Skip to content

Commit

Permalink
Merge pull request #190 from vsiakka/partiallyCommentedTagFixes
Browse files Browse the repository at this point in the history
Fix no-partially-commented-tag-lines rule not detecting errors in fea…
  • Loading branch information
vsiakka committed May 12, 2019
2 parents 8795a02 + 88928be commit 803a040
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
32 changes: 23 additions & 9 deletions src/rules/no-partially-commented-tag-lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,36 @@ var rule = 'no-partially-commented-tag-lines';

function noPartiallyCommentedTagLines(feature) {
var errors = [];
if (feature && feature.children) {
feature.children.forEach(function(scenario) {
if (scenario.tags) {
scenario.tags.forEach(function(tag) {
if (tag.name.indexOf('#') > 0) {
errors.push({message: 'Partially commented tag lines not allowed',
rule : rule,
line : tag.location.line});
}

checkTags(feature, errors);

if (feature.children) {
feature.children.forEach(function(child) {
checkTags(child, errors);

if (child.examples) {
child.examples.forEach(function(example) {
checkTags(example, errors);
});
}
});
}
return errors;
}

function checkTags(node, errors) {
if (node.tags) {
console.log(node.tags) //eslint-disable-line
node.tags.forEach(function(tag) {
if (tag.name.indexOf('#') > 0) {
errors.push({message: 'Partially commented tag lines not allowed',
rule : rule,
line : tag.location.line});
}
});
}
}

module.exports = {
name: rule,
run: noPartiallyCommentedTagLines
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@tag #@commented-out-tag
@tag #this is a comment
Feature: Test for the no-partially-commented-tag-lines

Background:
Expand All @@ -12,6 +12,7 @@ Scenario: This is a Scenario
@tag #@commented-out-tag
Scenario Outline: This is a Scenario Outline
Then this is a step
@tag#@commented-out-tag
Examples:
|foo|
|bar|
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ describe('No Partially Commented Tag Lines Rule', function() {

it('detects errors for features, scenarios, and scenario outlines', function() {
runTest('no-partially-commented-tag-lines/Violations.feature', {}, [
// TODO: fix features
//{ messageElements: {}, line: 1 },
{ messageElements: {}, line: 1 },
{ messageElements: {}, line: 7 },
{ messageElements: {}, line: 12 },
{ messageElements: {}, line: 15 },
]);
});
});

0 comments on commit 803a040

Please sign in to comment.