From 4bee2600193bdbe37208bf78f835b99f0f068f72 Mon Sep 17 00:00:00 2001 From: David RACODON Date: Mon, 30 Apr 2018 12:54:17 +0200 Subject: [PATCH] Fix #105 Support CSS Fonts Module Level 4 - font-variant-emoji --- .../ValidatePropertyValueCheckTest.java | 6 ++-- .../properties/css/font-variant-emoji.css | 10 ++++++ .../properties/less/font-variant-emoji.less | 10 ++++++ .../properties/scss/font-variant-emoji.scss | 10 ++++++ .../property/StandardPropertyFactory.java | 1 + .../property/standard/FontVariantEmoji.java | 33 +++++++++++++++++++ .../property/StandardPropertyFactoryTest.java | 4 +-- .../properties/css/font-variant-emoji.css | 10 ++++++ .../properties/less/font-variant-emoji.less | 10 ++++++ .../properties/scss/font-variant-emoji.scss | 10 ++++++ .../css-experimental-property-usage.json | 10 ++++++ .../src/test/expected/css-line-length.json | 3 ++ .../expected/css-validate-property-value.json | 6 ++++ .../less-experimental-property-usage.json | 10 ++++++ .../src/test/expected/less-line-length.json | 3 ++ .../less-prefer-single-line-comments.json | 6 ++++ .../less-validate-property-value.json | 6 ++++ .../scss-experimental-property-usage.json | 10 ++++++ .../src/test/expected/scss-line-length.json | 3 ++ .../scss-prefer-single-line-comments.json | 6 ++++ .../scss-validate-property-value.json | 6 ++++ 21 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 css-checks/src/test/resources/checks/common/properties/css/font-variant-emoji.css create mode 100644 css-checks/src/test/resources/checks/common/properties/less/font-variant-emoji.less create mode 100644 css-checks/src/test/resources/checks/common/properties/scss/font-variant-emoji.scss create mode 100644 css-frontend/src/main/java/org/sonar/css/model/property/standard/FontVariantEmoji.java create mode 100644 its/ruling/projects/custom/common/properties/css/font-variant-emoji.css create mode 100644 its/ruling/projects/custom/common/properties/less/font-variant-emoji.less create mode 100644 its/ruling/projects/custom/common/properties/scss/font-variant-emoji.scss diff --git a/css-checks/src/test/java/org/sonar/css/checks/common/ValidatePropertyValueCheckTest.java b/css-checks/src/test/java/org/sonar/css/checks/common/ValidatePropertyValueCheckTest.java index 2fbe6c0e..05f601c2 100644 --- a/css-checks/src/test/java/org/sonar/css/checks/common/ValidatePropertyValueCheckTest.java +++ b/css-checks/src/test/java/org/sonar/css/checks/common/ValidatePropertyValueCheckTest.java @@ -75,9 +75,9 @@ public void test_ignore_scss_nested_properties() { @Test public void test_number_of_validated_properties() { - assertEquals(316, CheckTestUtils.getCommonTestFile("properties/css").listFiles().length); - assertEquals(316, CheckTestUtils.getCommonTestFile("properties/less").listFiles().length); - assertEquals(316, CheckTestUtils.getCommonTestFile("properties/scss").listFiles().length); + assertEquals(317, CheckTestUtils.getCommonTestFile("properties/css").listFiles().length); + assertEquals(317, CheckTestUtils.getCommonTestFile("properties/less").listFiles().length); + assertEquals(317, CheckTestUtils.getCommonTestFile("properties/scss").listFiles().length); } } diff --git a/css-checks/src/test/resources/checks/common/properties/css/font-variant-emoji.css b/css-checks/src/test/resources/checks/common/properties/css/font-variant-emoji.css new file mode 100644 index 00000000..41743145 --- /dev/null +++ b/css-checks/src/test/resources/checks/common/properties/css/font-variant-emoji.css @@ -0,0 +1,10 @@ +.mybox { + font-variant-emoji: inherit; + font-variant-emoji: auto; + font-variant-emoji: text; + font-variant-emoji: emoji; + font-variant-emoji: 0; /* Noncompliant {Update the invalid value of property "font-variant-emoji". Expected format: auto | none}! */ + font-variant-emoji: 10px; /* Noncompliant */ + font-variant-emoji: normal; /* Noncompliant */ + font-variant-emoji: auto none; /* Noncompliant */ +} diff --git a/css-checks/src/test/resources/checks/common/properties/less/font-variant-emoji.less b/css-checks/src/test/resources/checks/common/properties/less/font-variant-emoji.less new file mode 100644 index 00000000..41743145 --- /dev/null +++ b/css-checks/src/test/resources/checks/common/properties/less/font-variant-emoji.less @@ -0,0 +1,10 @@ +.mybox { + font-variant-emoji: inherit; + font-variant-emoji: auto; + font-variant-emoji: text; + font-variant-emoji: emoji; + font-variant-emoji: 0; /* Noncompliant {Update the invalid value of property "font-variant-emoji". Expected format: auto | none}! */ + font-variant-emoji: 10px; /* Noncompliant */ + font-variant-emoji: normal; /* Noncompliant */ + font-variant-emoji: auto none; /* Noncompliant */ +} diff --git a/css-checks/src/test/resources/checks/common/properties/scss/font-variant-emoji.scss b/css-checks/src/test/resources/checks/common/properties/scss/font-variant-emoji.scss new file mode 100644 index 00000000..41743145 --- /dev/null +++ b/css-checks/src/test/resources/checks/common/properties/scss/font-variant-emoji.scss @@ -0,0 +1,10 @@ +.mybox { + font-variant-emoji: inherit; + font-variant-emoji: auto; + font-variant-emoji: text; + font-variant-emoji: emoji; + font-variant-emoji: 0; /* Noncompliant {Update the invalid value of property "font-variant-emoji". Expected format: auto | none}! */ + font-variant-emoji: 10px; /* Noncompliant */ + font-variant-emoji: normal; /* Noncompliant */ + font-variant-emoji: auto none; /* Noncompliant */ +} diff --git a/css-frontend/src/main/java/org/sonar/css/model/property/StandardPropertyFactory.java b/css-frontend/src/main/java/org/sonar/css/model/property/StandardPropertyFactory.java index e9dcfe7f..73e5f0dd 100644 --- a/css-frontend/src/main/java/org/sonar/css/model/property/StandardPropertyFactory.java +++ b/css-frontend/src/main/java/org/sonar/css/model/property/StandardPropertyFactory.java @@ -248,6 +248,7 @@ public class StandardPropertyFactory { FontVariantAlternates.class, FontVariantCaps.class, FontVariantEastAsian.class, + FontVariantEmoji.class, FontVariantLigatures.class, FontVariantNumeric.class, FontVariantPosition.class, diff --git a/css-frontend/src/main/java/org/sonar/css/model/property/standard/FontVariantEmoji.java b/css-frontend/src/main/java/org/sonar/css/model/property/standard/FontVariantEmoji.java new file mode 100644 index 00000000..81e1276e --- /dev/null +++ b/css-frontend/src/main/java/org/sonar/css/model/property/standard/FontVariantEmoji.java @@ -0,0 +1,33 @@ +/* + * 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.property.standard; + +import org.sonar.css.model.property.StandardProperty; +import org.sonar.css.model.property.validator.valueelement.IdentifierValidator; + +public class FontVariantEmoji extends StandardProperty { + + public FontVariantEmoji() { + setExperimental(true); + addLinks("https://drafts.csswg.org/css-fonts-4/#propdef-font-variant-emoji"); + addValidators(new IdentifierValidator("auto", "text", "emoji")); + } + +} diff --git a/css-frontend/src/test/java/org/sonar/css/model/property/StandardPropertyFactoryTest.java b/css-frontend/src/test/java/org/sonar/css/model/property/StandardPropertyFactoryTest.java index a2c9697e..7380f0bd 100644 --- a/css-frontend/src/test/java/org/sonar/css/model/property/StandardPropertyFactoryTest.java +++ b/css-frontend/src/test/java/org/sonar/css/model/property/StandardPropertyFactoryTest.java @@ -92,13 +92,13 @@ public void should_return_an_unknown_property_object() { @Test public void number_of_standard_properties() { - assertEquals(624, StandardPropertyFactory.getAll().size()); + assertEquals(625, StandardPropertyFactory.getAll().size()); } @Test public void number_of_experimental_properties() { assertEquals( - 338, + 339, StandardPropertyFactory .getAll() .stream() diff --git a/its/ruling/projects/custom/common/properties/css/font-variant-emoji.css b/its/ruling/projects/custom/common/properties/css/font-variant-emoji.css new file mode 100644 index 00000000..41743145 --- /dev/null +++ b/its/ruling/projects/custom/common/properties/css/font-variant-emoji.css @@ -0,0 +1,10 @@ +.mybox { + font-variant-emoji: inherit; + font-variant-emoji: auto; + font-variant-emoji: text; + font-variant-emoji: emoji; + font-variant-emoji: 0; /* Noncompliant {Update the invalid value of property "font-variant-emoji". Expected format: auto | none}! */ + font-variant-emoji: 10px; /* Noncompliant */ + font-variant-emoji: normal; /* Noncompliant */ + font-variant-emoji: auto none; /* Noncompliant */ +} diff --git a/its/ruling/projects/custom/common/properties/less/font-variant-emoji.less b/its/ruling/projects/custom/common/properties/less/font-variant-emoji.less new file mode 100644 index 00000000..41743145 --- /dev/null +++ b/its/ruling/projects/custom/common/properties/less/font-variant-emoji.less @@ -0,0 +1,10 @@ +.mybox { + font-variant-emoji: inherit; + font-variant-emoji: auto; + font-variant-emoji: text; + font-variant-emoji: emoji; + font-variant-emoji: 0; /* Noncompliant {Update the invalid value of property "font-variant-emoji". Expected format: auto | none}! */ + font-variant-emoji: 10px; /* Noncompliant */ + font-variant-emoji: normal; /* Noncompliant */ + font-variant-emoji: auto none; /* Noncompliant */ +} diff --git a/its/ruling/projects/custom/common/properties/scss/font-variant-emoji.scss b/its/ruling/projects/custom/common/properties/scss/font-variant-emoji.scss new file mode 100644 index 00000000..41743145 --- /dev/null +++ b/its/ruling/projects/custom/common/properties/scss/font-variant-emoji.scss @@ -0,0 +1,10 @@ +.mybox { + font-variant-emoji: inherit; + font-variant-emoji: auto; + font-variant-emoji: text; + font-variant-emoji: emoji; + font-variant-emoji: 0; /* Noncompliant {Update the invalid value of property "font-variant-emoji". Expected format: auto | none}! */ + font-variant-emoji: 10px; /* Noncompliant */ + font-variant-emoji: normal; /* Noncompliant */ + font-variant-emoji: auto none; /* Noncompliant */ +} diff --git a/its/ruling/tests/src/test/expected/css-experimental-property-usage.json b/its/ruling/tests/src/test/expected/css-experimental-property-usage.json index 510bbc50..23f1e279 100644 --- a/its/ruling/tests/src/test/expected/css-experimental-property-usage.json +++ b/its/ruling/tests/src/test/expected/css-experimental-property-usage.json @@ -701,6 +701,16 @@ 11, 12, ], +'project:custom/common/properties/css/font-variant-emoji.css':[ +2, +3, +4, +5, +6, +7, +8, +9, +], 'project:custom/common/properties/css/font-variant-position.css':[ 2, 3, diff --git a/its/ruling/tests/src/test/expected/css-line-length.json b/its/ruling/tests/src/test/expected/css-line-length.json index bdf879f9..605b585a 100644 --- a/its/ruling/tests/src/test/expected/css-line-length.json +++ b/its/ruling/tests/src/test/expected/css-line-length.json @@ -589,6 +589,9 @@ 'project:custom/common/properties/css/font-variant-caps.css':[ 10, ], +'project:custom/common/properties/css/font-variant-emoji.css':[ +6, +], 'project:custom/common/properties/css/font-variant-position.css':[ 6, ], diff --git a/its/ruling/tests/src/test/expected/css-validate-property-value.json b/its/ruling/tests/src/test/expected/css-validate-property-value.json index d6225dce..b4a9e1a5 100644 --- a/its/ruling/tests/src/test/expected/css-validate-property-value.json +++ b/its/ruling/tests/src/test/expected/css-validate-property-value.json @@ -754,6 +754,12 @@ 11, 12, ], +'project:custom/common/properties/css/font-variant-emoji.css':[ +6, +7, +8, +9, +], 'project:custom/common/properties/css/font-variant-position.css':[ 6, 7, diff --git a/its/ruling/tests/src/test/expected/less-experimental-property-usage.json b/its/ruling/tests/src/test/expected/less-experimental-property-usage.json index 451b7c1a..b412800f 100644 --- a/its/ruling/tests/src/test/expected/less-experimental-property-usage.json +++ b/its/ruling/tests/src/test/expected/less-experimental-property-usage.json @@ -686,6 +686,16 @@ 11, 12, ], +'project:custom/common/properties/less/font-variant-emoji.less':[ +2, +3, +4, +5, +6, +7, +8, +9, +], 'project:custom/common/properties/less/font-variant-position.less':[ 2, 3, diff --git a/its/ruling/tests/src/test/expected/less-line-length.json b/its/ruling/tests/src/test/expected/less-line-length.json index b100545b..607c8f1d 100644 --- a/its/ruling/tests/src/test/expected/less-line-length.json +++ b/its/ruling/tests/src/test/expected/less-line-length.json @@ -483,6 +483,9 @@ 'project:custom/common/properties/less/font-variant-caps.less':[ 10, ], +'project:custom/common/properties/less/font-variant-emoji.less':[ +6, +], 'project:custom/common/properties/less/font-variant-position.less':[ 6, ], diff --git a/its/ruling/tests/src/test/expected/less-prefer-single-line-comments.json b/its/ruling/tests/src/test/expected/less-prefer-single-line-comments.json index a188cb7a..e3e2c8ed 100644 --- a/its/ruling/tests/src/test/expected/less-prefer-single-line-comments.json +++ b/its/ruling/tests/src/test/expected/less-prefer-single-line-comments.json @@ -1002,6 +1002,12 @@ 11, 12, ], +'project:custom/common/properties/less/font-variant-emoji.less':[ +6, +7, +8, +9, +], 'project:custom/common/properties/less/font-variant-position.less':[ 6, 7, diff --git a/its/ruling/tests/src/test/expected/less-validate-property-value.json b/its/ruling/tests/src/test/expected/less-validate-property-value.json index ee7ed121..7bbf015f 100644 --- a/its/ruling/tests/src/test/expected/less-validate-property-value.json +++ b/its/ruling/tests/src/test/expected/less-validate-property-value.json @@ -737,6 +737,12 @@ 11, 12, ], +'project:custom/common/properties/less/font-variant-emoji.less':[ +6, +7, +8, +9, +], 'project:custom/common/properties/less/font-variant-position.less':[ 6, 7, diff --git a/its/ruling/tests/src/test/expected/scss-experimental-property-usage.json b/its/ruling/tests/src/test/expected/scss-experimental-property-usage.json index 4c3cdd6e..30993b4c 100644 --- a/its/ruling/tests/src/test/expected/scss-experimental-property-usage.json +++ b/its/ruling/tests/src/test/expected/scss-experimental-property-usage.json @@ -683,6 +683,16 @@ 11, 12, ], +'project:custom/common/properties/scss/font-variant-emoji.scss':[ +2, +3, +4, +5, +6, +7, +8, +9, +], 'project:custom/common/properties/scss/font-variant-position.scss':[ 2, 3, diff --git a/its/ruling/tests/src/test/expected/scss-line-length.json b/its/ruling/tests/src/test/expected/scss-line-length.json index 08cafa95..8ce08dc9 100644 --- a/its/ruling/tests/src/test/expected/scss-line-length.json +++ b/its/ruling/tests/src/test/expected/scss-line-length.json @@ -507,6 +507,9 @@ 'project:custom/common/properties/scss/font-variant-caps.scss':[ 10, ], +'project:custom/common/properties/scss/font-variant-emoji.scss':[ +6, +], 'project:custom/common/properties/scss/font-variant-position.scss':[ 6, ], diff --git a/its/ruling/tests/src/test/expected/scss-prefer-single-line-comments.json b/its/ruling/tests/src/test/expected/scss-prefer-single-line-comments.json index a8db491d..1ff16f87 100644 --- a/its/ruling/tests/src/test/expected/scss-prefer-single-line-comments.json +++ b/its/ruling/tests/src/test/expected/scss-prefer-single-line-comments.json @@ -1031,6 +1031,12 @@ 11, 12, ], +'project:custom/common/properties/scss/font-variant-emoji.scss':[ +6, +7, +8, +9, +], 'project:custom/common/properties/scss/font-variant-position.scss':[ 6, 7, diff --git a/its/ruling/tests/src/test/expected/scss-validate-property-value.json b/its/ruling/tests/src/test/expected/scss-validate-property-value.json index 9ebdcd1e..7cce6ee5 100644 --- a/its/ruling/tests/src/test/expected/scss-validate-property-value.json +++ b/its/ruling/tests/src/test/expected/scss-validate-property-value.json @@ -708,6 +708,12 @@ 11, 12, ], +'project:custom/common/properties/scss/font-variant-emoji.scss':[ +6, +7, +8, +9, +], 'project:custom/common/properties/scss/font-variant-position.scss':[ 6, 7,