Skip to content

Commit

Permalink
Update parent pom and pre-release cleanup (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-zurn-sonarsource committed Dec 5, 2022
1 parent e55f9a5 commit 210e8ff
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 44 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.sonarsource.parent</groupId>
<artifactId>parent</artifactId>
<version>60.0.52</version>
<version>64.0.211</version>
</parent>

<groupId>org.sonarsource.html</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.sonar.plugins.html;

import java.util.Arrays;
import java.util.List;
import org.sonar.api.Plugin;
import org.sonar.api.config.PropertyDefinition;
Expand Down Expand Up @@ -62,8 +61,7 @@ public void define(Context context) {
}

private static List<PropertyDefinition> pluginProperties() {
return Arrays.asList(

return List.of(
PropertyDefinition.builder(HtmlConstants.FILE_EXTENSIONS_PROP_KEY)
.name("HTML File suffixes")
.description("List of file suffixes that will be scanned.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
*/
package org.sonar.plugins.html.checks.comments;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import org.sonar.check.Rule;
import org.sonar.plugins.html.checks.AbstractPageCheck;
Expand All @@ -35,14 +34,14 @@ public class AvoidCommentedOutCodeCheck extends AbstractPageCheck {
private static final Pattern COPYRIGHT_CASE_INSENSITIVE = Pattern.compile("copyright", Pattern.CASE_INSENSITIVE);
private static final double THRESHOLD = 0.9;

private static final LanguageFootprint LANGUAGE_FOOTPRINT = () -> new HashSet<>(Arrays.asList(
private static final LanguageFootprint LANGUAGE_FOOTPRINT = () -> Set.of(
new ContainsDetector(0.7, "=\"", "='"),
new ContainsDetector(0.8, "/>", "</", "<%", "%>"),
new EndWithDetector(0.9, '>')));
new EndWithDetector(0.9, '>'));

private static final CodeRecognizer CODE_RECOGNIZER = new CodeRecognizer(THRESHOLD, LANGUAGE_FOOTPRINT);

private static final List<String> IGNORED_COMMENT_ANNOTATIONS = Arrays.asList("@thymesVar", "@elvariable");
private static final List<String> IGNORED_COMMENT_ANNOTATIONS = List.of("@thymesVar", "@elvariable");

@Override
public void comment(CommentNode node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
*/
package org.sonar.plugins.html.checks.sonar;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -111,7 +109,7 @@ public class DeprecatedAttributesInHtml5Check extends AbstractPageCheck {
}

private static void put(String key, String... values) {
DEPRECATED.put(key, new HashSet<>(Arrays.asList(values)));
DEPRECATED.put(key, Set.of(values));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.sonar.plugins.html.checks.sonar;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
Expand All @@ -32,7 +31,7 @@
@Rule(key = "S5255")
public class IndistinguishableSimilarElementsCheck extends AbstractPageCheck {

private static final List<String> LANDMARK_ROLES = Arrays.asList(
private static final List<String> LANDMARK_ROLES = List.of(
"BANNER", "COMPLEMENTARY", "CONTENTINFO", "FORM", "MAIN", "NAVIGATION", "SEARCH", "APPLICATION"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@Rule(key = "InputWithoutLabelCheck")
public class InputWithoutLabelCheck extends AbstractPageCheck {

private static final Set<String> EXCLUDED_TYPES = new HashSet<>(Arrays.asList("SUBMIT", "BUTTON", "IMAGE", "HIDDEN"));
private static final Set<String> EXCLUDED_TYPES = Set.of("SUBMIT", "BUTTON", "IMAGE", "HIDDEN");

private final Set<String> labelFor = new HashSet<>();
private final Map<String, TagNode> inputIdToNode = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package org.sonar.plugins.html.checks.sonar;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import org.sonar.check.Rule;
Expand All @@ -28,7 +26,7 @@
@Rule(key = "LinkToImageCheck")
public class LinkToImageCheck extends AbstractPageCheck {

private static final Set<String> IMG_SUFFIXES = new HashSet<>(Arrays.asList(".GIF", ".JPG", ".JPEG", ".PNG", ".BMP"));
private static final Set<String> IMG_SUFFIXES = Set.of(".GIF", ".JPG", ".JPEG", ".PNG", ".BMP");

@Override
public void startElement(TagNode node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package org.sonar.plugins.html.checks.sonar;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import org.sonar.check.Rule;
Expand All @@ -29,7 +27,7 @@
@Rule(key = "UnsupportedTagsInHtml5Check")
public class UnsupportedTagsInHtml5Check extends AbstractPageCheck {

private static final Set<String> UNSUPPORTED_TAGS = new HashSet<>(Arrays.asList(
private static final Set<String> UNSUPPORTED_TAGS = Set.of(
"ACRONYM",
"APPLET",
"BASEFONT",
Expand All @@ -54,7 +52,7 @@ public class UnsupportedTagsInHtml5Check extends AbstractPageCheck {
"SPACER",
"STRIKE",
"TT",
"XMP"));
"XMP");

@Override
public void startElement(TagNode node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package org.sonar.plugins.html.checks.sonar;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.sonar.check.Rule;
import org.sonar.plugins.html.checks.AbstractPageCheck;
Expand All @@ -27,11 +25,11 @@
@Rule(key = "S4084")
public class VideoTrackCheck extends AbstractPageCheck {

private static final Set<String> ACCESSIBILITY_TRACK_KINDS = new HashSet<>(Arrays.asList(
private static final Set<String> ACCESSIBILITY_TRACK_KINDS = Set.of(
"captions",
"descriptions",
"subtitles"
));
);

@Override
public void startElement(TagNode node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
package org.sonar.plugins.html.lex;

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.sonar.plugins.html.node.Attribute;
Expand Down Expand Up @@ -198,14 +196,14 @@ public boolean match(int character) {
}

private static final class EndUnquotedAttributeMatcher implements EndMatcher {
private static final Set<Character> FORBIDDEN = new HashSet<>(Arrays.asList(
private static final Set<Character> FORBIDDEN = Set.of(
'"',
'\'',
'=',
'<',
'>',
'`'
));
);

@Override
public boolean match(int character) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.sonar.plugins.html.rules;

import java.util.Arrays;
import java.util.List;
import org.sonar.plugins.html.checks.attributes.IllegalAttributeCheck;
import org.sonar.plugins.html.checks.attributes.RequiredAttributeCheck;
Expand Down Expand Up @@ -87,7 +86,7 @@

public final class CheckClasses {

private static final List<Class<?>> CLASSES = Arrays.asList(
private static final List<Class<?>> CLASSES = List.of(
AbsoluteURICheck.class,
AvoidHtmlCommentCheck.class,
ChildElementRequiredCheck.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.plugins.html.analyzers.ComplexityVisitor;
Expand Down Expand Up @@ -55,7 +55,7 @@ public static HtmlSourceCode scan(File file, DefaultNodeVisitor visitor) {
.build()
);

HtmlAstScanner walker = new HtmlAstScanner(Arrays.asList(new PageCountLines(), new ComplexityVisitor()));
HtmlAstScanner walker = new HtmlAstScanner(List.of(new PageCountLines(), new ComplexityVisitor()));
PageLexer lexer = file.getName().endsWith(".vue") ? new VueLexer() : new PageLexer();
walker.addVisitor(visitor);
walker.scan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void custom() {

checkMessagesVerifier.verify(sourceCode.getIssues())
.next().atLine(2).withMessage("Fix this expression: Unknown function \"myMethod1\".")
.next().atLine(5).withMessage("Fix this expression: Error Parsing: ${}")
.next().atLine(9).withMessage("Fix this expression: Error Parsing: ${{'one':1,}");
.next().atLine(6).withMessage("Fix this expression: Error Parsing: ${}")
.next().atLine(10).withMessage("Fix this expression: Error Parsing: ${{'one':1,}");
}

@Test
Expand All @@ -58,8 +58,8 @@ public void should_not_detect_unknown_functions_with_empty_list() {
HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/UnifiedExpressionCheck.jsp"), check);

checkMessagesVerifier.verify(sourceCode.getIssues())
.next().atLine(5)
.next().atLine(9);
.next().atLine(6)
.next().atLine(10);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,24 @@ public void is_valid_surrogate_pair_name_start_char() {
* Helper test method: returns true if all invocations to {@link NormalElementTokenizer#isValidSingleCharCodeNameStartChar} returns true for the given character range.
*/
private static boolean isValidRangeForFirstCharacter(char startInclusive, char endInclusive) {
boolean allValid = true;
for (int i = startInclusive; i <= endInclusive; i++) {
allValid = allValid && isValidSingleCharCodeNameStartChar((char) i);
if (!isValidSingleCharCodeNameStartChar((char) i)) {
return false;
}
}
return allValid;
return true;
}

/**
* Helper test method: returns true if all invocations to {@link NormalElementTokenizer#isValidSingleCharCodeNameStartChar} returns false for the given character range.
*/
private static boolean isInvalidRangeForFirstCharacter(char startInclusive, char endInclusive) {
boolean allInvalid = true;
for (int i = startInclusive; i <= endInclusive; i++) {
allInvalid = allInvalid && !isValidSingleCharCodeNameStartChar((char) i);
if (isValidSingleCharCodeNameStartChar((char) i)) {
return false;
}
}
return allInvalid;
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void property() {
assertThat(node.getAttribute("attr.name4")).isEqualTo("value4");
assertThat(node.getPropertyValue("attr.name4")).isEqualTo("value4");
assertThat(node.hasProperty("attr.name4")).isTrue();
assertThat(node.hasProperty("name4")).isTrue();

assertThat(node.getAttribute("name3")).isNull();
assertThat(node.getPropertyValue("name3")).isEqualTo("value3");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void emptyTextNode() {
TextNode textNode = new TextNode();
assertThat(textNode.isBlank()).isTrue();
assertThat(textNode.getCode()).isEmpty();
assertThat(textNode.toString()).isEmpty();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<a foo="${foo.myMethod1()}" />
<a foo="${foo:myMethod1()}" />
<a foo="${foo:myMethod2()}" />
<a foo="${fn:escapeXml(myString)}" />

<a foo="${}" />

Expand Down

0 comments on commit 210e8ff

Please sign in to comment.