Skip to content

Commit

Permalink
RED-1286 Adding error for "..." KW/TC name
Browse files Browse the repository at this point in the history
Error for RF 3.2 and above

Change-Id: I20d95ca3fd34009f456204fbfbcf72243ff49c44
  • Loading branch information
lwlodarc committed Jul 24, 2020
1 parent ffd401a commit 91d5067
Show file tree
Hide file tree
Showing 9 changed files with 1,166 additions and 1,099 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.junit.jupiter.api.Test;
import org.rf.ide.core.environment.RobotVersion;
import org.rf.ide.core.testdata.model.table.keywords.UserKeyword;
import org.rf.ide.core.validation.ProblemPosition;
import org.robotframework.ide.eclipse.main.plugin.mockmodel.RobotSuiteFileCreator;
Expand Down Expand Up @@ -133,10 +134,11 @@ public void keywordDefinitionIsLineContinuationIsReported() throws CoreException
.build();

final List<KeywordEntity> accessibleKws = newArrayList(newResourceKeyword("kw", new Path("/res.robot")));
final FileValidationContext context = prepareContext(accessibleKws);
final RobotVersion version = RobotVersion.from("3.1.2");
final FileValidationContext context = prepareContext(accessibleKws, version);

final Collection<Problem> problems = validate(context, fileModel);
assertThat(problems).containsOnly(new Problem(KeywordsProblem.KEYWORD_NAME_IS_LINE_CONTINUATION,
assertThat(problems).containsOnly(new Problem(KeywordsProblem.KEYWORD_NAME_IS_LINE_CONTINUATION_PRE_3_2,
new ProblemPosition(2, Range.closed(17, 20))));
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,30 @@ public List<? extends IMarkerResolution> createFixers(final IMarker marker) {
return newArrayList(new ChangeToFixer(":FOR"));
}
},
KEYWORD_NAME_IS_LINE_CONTINUATION {
KEYWORD_NAME_IS_LINE_CONTINUATION_PRE_3_2 {

@Override
public ProblemCategory getProblemCategory() {
return ProblemCategory.DEFINITION_NAME_IS_LINE_CONTINUATION;
return ProblemCategory.DEFINITION_NAME_IS_LINE_CONTINUATION_PRE_3_2;
}

@Override
public String getProblemDescription() {
return "Definition name '...' is considered confusing and deprecated since RobotFramework 3.1.2";
}
},
KEYWORD_NAME_IS_LINE_CONTINUATION_3_2 {

@Override
public ProblemCategory getProblemCategory() {
return ProblemCategory.DEFINITION_NAME_IS_LINE_CONTINUATION_3_2;
}

@Override
public String getProblemDescription() {
return "Definition name '...' is considered confusing and removed since 3.2";
}
},
KEYWORD_NAME_WITH_DOTS {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,20 @@ public Severity getDefaultSeverity() {
ProblemCategoryType.CODE_STYLE,
"Variables are used in called keyword names",
"Occurs when variables are used in name of called keyword."),
DEFINITION_NAME_IS_LINE_CONTINUATION(
DEFINITION_NAME_IS_LINE_CONTINUATION_PRE_3_2(
ProblemCategoryType.CODE_STYLE,
"Line continuation as definition name",
"Occurs when keyword, task or test case name is line continuation. It may be confused with line continuation and is deprecated since RF 3.1.2."),
DEFINITION_NAME_IS_LINE_CONTINUATION_3_2(
ProblemCategoryType.CODE_STYLE,
"Line continuation as definition name",
"Occurs when keyword, task or test case name is line continuation. It may be confused with line continuation and is removed since RF 3.2.") {

@Override
public Severity getDefaultSeverity() {
return Severity.ERROR;
}
},
ARGUMENT_IN_MULTIPLE_CELLS(
ProblemCategoryType.CODE_STYLE,
"Template keyword written in multiple cells",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,30 @@ public String getProblemDescription() {
return "Task name cannot be empty";
}
},
TASK_NAME_IS_LINE_CONTINUATION {
TASK_NAME_IS_LINE_CONTINUATION_PRE_3_2 {

@Override
public ProblemCategory getProblemCategory() {
return ProblemCategory.DEFINITION_NAME_IS_LINE_CONTINUATION;
return ProblemCategory.DEFINITION_NAME_IS_LINE_CONTINUATION_PRE_3_2;
}

@Override
public String getProblemDescription() {
return "Definition name '...' is considered confusing and deprecated since RobotFramework 3.1.2";
}
},
TASK_NAME_IS_LINE_CONTINUATION_3_2 {

@Override
public ProblemCategory getProblemCategory() {
return ProblemCategory.DEFINITION_NAME_IS_LINE_CONTINUATION_3_2;
}

@Override
public String getProblemDescription() {
return "Definition name '...' is considered confusing and removed since RobotFramework 3.2";
}
},
EMPTY_TASK {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,30 @@ public String getProblemDescription() {
return "Test case name cannot be empty";
}
},
TEST_CASE_NAME_IS_LINE_CONTINUATION {
TEST_CASE_NAME_IS_LINE_CONTINUATION_PRE_3_2 {

@Override
public ProblemCategory getProblemCategory() {
return ProblemCategory.DEFINITION_NAME_IS_LINE_CONTINUATION;
return ProblemCategory.DEFINITION_NAME_IS_LINE_CONTINUATION_PRE_3_2;
}

@Override
public String getProblemDescription() {
return "Definition name '...' is considered confusing and deprecated since RobotFramework 3.1.2";
}
},
TEST_CASE_NAME_IS_LINE_CONTINUATION_3_2 {

@Override
public ProblemCategory getProblemCategory() {
return ProblemCategory.DEFINITION_NAME_IS_LINE_CONTINUATION_3_2;
}

@Override
public String getProblemDescription() {
return "Definition name '...' is considered confusing and removed since RobotFramework 3.2";
}
},
EMPTY_CASE {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.stream.Stream;

import org.eclipse.core.runtime.IProgressMonitor;
import org.rf.ide.core.environment.RobotVersion;
import org.rf.ide.core.testdata.model.RobotFile;
import org.rf.ide.core.testdata.model.search.keyword.KeywordScope;
import org.rf.ide.core.testdata.model.table.LocalSetting;
Expand Down Expand Up @@ -82,8 +83,13 @@ private void reportKeywordNameWithDots() {
final RobotToken keywordName = keyword.getName();
final String name = keywordName.getText();
if ("...".equals(name.trim())) {
final RobotProblem problem = RobotProblem.causedBy(KeywordsProblem.KEYWORD_NAME_IS_LINE_CONTINUATION)
.formatMessageWith(name);
KeywordsProblem cause;
if (validationContext.getVersion().isNewerOrEqualTo(new RobotVersion(3, 2))) {
cause = KeywordsProblem.KEYWORD_NAME_IS_LINE_CONTINUATION_3_2;
} else {
cause = KeywordsProblem.KEYWORD_NAME_IS_LINE_CONTINUATION_PRE_3_2;
}
final RobotProblem problem = RobotProblem.causedBy(cause).formatMessageWith(name);
final Map<String, Object> arguments = ImmutableMap.of(AdditionalMarkerAttributes.NAME, name);
reporter.handleProblem(problem, validationContext.getFile(), keywordName, arguments);
} else if (name.contains(".")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Set;

import org.eclipse.core.runtime.IProgressMonitor;
import org.rf.ide.core.environment.RobotVersion;
import org.rf.ide.core.testdata.model.RobotFile;
import org.rf.ide.core.testdata.model.table.keywords.names.EmbeddedKeywordNamesSupport;
import org.rf.ide.core.testdata.model.table.setting.SuiteSetup;
Expand Down Expand Up @@ -74,8 +75,13 @@ private void reportLineContinuationAsNameOfTask() {
final RobotToken taskName = task.getName();
final String name = taskName.getText();
if ("...".equals(name.trim())) {
final RobotProblem problem = RobotProblem.causedBy(TasksProblem.TASK_NAME_IS_LINE_CONTINUATION)
.formatMessageWith(name);
TasksProblem cause;
if (validationContext.getVersion().isNewerOrEqualTo(new RobotVersion(3, 2))) {
cause = TasksProblem.TASK_NAME_IS_LINE_CONTINUATION_3_2;
} else {
cause = TasksProblem.TASK_NAME_IS_LINE_CONTINUATION_PRE_3_2;
}
final RobotProblem problem = RobotProblem.causedBy(cause).formatMessageWith(name);
final Map<String, Object> arguments = ImmutableMap.of(AdditionalMarkerAttributes.NAME, name);
reporter.handleProblem(problem, validationContext.getFile(), taskName, arguments);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Set;

import org.eclipse.core.runtime.IProgressMonitor;
import org.rf.ide.core.environment.RobotVersion;
import org.rf.ide.core.testdata.model.RobotFile;
import org.rf.ide.core.testdata.model.table.keywords.names.EmbeddedKeywordNamesSupport;
import org.rf.ide.core.testdata.model.table.setting.SuiteSetup;
Expand Down Expand Up @@ -74,8 +75,13 @@ private void reportLineContinuationAsNameOfCase() {
final RobotToken caseName = testCase.getName();
final String name = caseName.getText();
if ("...".equals(name.trim())) {
final RobotProblem problem = RobotProblem.causedBy(TestCasesProblem.TEST_CASE_NAME_IS_LINE_CONTINUATION)
.formatMessageWith(name);
TestCasesProblem cause;
if (validationContext.getVersion().isNewerOrEqualTo(new RobotVersion(3, 2))) {
cause = TestCasesProblem.TEST_CASE_NAME_IS_LINE_CONTINUATION_3_2;
} else {
cause = TestCasesProblem.TEST_CASE_NAME_IS_LINE_CONTINUATION_PRE_3_2;
}
final RobotProblem problem = RobotProblem.causedBy(cause).formatMessageWith(name);
final Map<String, Object> arguments = ImmutableMap.of(AdditionalMarkerAttributes.NAME, name);
reporter.handleProblem(problem, validationContext.getFile(), caseName, arguments);
}
Expand Down

0 comments on commit 91d5067

Please sign in to comment.