Commit 023da2e4 authored by Kristof Szabados's avatar Kristof Szabados
Browse files

could be final.


Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent e93c6170
......@@ -46,7 +46,7 @@ public class DefinitionNameTooLong extends BaseModuleCodeSmellSpotter{
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof Definition) {
final Definition s = (Definition) node;
int lengthOfFunctionName=s.getIdentifier().getDisplayName().length();
final int lengthOfFunctionName = s.getIdentifier().getDisplayName().length();
if(lengthOfFunctionName>recommendedLenghtOfFunctionName){
final String msg = MessageFormat.format(WARNING_MESSAGE,
lengthOfFunctionName, recommendedLenghtOfFunctionName);
......
......@@ -94,11 +94,11 @@ final class SuspiciouslyUsedIf extends ASTVisitor {
for (final If_Clause clause : ifs) {
final Value cond = clause.getExpression();
if (cond != null) {
ReferenceCollector refCollector = new ReferenceCollector();
final ReferenceCollector refCollector = new ReferenceCollector();
redirectValue.accept(refCollector);
ArrayList<Reference> foundReferences = refCollector.getReferences();
final ArrayList<Reference> foundReferences = refCollector.getReferences();
for (Reference reference : foundReferences) {
for (final Reference reference : foundReferences) {
final RefUsedInMatching mv = new RefUsedInMatching(reference);
cond.accept(mv);
if (mv.getUsed()) {
......
......@@ -59,8 +59,8 @@ public class InvokingFunctionsFromSpecificPlaces extends BaseModuleCodeSmellSpot
@Override
public int visit(final IVisitableNode node) {
if(node instanceof Referenced_Value) {
Referenced_Value value = (Referenced_Value) node;
Assignment_type asst = value.getReference().getAssOld().getAssignmentType();
final Referenced_Value value = (Referenced_Value) node;
final Assignment_type asst = value.getReference().getAssOld().getAssignmentType();
if (asst == Assignment_type.A_FUNCTION_RVAL ||
asst == Assignment_type.A_EXT_FUNCTION_RVAL ||
asst == Assignment_type.A_FUNCTION_RTEMP ||
......@@ -70,26 +70,26 @@ public class InvokingFunctionsFromSpecificPlaces extends BaseModuleCodeSmellSpot
}
if(node instanceof RNDExpression || node instanceof RNDWithValueExpression ) {
Expression_Value exp = (Expression_Value) node;
final Expression_Value exp = (Expression_Value) node;
problems.report(exp.getLocation(), "Random number generation change the actual snapshot");
}
if(node instanceof AllComponentAliveExpression || node instanceof AllComponentRunningExpression ||
node instanceof AnyComponentAliveExpression || node instanceof AnyComponentRunningExpression ||
node instanceof ComponentAliveExpression || node instanceof ComponentRunningExpression ) {
Expression_Value exp = (Expression_Value) node;
final Expression_Value exp = (Expression_Value) node;
problems.report(exp.getLocation(), "State of component may change during the actual snapshot");
}
if(node instanceof AnyPortCheckStateExpression ||node instanceof AllPortCheckSateExpression || node instanceof CheckStateExpression) {
Expression_Value exp = (Expression_Value) node;
final Expression_Value exp = (Expression_Value) node;
problems.report(exp.getLocation(), "State of port may change during the actual snapshot");
}
if(node instanceof AnyTimerRunningExpression ||
node instanceof TimerRunningExpression ||
node instanceof TimerReadExpression) {
Expression_Value exp = (Expression_Value) node;
final Expression_Value exp = (Expression_Value) node;
problems.report(exp.getLocation(), "State of timer may change during the actual snapshot");
}
return V_CONTINUE;
......@@ -99,7 +99,7 @@ public class InvokingFunctionsFromSpecificPlaces extends BaseModuleCodeSmellSpot
@Override
public void process(final IVisitableNode node, final Problems problems) {
FunctionVisitor visitor = new FunctionVisitor(problems);
final FunctionVisitor visitor = new FunctionVisitor(problems);
if (node instanceof AltGuard) {
final AltGuard altGuard = (AltGuard) node;
......
......@@ -50,7 +50,7 @@ public class LanguageMixing extends BaseProjectCodeSmellSpotter {
final Set<String> knownModuleNames = projectSourceParser.getKnownModuleNames();
final List<TTCN3Module> modules = new ArrayList<TTCN3Module>();
for (final String moduleName : new TreeSet<String>(knownModuleNames)) {
Module module = projectSourceParser.getModuleByName(moduleName);
final Module module = projectSourceParser.getModuleByName(moduleName);
if(module instanceof TTCN3Module) {
modules.add((TTCN3Module) module);
}
......@@ -65,10 +65,10 @@ public class LanguageMixing extends BaseProjectCodeSmellSpotter {
String lastLanguage = null;
TTCN3Module lastModule = null;
for (TTCN3Module module: modules) {
List<String> languageSpecifications = module.getLanguageSpecifictions();
for (final TTCN3Module module: modules) {
final List<String> languageSpecifications = module.getLanguageSpecifictions();
if(languageSpecifications != null && languageSpecifications.size() > 0) {
String tempLanguage = languageSpecifications.get(0);
final String tempLanguage = languageSpecifications.get(0);
if(tempLanguage != null) {
if(lastLanguage == null) {
lastLanguage = tempLanguage;
......
......@@ -81,7 +81,7 @@ public class RunsOnScopeReduction extends BaseModuleCodeSmellSpotter{
if (definitions.isEmpty()) {
if (isTestCase) {
List<Definition> attributes = componentType.getComponentBody().getDefinitions();
final List<Definition> attributes = componentType.getComponentBody().getDefinitions();
if (!attributes.isEmpty()) {
problems.report(identifier.getLocation(), MessageFormat.format("The runs on component `{0}'' seems to be never used. Use empty component.",componentIdentifier.getDisplayName()));
}
......@@ -111,7 +111,7 @@ public class RunsOnScopeReduction extends BaseModuleCodeSmellSpotter{
}
final Set<Identifier> setNodes = new HashSet<Identifier>();
setNodes.add(component.getIdentifier());
for (ComponentTypeBody variable : parentComponentBodies) {
for (final ComponentTypeBody variable : parentComponentBodies) {
final Set<Identifier> identifiersOfNode = new HashSet<Identifier>();
final ComponentTypeBody cb = searchComponent(variable, definitions, identifiersOfNode);
if (cb != null) {
......
......@@ -79,9 +79,9 @@ public class SelectUnion extends BaseModuleCodeSmellSpotter {
// Check the union, get the types.
final UnionItemVisitor unionVisitor = new UnionItemVisitor();
List<Identifier> foundIds = new ArrayList<Identifier>();
for(Reference ref : caseVisitor.getReferenceList()){
List<ISubReference> reflist = ref.getSubreferences();
final List<Identifier> foundIds = new ArrayList<Identifier>();
for(final Reference ref : caseVisitor.getReferenceList()){
final List<ISubReference> reflist = ref.getSubreferences();
if(reflist.isEmpty()){
continue;
}
......@@ -96,11 +96,11 @@ public class SelectUnion extends BaseModuleCodeSmellSpotter {
caseVisitor.getUnionType().accept(unionVisitor);
// Check if the found types are the same as the union types.
List<Identifier> unionItems = unionVisitor.getItemsFound();
final List<Identifier> unionItems = unionVisitor.getItemsFound();
if(unionItems.isEmpty()){
return;
}
for(Identifier item : unionItems){
for(final Identifier item : unionItems){
foundIds.remove(item);
}
if(foundIds.isEmpty()){
......@@ -142,13 +142,13 @@ public class SelectUnion extends BaseModuleCodeSmellSpotter {
return V_CONTINUE;
} else if (node instanceof TemplateInstance) {
final TemplateInstance ti = (TemplateInstance)node;
IValue val = ti.getTemplateBody().getValue();
final IValue val = ti.getTemplateBody().getValue();
if (val == null || val.getIsErroneous(timestamp) || !(val instanceof IsChoosenExpression)) {
errorDuringVisiting = true;
return V_ABORT;
}
IsChoosenExpression expr = (IsChoosenExpression)val;
final IsChoosenExpression expr = (IsChoosenExpression)val;
final IsChoosenItemVisitor itemVisitor = new IsChoosenItemVisitor();
expr.accept(itemVisitor);
if(itemVisitor.getReference() == null){
......@@ -210,9 +210,9 @@ public class SelectUnion extends BaseModuleCodeSmellSpotter {
} else if (node instanceof WithAttributesPath) {
return V_CONTINUE;
} else if (node instanceof CompFieldMap){
CompFieldMap cm = (CompFieldMap) node;
Map<String, CompField> map = cm.getComponentFieldMap(timestamp);
for(Map.Entry<String, CompField> entry : map.entrySet()) {
final CompFieldMap cm = (CompFieldMap) node;
final Map<String, CompField> map = cm.getComponentFieldMap(timestamp);
for(final Map.Entry<String, CompField> entry : map.entrySet()) {
itemsFound.add(entry.getValue().getIdentifier());
}
return V_CONTINUE;
......
......@@ -45,23 +45,23 @@ public class UnusedGlobalDefinition extends BaseProjectCodeSmellSpotter {
final Set<Assignment> unused = new HashSet<Assignment>();
for (final String moduleName : new TreeSet<String>(knownModuleNames)) {
Module module = projectSourceParser.getModuleByName(moduleName);
final Module module = projectSourceParser.getModuleByName(moduleName);
modules.add(module);
final GlobalDefinitionCheck chek = new GlobalDefinitionCheck();
module.accept(chek);
unused.addAll(chek.getDefinitions());
}
for (Module module : modules) {
for (final Module module : modules) {
final GlobalUsedDefinitionCheck chekUsed = new GlobalUsedDefinitionCheck();
module.accept(chekUsed);
Set<Assignment> used = chekUsed.getDefinitions();
final Set<Assignment> used = chekUsed.getDefinitions();
//remove from the unused list items that are referenced
unused.removeAll(used);
//remove from the unused list undefined items who's real version is referenced
final ArrayList<Assignment> tobeRemoved = new ArrayList<Assignment>();
for (Assignment assignment : unused) {
for (final Assignment assignment : unused) {
if (assignment instanceof Undefined_Assignment) {
final Assignment realAssignment = ((Undefined_Assignment)assignment).getRealAssignment(CompilationTimeStamp.getBaseTimestamp());
if (used.contains(realAssignment)) {
......@@ -72,7 +72,7 @@ public class UnusedGlobalDefinition extends BaseProjectCodeSmellSpotter {
unused.removeAll(tobeRemoved);
}
for (Assignment ass : unused) {
for (final Assignment ass : unused) {
final String name = ass.getIdentifier().getDisplayName();
final String msg = MessageFormat.format("The {0} `{1}'' seems to be never used globally", ass.getAssignmentName(), name);
problems.report(ass.getIdentifier().getLocation(), msg);
......
......@@ -46,13 +46,13 @@ public class UnusedImportsProject extends BaseProjectCodeSmellSpotter{
final Set<String> knownModuleNames = projectSourceParser.getKnownModuleNames();
final List<Module> modules = new ArrayList<Module>();
for (final String moduleName : new TreeSet<String>(knownModuleNames)) {
Module module = projectSourceParser.getModuleByName(moduleName);
final Module module = projectSourceParser.getModuleByName(moduleName);
modules.add(module);
}
final Set<Module> setOfImportedModules = new HashSet<Module>();
for (Module module : modules) {
for (final Module module : modules) {
setOfImportedModules.clear();
setOfImportedModules.addAll( module.getImportedModules());
......@@ -62,9 +62,9 @@ public class UnusedImportsProject extends BaseProjectCodeSmellSpotter{
setOfImportedModules.removeAll(check.getModules());
if (module instanceof TTCN3Module) {
for (ImportModule mod : ((TTCN3Module)module).getImports()){
for (final ImportModule mod : ((TTCN3Module)module).getImports()){
final Identifier importIdentifier = mod.getIdentifier();
for (Module m : setOfImportedModules) {
for (final Module m : setOfImportedModules) {
if(m.getIdentifier().equals(importIdentifier)) {
problems.report(importIdentifier.getLocation(), "Possibly unused importation");
}
......@@ -73,9 +73,9 @@ public class UnusedImportsProject extends BaseProjectCodeSmellSpotter{
} else {
final ModuleImportsCheck importsCheck = new ModuleImportsCheck();
module.accept(importsCheck);
for (ModuleImportation im : importsCheck.getImports()) {
for (final ModuleImportation im : importsCheck.getImports()) {
final Identifier importIdentifier = im.getIdentifier();
for (Module m : setOfImportedModules) {
for (final Module m : setOfImportedModules) {
if(m.getIdentifier().equals(importIdentifier)) {
problems.report(importIdentifier.getLocation(), "Possibly unused importation");
}
......@@ -131,7 +131,7 @@ public class UnusedImportsProject extends BaseProjectCodeSmellSpotter{
@Override
public int visit(final IVisitableNode node) {
if(node instanceof ModuleImportation){
ModuleImportation mod = (ModuleImportation) node;
final ModuleImportation mod = (ModuleImportation) node;
setOfModules.add(mod);
}
return V_CONTINUE;
......
......@@ -46,7 +46,7 @@ public class UnusedLocalDefinition extends BaseModuleCodeSmellSpotter {
node.accept(chekUsed);
unused.removeAll(chekUsed.getDefinitions());
for (Assignment ass : unused) {
for (final Assignment ass : unused) {
final String name = ass.getIdentifier().getDisplayName();
final String msg = MessageFormat.format("The {0} `{1}'' seems to be never used locally (new)", ass.getAssignmentName(), name);
problems.report(ass.getIdentifier().getLocation(), msg);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment