From 19aedcfef48125e054968be883d17e9fdbcf97c8 Mon Sep 17 00:00:00 2001 From: David RACODON Date: Thu, 22 Dec 2016 12:07:44 +0100 Subject: [PATCH] Fix quality flaws --- .../gherkin/parser/GherkinDialectProvider.java | 3 +++ .../tree/impl/AbstractBasicScenarioTreeImpl.java | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gherkin-frontend/src/main/java/org/sonar/gherkin/parser/GherkinDialectProvider.java b/gherkin-frontend/src/main/java/org/sonar/gherkin/parser/GherkinDialectProvider.java index 5092d1c..c7c44dc 100644 --- a/gherkin-frontend/src/main/java/org/sonar/gherkin/parser/GherkinDialectProvider.java +++ b/gherkin-frontend/src/main/java/org/sonar/gherkin/parser/GherkinDialectProvider.java @@ -45,6 +45,9 @@ public class GherkinDialectProvider { } } + private GherkinDialectProvider() { + } + public static GherkinDialect getDialect(String language) { Map> map = DIALECTS.get(language); if (map == null) { diff --git a/gherkin-frontend/src/main/java/org/sonar/gherkin/tree/impl/AbstractBasicScenarioTreeImpl.java b/gherkin-frontend/src/main/java/org/sonar/gherkin/tree/impl/AbstractBasicScenarioTreeImpl.java index fa6b39a..fbe6fb5 100644 --- a/gherkin-frontend/src/main/java/org/sonar/gherkin/tree/impl/AbstractBasicScenarioTreeImpl.java +++ b/gherkin-frontend/src/main/java/org/sonar/gherkin/tree/impl/AbstractBasicScenarioTreeImpl.java @@ -118,18 +118,18 @@ private void setSemanticStepTypes() { private void setSyntacticStepTypes(String language) { GherkinDialect dialect = GherkinDialectProvider.getDialect(language); - String prefix; + String stepPrefix; for (StepTree currentStep : steps) { - prefix = currentStep.prefix().text(); - if (dialect.getGivenStepKeywords().contains(prefix)) { + stepPrefix = currentStep.prefix().text(); + if (dialect.getGivenStepKeywords().contains(stepPrefix)) { currentStep.setSyntacticType(StepTree.SyntacticStepType.GIVEN); - } else if (dialect.getWhenStepKeywords().contains(prefix)) { + } else if (dialect.getWhenStepKeywords().contains(stepPrefix)) { currentStep.setSyntacticType(StepTree.SyntacticStepType.WHEN); - } else if (dialect.getThenStepKeywords().contains(prefix)) { + } else if (dialect.getThenStepKeywords().contains(stepPrefix)) { currentStep.setSyntacticType(StepTree.SyntacticStepType.THEN); - } else if (dialect.getButStepKeywords().contains(prefix)) { + } else if (dialect.getButStepKeywords().contains(stepPrefix)) { currentStep.setSyntacticType(StepTree.SyntacticStepType.BUT); - } else if (dialect.getAndStepKeywords().contains(prefix)) { + } else if (dialect.getAndStepKeywords().contains(stepPrefix)) { currentStep.setSyntacticType(StepTree.SyntacticStepType.AND); } else { currentStep.setSyntacticType(StepTree.SyntacticStepType.STAR);