Skip to content

Commit

Permalink
Fix #45 Add ::ng-deep pseudo-selector as obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
racodond committed Jul 21, 2017
1 parent 607af63 commit bc79396
Show file tree
Hide file tree
Showing 22 changed files with 158 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,29 @@
import org.sonar.css.checks.CheckTestUtils;
import org.sonar.css.checks.verifier.CssCheckVerifier;

import java.io.File;

public class ObsoletePseudoCheckTest {

private ObsoletePseudoCheck check = new ObsoletePseudoCheck();

@Test
public void test_css() {
CssCheckVerifier.verifyCssFile(check, getTestFile("obsoletePseudos.css"));
}

@Test
public void test() {
CssCheckVerifier.verifyCssFile(new ObsoletePseudoCheck(), CheckTestUtils.getCommonTestFile("obsoletePseudos.css"));
public void test_less() {
CssCheckVerifier.verifyLessFile(check, getTestFile("obsoletePseudos.less"));
}

@Test
public void test_scss() {
CssCheckVerifier.verifyScssFile(check, getTestFile("obsoletePseudos.scss"));
}

private File getTestFile(String fileName) {
return CheckTestUtils.getCommonTestFile("obsolete-pseudos/" + fileName);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:any(ol, ul, menu, dir) { /* Noncompliant ![sc=2;ec=5;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "any" pseudo.}! */
color: #000000;
}

::ng-deep { /* Noncompliant ![sc=3;ec=10;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "ng-deep" pseudo.}! */
color: #000000;
}

p:empty {
color: #000000;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:any(ol, ul, menu, dir) { /* Noncompliant ![sc=2;ec=5;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "any" pseudo.}! */
color: #000000;
}

::ng-deep { /* Noncompliant ![sc=3;ec=10;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "ng-deep" pseudo.}! */
color: #000000;
}

p:empty {
color: #000000;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:any(ol, ul, menu, dir) { /* Noncompliant ![sc=2;ec=5;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "any" pseudo.}! */
color: #000000;
}

::ng-deep { /* Noncompliant ![sc=3;ec=10;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "ng-deep" pseudo.}! */
color: #000000;
}

p:empty {
color: #000000;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
package org.sonar.css.model.pseudo.pseudoidentifier;

import com.google.common.collect.ImmutableSet;

import java.util.*;

import org.sonar.css.model.pseudo.pseudoidentifier.standard.*;
import org.sonar.css.model.pseudo.pseudoidentifier.standard.Optional;

import java.util.*;

public class StandardPseudoIdentifierFactory {

private static final Set<Class> ALL_PSEUDO_IDENTIFIER_CLASSES = ImmutableSet.of(
Expand Down Expand Up @@ -64,6 +63,7 @@ public class StandardPseudoIdentifierFactory {
Left.class,
Link.class,
Marker.class,
NgDeep.class,
OnlyChild.class,
OnlyOfType.class,
Optional.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* SonarQube CSS / SCSS / Less Analyzer
* Copyright (C) 2013-2017 David RACODON
* mailto: david.racodon@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.css.model.pseudo.pseudoidentifier.standard;

import org.sonar.css.model.pseudo.pseudoidentifier.StandardPseudoIdentifier;

public class NgDeep extends StandardPseudoIdentifier {

public NgDeep() {
setObsolete(true);
addLinks("https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class StandardPseudoComponentFactoryTest {

@Test
public void number_of_standard_pseudo_components() {
assertEquals(75, StandardPseudoComponentFactory.getAll().size());
assertEquals(76, StandardPseudoComponentFactory.getAll().size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void should_return_a_valid_first_line_pseudo_identifier_object_mix_upperc

@Test
public void number_of_standard_pseudo_identifiers() {
assertEquals(58, StandardPseudoIdentifierFactory.getAll().size());
assertEquals(59, StandardPseudoIdentifierFactory.getAll().size());
}

@Test
public void number_of_obsolete_pseudo_functions() {
assertEquals(0, StandardPseudoIdentifierFactory.getAll().stream().filter(StandardPseudoIdentifier::isObsolete).count());
public void number_of_obsolete_pseudo_identifiers() {
assertEquals(1, StandardPseudoIdentifierFactory.getAll().stream().filter(StandardPseudoIdentifier::isObsolete).count());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:any(ol, ul, menu, dir) { /* Noncompliant ![sc=2;ec=5;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "any" pseudo.}! */
color: #000000;
}

::ng-deep { /* Noncompliant ![sc=3;ec=10;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "ng-deep" pseudo.}! */
color: #000000;
}

p:empty {
color: #000000;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:any(ol, ul, menu, dir) { /* Noncompliant ![sc=2;ec=5;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "any" pseudo.}! */
color: #000000;
}

::ng-deep { /* Noncompliant ![sc=3;ec=10;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "ng-deep" pseudo.}! */
color: #000000;
}

p:empty {
color: #000000;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:any(ol, ul, menu, dir) { /* Noncompliant ![sc=2;ec=5;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "any" pseudo.}! */
color: #000000;
}

::ng-deep { /* Noncompliant ![sc=3;ec=10;el=+0]! !{Remove this usage of the obsolete / not on W3C Standards track "ng-deep" pseudo.}! */
color: #000000;
}

p:empty {
color: #000000;
}
7 changes: 0 additions & 7 deletions its/ruling/projects/custom/common/obsoletePseudos.css

This file was deleted.

7 changes: 4 additions & 3 deletions its/ruling/tests/src/test/expected/css-line-length.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,16 @@
12,
13,
],
'project:custom/common/obsolete-pseudos/obsoletePseudos.css':[
1,
5,
],
'project:custom/common/obsoleteProperties.css':[
2,
3,
4,
5,
],
'project:custom/common/obsoletePseudos.css':[
1,
],
'project:custom/common/oneDeclarationPerLine.css':[
19,
],
Expand Down
3 changes: 0 additions & 3 deletions its/ruling/tests/src/test/expected/css-named-color.json
Original file line number Diff line number Diff line change
Expand Up @@ -4475,9 +4475,6 @@
'project:custom/common/obsoleteProperties.css':[
6,
],
'project:custom/common/obsoletePseudos.css':[
6,
],
'project:custom/common/oneDeclarationPerLine.css':[
3,
4,
Expand Down
3 changes: 2 additions & 1 deletion its/ruling/tests/src/test/expected/css-obsolete-pseudos.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
'project:custom/common/obsoletePseudos.css':[
'project:custom/common/obsolete-pseudos/obsoletePseudos.css':[
1,
5,
],
}
4 changes: 4 additions & 0 deletions its/ruling/tests/src/test/expected/less-line-length.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
12,
13,
],
'project:custom/common/obsolete-pseudos/obsoletePseudos.less':[
1,
5,
],
'project:custom/common/properties/less/accelerator.less':[
5,
],
Expand Down
6 changes: 6 additions & 0 deletions its/ruling/tests/src/test/expected/less-obsolete-pseudos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
'project:custom/common/obsolete-pseudos/obsoletePseudos.less':[
1,
5,
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
12,
13,
],
'project:custom/common/obsolete-pseudos/obsoletePseudos.less':[
1,
5,
],
'project:custom/common/properties/less/accelerator.less':[
5,
6,
Expand Down
4 changes: 4 additions & 0 deletions its/ruling/tests/src/test/expected/scss-line-length.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
12,
13,
],
'project:custom/common/obsolete-pseudos/obsoletePseudos.scss':[
1,
5,
],
'project:custom/common/properties/scss/accelerator.scss':[
5,
],
Expand Down
6 changes: 6 additions & 0 deletions its/ruling/tests/src/test/expected/scss-obsolete-pseudos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
'project:custom/common/obsolete-pseudos/obsoletePseudos.scss':[
1,
5,
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@
12,
13,
],
'project:custom/common/obsolete-pseudos/obsoletePseudos.scss':[
1,
5,
],
'project:custom/common/properties/scss/accelerator.scss':[
5,
6,
Expand Down

0 comments on commit bc79396

Please sign in to comment.