<commit_before>/******************************************************************************
 * Copyright (c) 2000-2015 <NAME> AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.eclipse.titanium.markers.spotters.implementation;

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

import org.eclipse.titan.designer.AST.IVisitableNode;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template;
import org.eclipse.titanium.markers.spotters.BaseModuleCodeSmellSpotter;
import org.eclipse.titanium.markers.types.CodeSmellType;

public class UninitializedVar extends BaseModuleCodeSmellSpotter {
	private static final String ERROR_MESSAGE = "Variable templates should be initialized";

	public UninitializedVar() {
		super(CodeSmellType.UNINITIALIZED_VARIABLE);
	}
	
	@Override
	protected void process(final IVisitableNode node, final Problems problems) {
		if (node instanceof Def_Var_Template) {
			Def_Var_Template d = (Def_Var_Template)node;
			if (d.getInitialValue() == null) {
				problems.report(d.getLocation(), ERROR_MESSAGE);
			}
		} else if (node instanceof Def_Var) {
			Def_Var d = (Def_Var)node;
			if (d.getInitialValue() == null) {
				problems.report(d.getLocation(), ERROR_MESSAGE);
			}
		} else {
			return;
		}
	}
	
	@Override
	public List<Class<? extends IVisitableNode>> getStartNode() {
		List<Class<? extends IVisitableNode>> ret = new ArrayList<Class<? extends IVisitableNode>>(2);
		ret.add(Def_Var_Template.class);
		ret.add(Def_Var.class);
		return ret;
	}<commit_msg>lets write different message for templates and variables<commit_after>/******************************************************************************
 * Copyright (c) 2000-2015 <NAME> AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.eclipse.titanium.markers.spotters.implementation;

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

import org.eclipse.titan.designer.AST.IVisitableNode;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template;
import org.eclipse.titanium.markers.spotters.BaseModuleCodeSmellSpotter;
import org.eclipse.titanium.markers.types.CodeSmellType;

public class UninitializedVar extends BaseModuleCodeSmellSpotter {
	private static final String TEMPLATE_ERROR_MESSAGE = "Variable templates should be initialized";
	private static final String VARIABLE_ERROR_MESSAGE = "Variables should be initialized";

	public UninitializedVar() {
		super(CodeSmellType.UNINITIALIZED_VARIABLE);
	}
	
	@Override
	protected void process(final IVisitableNode node, final Problems problems) {
		if (node instanceof Def_Var_Template) {
			Def_Var_Template d = (Def_Var_Template)node;
			if (d.getInitialValue() == null) {
				problems.report(d.getLocation(), TEMPLATE_ERROR_MESSAGE);
			}
		} else if (node instanceof Def_Var) {
			Def_Var d = (Def_Var)node;
			if (d.getInitialValue() == null) {
				problems.report(d.getLocation(), VARIABLE_ERROR_MESSAGE);
			}
		} else {
			return;
		}
	}
	
	@Override
	public List<Class<? extends IVisitableNode>> getStartNode() {
		List<Class<? extends IVisitableNode>> ret = new ArrayList<Class<? extends IVisitableNode>>(2);
		ret.add(Def_Var_Template.class);
		ret.add(Def_Var.class);
		return ret;
	}
{'fraction_non_alphanumeric': 0.1735558408215661, 'fraction_numerical': 0.007702182284980745, 'mean_word_length': 5.637137989778535, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4050100', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1134, 'n_words': 264}