<commit_before>package checkstyle.checks.coding;

import checkstyle.token.TokenTree;
import haxe.macro.Expr;

@name("MultipleVariableDeclarations")
@desc("Checks that each variable declaration is in its own statement and on its own line.")
class MultipleVariableDeclarationsCheck extends Check {

	public function new() {
		super(TOKEN);
		categories = [Category.STYLE, Category.CLARITY, Category.COMPLEXITY];
		points = 2;
	}

	override function actualRun() {
		var root:TokenTree = checker.getTokenTree();
		var acceptableTokens:Array<TokenTree> = root.filter([Kwd(KwdVar)], ALL);

		for (v in acceptableTokens) {
			var count = 0;
			for (c in v.childs) {
				switch (c.tok) {
					case Const(CIdent(name)):
						count++;
					default:
				}
			}
			if (count > 1) logPos("Each variable declaration must be in its own statement", v.pos);
		}

		// Need line no of each token to remove line based check
		for (i in 0 ... checker.lines.length) {
			if (isLineSuppressed(i)) return;
			var line = checker.lines[i];
			if (~/(var ).*;.*(var ).*;$/.match(line)) log("Only one variable definition per line allowed", i + 1, 0);
		}
	}
}<commit_msg>removed line based check in MultipleVariableDeclarations<commit_after>package checkstyle.checks.coding;

import checkstyle.token.TokenTree;

@name("MultipleVariableDeclarations")
@desc("Checks that each variable declaration is in its own statement and on its own line.")
class MultipleVariableDeclarationsCheck extends Check {

	public function new() {
		super(TOKEN);
		categories = [Category.STYLE, Category.CLARITY, Category.COMPLEXITY];
		points = 2;
	}

	override function actualRun() {
		var root:TokenTree = checker.getTokenTree();
		var acceptableTokens:Array<TokenTree> = root.filter([Kwd(KwdVar)], ALL);

		var lastVarLineNo = -1;
		for (v in acceptableTokens) {
			var curVarLineNo = checker.getLinePos(v.pos.min).line;
			if (lastVarLineNo > 0 && lastVarLineNo == curVarLineNo) logPos("Only one variable definition per line allowed", v.pos);
			lastVarLineNo = curVarLineNo;
			var count = 0;
			for (c in v.childs) {
				switch (c.tok) {
					case Const(CIdent(name)):
						count++;
					default:
				}
			}
			if (count > 1) logPos("Each variable declaration must be in its own statement", v.pos);
		}
	}
}
{'fraction_non_alphanumeric': 0.12180052956751986, 'fraction_numerical': 0.0048543689320388345, 'mean_word_length': 4.015486725663717, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '3402560', 'n_tokens_mistral': 825, 'n_tokens_neox': 716, 'n_words': 212}