<commit_before>package com.puresol.coding.lang.java.metrics;

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

import com.puresol.coding.metrics.mccabe.LanguageDependedMcCabeMetric;
import com.puresol.uhura.ast.ParserTree;

/**
 * This is the actual implementation of the McCabe metric for Java.
 * 
 * @author <NAME>
 * 
 */
public class McCabeMetricImpl implements LanguageDependedMcCabeMetric {

	private static final List<String> blockNames = new ArrayList<String>();
	static {
		blockNames.add("IfThenStatement");
		blockNames.add("IfThenElseStatement");
		blockNames.add("IfThenElseStatementNoShortIf");
		blockNames.add("BasicForStatement");
		blockNames.add("ForStatementNoShortIf");
		blockNames.add("EnhancedForStatement");
		blockNames.add("WhileStatement");
		blockNames.add("WhileStatementNoShortIf");
		blockNames.add("DoStatement");
		blockNames.add("CatchClause");
		blockNames.add("SwitchLabel");
		blockNames.add("QUESTION_MARK");
	}

	@Override
	public boolean increasesCyclomaticComplexity(ParserTree node) {
		if (!blockNames.contains(node.getName())) {
			return false;
		}
		if ("SwitchLabel".equals(node.getName())) {
			if (node.getParent().getChildren().indexOf(node) > 0) {
				return false;
			}
		}
		if ("QUESTION_MARK".equals(node.getName())) {
			if ("ConditionalExpression".equals(node.getParent().getName())) {
				return true;
			} else {
				return false;
			}
		}
		return true;
	}
}
<commit_msg>- improvement in language depended McCabeMetric implementation<commit_after>package com.puresol.coding.lang.java.metrics;

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

import com.puresol.coding.metrics.mccabe.LanguageDependedMcCabeMetric;
import com.puresol.uhura.ast.ParserTree;

/**
 * This is the actual implementation of the McCabe metric for Java.
 * 
 * @author <NAME>
 * 
 */
public class McCabeMetricImpl implements LanguageDependedMcCabeMetric {

	private static final List<String> blockNames = new ArrayList<String>();
	static {
		blockNames.add("IfThenStatement");
		blockNames.add("IfThenElseStatement");
		blockNames.add("IfThenElseStatementNoShortIf");
		blockNames.add("BasicForStatement");
		blockNames.add("ForStatementNoShortIf");
		blockNames.add("EnhancedForStatement");
		blockNames.add("WhileStatement");
		blockNames.add("WhileStatementNoShortIf");
		blockNames.add("DoStatement");
		blockNames.add("CatchClause");
		blockNames.add("SwitchLabel");
		blockNames.add("QUESTION_MARK");
	}

	@Override
	public int increasesCyclomaticComplexityBy(ParserTree node) {
		if (!blockNames.contains(node.getName())) {
			return 0;
		}
		if ("SwitchLabel".equals(node.getName())) {
			if (node.getParent().getChildren().indexOf(node) > 0) {
				return 0;
			}
		}
		if ("QUESTION_MARK".equals(node.getName())) {
			if ("ConditionalExpression".equals(node.getParent().getName())) {
				return 1;
			} else {
				return 0;
			}
		}
		return 1;
	}
}

{'fraction_non_alphanumeric': 0.1375387797311272, 'fraction_numerical': 0.002412961047914512, 'mean_word_length': 5.148305084745763, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4630221', 'n_tokens_mistral': 1012, 'n_tokens_neox': 896, 'n_words': 156}