Skip to content

Commit

Permalink
Fix #57 FP on rule class-selector-naming-convention within mixin calls
Browse files Browse the repository at this point in the history
  • Loading branch information
racodond committed Sep 14, 2017
1 parent 05350ed commit 2eb0d6b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.sonar.css.checks.Tags;
import org.sonar.plugins.css.api.tree.css.ClassSelectorTree;
import org.sonar.plugins.css.api.tree.css.IdentifierTree;
import org.sonar.plugins.css.api.tree.less.LessMixinCallTree;
import org.sonar.plugins.css.api.visitors.DoubleDispatchVisitorCheck;
import org.sonar.squidbridge.annotations.ActivatedByDefault;
import org.sonar.squidbridge.annotations.SqaleConstantRemediation;
Expand Down Expand Up @@ -56,7 +57,9 @@ public class ClassSelectorNamingConventionCheck extends DoubleDispatchVisitorChe

@Override
public void visitClassSelector(ClassSelectorTree tree) {
if (!tree.className().isInterpolated() && !tree.className().text().matches(format)) {
if (!tree.className().isInterpolated()
&& !tree.className().text().matches(format)
&& !tree.parent().hasAncestor(LessMixinCallTree.class)) {
addIssue(tree.className());
}
super.visitClassSelector(tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@

.abc@{DEF}ghi { /* Compliant */
}

.abc {
.Mymixin;
.Mymixin();
.Mymxin
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public StyleSheetTreeTest() {
public void stylesheet() throws Exception {
StyleSheetTree tree;

tree = checkParsed(".abc { .space; }");
assertThat(tree.atRules()).isEmpty();

checkParsed("");
checkParsed(" ");
checkParsed(" ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@

.abc@{DEF}ghi { /* Compliant */
}

.abc {
.Mymixin;
.Mymixin();
.Mymxin
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
59,
65,
71,
87,
87,g
101,
106,
111,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
7,
13,
13,
20,
21,
22,
],
'project:custom/common/id-selector-naming-convention/selectorNamingConvention.less':[
7,
Expand Down

0 comments on commit 2eb0d6b

Please sign in to comment.