Skip to content

Commit

Permalink
Fix quality flaws
Browse files Browse the repository at this point in the history
  • Loading branch information
racodond committed Dec 7, 2016
1 parent 35c185e commit 72db3a6
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Number of features.
* Wording should remain at business level


### Templates
### Template

* Regular expression on comment

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class RuleDescriptionsGenerator {
.put("[[allForbiddenWords]]", generateForbiddenWordsHtmlTable())
.build();

public void generateHtmlRuleDescription(String templatePath, String outputPath) throws IOException {
public void generateHtmlRuleDescription(String templatePath, String outputPath) {
try (OutputStream fileOutputStream = new FileOutputStream(outputPath)) {
Writer writer = new BufferedWriter(new OutputStreamWriter(fileOutputStream, UTF_8));
writer.write(replaceTags(FileUtils.readFileToString(new File(templatePath), UTF_8)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ public class TagRightLevelCheck extends DoubleDispatchVisitorCheck {

private PrefixTree featurePrefix;

private final List<TagTree> featureTagTrees = new ArrayList<>();
private final Set<String> featureTags = new HashSet<>();

private final List<TagTree> scenarioTagTrees = new ArrayList<>();
private final List<Set<String>> scenarioTags = new ArrayList<>();

@Override
public void visitGherkinDocument(GherkinDocumentTree tree) {
featureTagTrees.clear();
featureTags.clear();
scenarioTagTrees.clear();
scenarioTags.clear();
Expand All @@ -64,7 +62,6 @@ public void visitGherkinDocument(GherkinDocumentTree tree) {

@Override
public void visitFeatureDeclaration(FeatureDeclarationTree tree) {
featureTagTrees.addAll(tree.tags());
featureTags.addAll(tree.tags().stream().map(TagTree::text).collect(Collectors.toSet()));
featurePrefix = tree.prefix();
super.visitFeatureDeclaration(tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@ActivatedByDefault
public class WordingBusinessLevelCheck extends DoubleDispatchVisitorCheck {

protected final static String[] FORBIDDEN_WORDS = {"checkbox", "click", "drop-down list", "dropdown list", "field", "fill in the form", "radio button"};
protected static final String[] FORBIDDEN_WORDS = {"checkbox", "click", "drop-down list", "dropdown list", "field", "fill in the form", "radio button"};

@Override
public void visitStep(StepTree tree) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
*/
package org.sonar.gherkin.tree.impl;

import com.google.common.base.Preconditions;
import org.sonar.plugins.gherkin.api.tree.SyntaxToken;
import org.sonar.plugins.gherkin.api.tree.TableTree;
import org.sonar.plugins.gherkin.api.tree.Tree;
import org.sonar.plugins.gherkin.api.visitors.DoubleDispatchVisitor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
Expand All @@ -36,16 +36,12 @@ public class TableTreeImpl extends GherkinTree implements TableTree {
private final List<String> headers;

public TableTreeImpl(List<SyntaxToken> rows) {
Preconditions.checkArgument(!rows.isEmpty());
this.rows = rows;

if (rows.isEmpty()) {
this.headers = new ArrayList<>();
} else {
this.headers = Arrays
.stream(rows.get(0).text().substring(1, rows.get(0).text().length() - 1).split("\\|"))
.map(String::trim)
.collect(Collectors.toList());
}
this.headers = Arrays
.stream(rows.get(0).text().substring(1, rows.get(0).text().length() - 1).split("\\|"))
.map(String::trim)
.collect(Collectors.toList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.nio.charset.Charset;

@FunctionalInterface
public interface CharsetAwareVisitor {

void setCharset(Charset charset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class CommentLinesVisitor extends SubscriptionVisitor {

private int commentLines;
private GherkinCommentAnalyser commentAnalyser = new GherkinCommentAnalyser();
private final GherkinCommentAnalyser commentAnalyser = new GherkinCommentAnalyser();

public CommentLinesVisitor(Tree tree) {
commentLines = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import javax.annotation.Nullable;

@FunctionalInterface
public interface Descriptionable {

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import javax.annotation.Nullable;

@FunctionalInterface
public interface Nameable {

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ enum StepType {
GIVEN,
WHEN,
THEN,
UNKNOWN;
UNKNOWN
}

PrefixTree prefix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.List;

@FunctionalInterface
public interface Taggable {

List<TagTree> tags();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public GherkinChecks addChecks(String repositoryKey, Iterable<Class> checkClass)

public GherkinChecks addCustomChecks(@Nullable CustomGherkinRulesDefinition[] customRulesDefinitions) {
if (customRulesDefinitions != null) {

for (CustomGherkinRulesDefinition rulesDefinition : customRulesDefinitions) {
addChecks(rulesDefinition.repositoryKey(), Lists.newArrayList(rulesDefinition.checkClasses()));
}
Expand Down

0 comments on commit 72db3a6

Please sign in to comment.