<commit_before>/*
 * Copyright 2011 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.errorprone;

import com.google.errorprone.checkers.DeadExceptionChecker;
import com.google.errorprone.checkers.EmptyStatementChecker;
import com.google.errorprone.checkers.ErrorChecker;
import com.google.errorprone.checkers.ErrorChecker.AstError;
import com.google.errorprone.checkers.FallThroughSuppressionChecker;
import com.google.errorprone.checkers.PreconditionsCheckNotNullChecker;
import com.google.errorprone.checkers.PreconditionsCheckNotNullPrimitive1stArgChecker;
import com.google.errorprone.checkers.PreconditionsExpensiveStringChecker;

import com.sun.source.tree.AnnotationTree;
import com.sun.source.tree.EmptyStatementTree;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.tree.NewClassTree;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Scans the parsed AST, looking for violations of any of the configured checks.
 * @author <NAME> (<EMAIL>)
 */
public class ErrorProneScanner extends ErrorCollectingTreeScanner {

  private final Iterable<? extends ErrorChecker<MethodInvocationTree>>
      methodInvocationCheckers = Arrays.asList(
          new PreconditionsCheckNotNullChecker(),
          new PreconditionsExpensiveStringChecker(),
          new PreconditionsCheckNotNullPrimitive1stArgChecker());
  
  private final Iterable<? extends ErrorChecker<NewClassTree>>
      newClassCheckers = Arrays.asList(new DeadExceptionChecker());

  private final Iterable<? extends ErrorChecker<AnnotationTree>>
      annotationCheckers = Arrays.asList(
          new FallThroughSuppressionChecker());
  
  private final Iterable<? extends ErrorChecker<EmptyStatementTree>>
      emptyStatementCheckers = Arrays.asList(new EmptyStatementChecker());

  @Override
  public List<AstError> visitMethodInvocation(
      MethodInvocationTree methodInvocationTree, VisitorState state) {
    List<AstError> result = new ArrayList<AstError>();
    for (ErrorChecker<MethodInvocationTree> checker : methodInvocationCheckers) {
      AstError error = checker.check(methodInvocationTree, state.withPath(getCurrentPath()));
      if (error != null) {
        result.add(error);
      }<commit_msg>Added checker for empty if statement<commit_after>/*
 * Copyright 2011 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.errorprone;

import com.google.errorprone.checkers.DeadExceptionChecker;
import com.google.errorprone.checkers.EmptyIfStatementChecker;
import com.google.errorprone.checkers.EmptyStatementChecker;
import com.google.errorprone.checkers.ErrorChecker;
import com.google.errorprone.checkers.ErrorChecker.AstError;
import com.google.errorprone.checkers.FallThroughSuppressionChecker;
import com.google.errorprone.checkers.PreconditionsCheckNotNullChecker;
import com.google.errorprone.checkers.PreconditionsCheckNotNullPrimitive1stArgChecker;
import com.google.errorprone.checkers.PreconditionsExpensiveStringChecker;

import com.sun.source.tree.AnnotationTree;
import com.sun.source.tree.EmptyStatementTree;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.tree.NewClassTree;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Scans the parsed AST, looking for violations of any of the configured checks.
 * @author <NAME> (<EMAIL>)
 */
public class ErrorProneScanner extends ErrorCollectingTreeScanner {

  private final Iterable<? extends ErrorChecker<MethodInvocationTree>>
      methodInvocationCheckers = Arrays.asList(
          new PreconditionsCheckNotNullChecker(),
          new PreconditionsExpensiveStringChecker(),
          new PreconditionsCheckNotNullPrimitive1stArgChecker());
  
  private final Iterable<? extends ErrorChecker<NewClassTree>>
      newClassCheckers = Arrays.asList(new DeadExceptionChecker());

  private final Iterable<? extends ErrorChecker<AnnotationTree>>
      annotationCheckers = Arrays.asList(
          new FallThroughSuppressionChecker());
  
  private final Iterable<? extends ErrorChecker<EmptyStatementTree>>
      emptyStatementCheckers = Arrays.asList(
          //new EmptyStatementChecker(),
          new EmptyIfStatementChecker());

  @Override
  public List<AstError> visitMethodInvocation(
      MethodInvocationTree methodInvocationTree, VisitorState state) {
    List<AstError> result = new ArrayList<AstError>();
    for (ErrorChecker<MethodInvocationTree> checker : methodInvocationCheckers) {
      AstError error = checker.check(methodInvocationTree, state.withPath(getCurrentPath()));
      if (error != null) {
        result.add(error);
      }
{'fraction_non_alphanumeric': 0.08240611961057023, 'fraction_numerical': 0.0034770514603616135, 'mean_word_length': 4.949327817993796, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '825609', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1540, 'n_words': 412}