From 62d13831b70712ce5969e2ed6bfdc21830edc8e8 Mon Sep 17 00:00:00 2001 From: Wouter Born Date: Tue, 9 Jan 2024 21:52:03 +0100 Subject: [PATCH] Cleanup code This cleanup includes: * Fix deprecations * Fix format argument mismatches * Fix JavaDocs * Fix typos * Remove redundant boxing * Remove redundant imports * Remove redundant modifiers * Remove redundant toString calls * Remove redundant variable initialization * Use diamond operator * Use enhanced for loops * Use secure URLs with XML * Use try-with-resources with Files.list * Replace Collectors.joining with String.join * Replace lambdas with method references Signed-off-by: Wouter Born --- .../AuthorContributionDescriptionCheck.java | 5 +- .../ForbiddenPackageUsageCheck.java | 2 +- .../checkstyle/JavadocMethodStyleCheck.java | 7 +-- .../checkstyle/KarafFeatureCheck.java | 4 +- .../checkstyle/NullAnnotationsCheck.java | 2 +- .../checkstyle/OhInfXmlLabelCheck.java | 12 ++--- .../checkstyle/OhInfXmlUsageCheck.java | 6 +-- .../checkstyle/OhInfXmlValidationCheck.java | 4 +- .../checkstyle/OnlyTabIndentationCheck.java | 4 +- ...OverridingParentPomConfigurationCheck.java | 2 +- .../ParameterizedRegexpHeaderCheck.java | 3 +- .../analysis/checkstyle/PomXmlCheck.java | 4 +- .../checkstyle/api/AbstractStaticCheck.java | 10 ++-- .../checkstyle/readme/MarkdownCheck.java | 13 ++--- .../checkstyle/readme/MarkdownVisitor.java | 14 +++--- .../readme/MarkdownVisitorCallback.java | 2 +- .../analysis/utils/CachingHttpClient.java | 12 ++--- ...back.java => ContentReceivedCallback.java} | 4 +- ...uthorContributionDescriptionCheckTest.java | 6 +-- .../checkstyle/test/AuthorTagCheckTest.java | 2 +- .../test/JavadocMethodStyleCheckTest.java | 12 ++--- .../test/LoggedMessagesExtension.java | 4 +- .../checkstyle/test/MarkdownCheckTest.java | 14 +++--- .../test/MissingJavadocFilterCheckTest.java | 8 +-- .../test/NoEmptyLineSeparatorCheckTest.java | 4 +- .../test/OhInfXmlLabelCheckTest.java | 7 ++- .../test/OhInfXmlUsageCheckTest.java | 2 +- .../test/OhInfXmlValidationCheckTest.java | 4 +- .../test/OnlyTabIndentationCheckTest.java | 33 ++++++------- .../checkstyle/test/PomXmlCheckTest.java | 2 +- .../test/RequiredFilesCheckTest.java | 2 +- .../analysis/utils/CachingHttpClientTest.java | 49 +++++++++---------- .../README.md | 2 +- .../testListAtBeginingOfFile/README.md | 3 -- .../testListAtBeginningOfFile/README.md | 3 ++ .../README.md | 0 ... => MissingJavadocOuterAndInnerClass.java} | 2 +- ... MultipleEmptyLinesInSwitchWithCases.java} | 0 .../resources/OH-INF/thing/thing-types.xml | 0 .../xml/AvoidMavenPomderivedInClasspath.xml | 2 +- .../AvoidOverridingParentPomConfiguration.xml | 2 +- .../pmd/test/xml/UseSLF4JLoggerRule.xml | 2 +- .../test/resources/pmd/ruleset/classpath.xml | 2 +- .../resources/pmd/ruleset/customrules.xml | 4 +- .../src/test/resources/pmd/ruleset/pom.xml | 2 +- .../tools/analysis/report/ReportMojo.java | 7 +-- .../analysis/tools/CheckstyleChecker.java | 6 +-- .../tools/analysis/tools/SpotBugsChecker.java | 2 +- .../tools/internal/SpotBugsVisitors.java | 2 +- .../main/resources/report/create_html.xslt | 2 +- .../resources/rulesets/pmd/customrules.xml | 2 +- .../src/main/resources/rulesets/pmd/rules.xml | 2 +- sat-plugin/src/test/resources/report/pmd.xml | 6 +-- 53 files changed, 143 insertions(+), 169 deletions(-) rename custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/{ContentReceviedCallback.java => ContentReceivedCallback.java} (90%) rename custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/{testCodeSectionAtBeginingOfFile => testCodeSectionAtBeginningOfFile}/README.md (51%) delete mode 100644 custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListAtBeginingOfFile/README.md create mode 100644 custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListAtBeginningOfFile/README.md rename custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/{testListBeginingSameAsAnotherLineBegining => testListBeginningSameAsAnotherLineBeginning}/README.md (100%) rename custom-checks/checkstyle/src/test/resources/checkstyle/missingJavadocFilterCheckTest/{MissingJavadocOuterAndInnnerClass.java => MissingJavadocOuterAndInnerClass.java} (89%) rename custom-checks/checkstyle/src/test/resources/checkstyle/noEmptyLineSeparatorCheck/{MutlitpleEmptyLinesInSwitchWithCases.java => MultipleEmptyLinesInSwitchWithCases.java} (100%) rename custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlUsageCheckTest/{missingConfigDesciptionRef => missingConfigDescriptionRef}/src/main/resources/OH-INF/thing/thing-types.xml (100%) diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/AuthorContributionDescriptionCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/AuthorContributionDescriptionCheck.java index 9417196d..cbcc750f 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/AuthorContributionDescriptionCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/AuthorContributionDescriptionCheck.java @@ -81,7 +81,7 @@ public void setCheckInnerUnits(boolean checkInnerUnits) { } public void setRequiredContributionDescriptions(String[] contributionDescriptions) { - this.requiredContributionDescriptions = new ArrayList(Arrays.asList(contributionDescriptions)); + this.requiredContributionDescriptions = new ArrayList<>(Arrays.asList(contributionDescriptions)); setWarningMessageFirstAuthorDescription(requiredContributionDescriptions); } @@ -97,8 +97,7 @@ public void setRequiredContributionDescriptions(String[] contributionDescription */ private void setWarningMessageFirstAuthorDescription(List contributionDescriptions) { warningMessageFirstAuthorDescription = contributionDescriptions.stream().map(Object::toString) - .collect(Collectors.joining(WARNING_MESSAGE_DELIMITER, WARNING_MESSAGE_PREFIX, WARNING_MESSAGE_SUFFIX)) - .toString(); + .collect(Collectors.joining(WARNING_MESSAGE_DELIMITER, WARNING_MESSAGE_PREFIX, WARNING_MESSAGE_SUFFIX)); } @Override diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/ForbiddenPackageUsageCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/ForbiddenPackageUsageCheck.java index 8a3d97ab..cb3b299f 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/ForbiddenPackageUsageCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/ForbiddenPackageUsageCheck.java @@ -85,7 +85,7 @@ public void beginTree(DetailAST rootAST) { public void finishTree(DetailAST ast) { importsToLineNumbers.entrySet().stream() .filter(entry -> forbiddenPackages.stream().anyMatch(entry.getKey()::contains)) - .filter(entry -> !exceptions.stream().anyMatch(entry.getKey()::contains)) + .filter(entry -> exceptions.stream().noneMatch(entry.getKey()::contains)) .forEach(entry -> log(entry.getValue(), String.format(MESSAGE, entry.getKey()))); } } diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/JavadocMethodStyleCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/JavadocMethodStyleCheck.java index 219ba987..fd9efefb 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/JavadocMethodStyleCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/JavadocMethodStyleCheck.java @@ -112,9 +112,7 @@ public int[] getDefaultTokens() { @Override public int[] getAcceptableTokens() { - /** - * The check will be executed for method and constructor declarations. - */ + // The check will be executed for method and constructor declarations. return new int[] { TokenTypes.METHOD_DEF, TokenTypes.CTOR_DEF, }; } @@ -139,7 +137,7 @@ private void visit(DetailAST ast) { if (textBlock != null) { String[] text = textBlock.getText(); - lineNumberToLineText = new HashMap(); + lineNumberToLineText = new HashMap<>(); tagLines = new ArrayList<>(); for (int javadocLineIndex = 0; javadocLineIndex < text.length; javadocLineIndex++) { @@ -206,7 +204,6 @@ private void logInformation(String group, String message) { lineNumberToLineText.forEach((lineNumber, lineText) -> { if (lineText.contains(group)) { log(lineNumber, message); - return; } }); } diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/KarafFeatureCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/KarafFeatureCheck.java index b9d33709..388b31ef 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/KarafFeatureCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/KarafFeatureCheck.java @@ -81,9 +81,7 @@ protected void processFiltered(File file, FileText fileText) throws CheckstyleEx boolean isFound = false; - for (int i = 0; i < individualPaths.length; i++) { - String singlePath = individualPaths[i]; - + for (String singlePath : individualPaths) { Path featurePath = resolveRecursively(file.toPath(), Paths.get(singlePath)); if (featurePath == null) { diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/NullAnnotationsCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/NullAnnotationsCheck.java index 2ca2f74c..e6132bc1 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/NullAnnotationsCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/NullAnnotationsCheck.java @@ -40,7 +40,7 @@ */ public class NullAnnotationsCheck extends AbstractCheck { - private List imports = new ArrayList(); + private List imports = new ArrayList<>(); private static final String NONNULL_ANNOTATION = NonNull.class.getSimpleName(); private static final String NULLABLE_ANNOTATION = Nullable.class.getSimpleName(); diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlLabelCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlLabelCheck.java index 7ef95c07..d834d75f 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlLabelCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlLabelCheck.java @@ -107,7 +107,7 @@ public void setMaxLabelLengthError(final String maxLabelLength) { } public void setCheckWordCasing(final String check) { - this.doCheckWordCasing = Boolean.valueOf(check); + this.doCheckWordCasing = Boolean.parseBoolean(check); } @Override @@ -134,7 +134,7 @@ protected void checkThingTypeFile(final FileText xmlFileText) throws CheckstyleE private void evaluateExpressionOnFile(final FileText xmlFileText, final String xPathExpression, final String key) throws CheckstyleException { - final String type = fiterType(xPathExpression); + final String type = filterType(xPathExpression); final Map lineNumberMap = new HashMap<>(); final NodeList nodes = getNodes(xmlFileText, xPathExpression); final File file = xmlFileText.getFile(); @@ -170,8 +170,8 @@ private void checkWordCasing(final FileText xmlFileText, final Map getConfigurableServiceRefs(Path basePath) { if (!Files.exists(osgiInfPath)) { return uriFileMap; } - try { - Files.list(osgiInfPath) - .forEach(xmlPath -> uriFileMap.putAll(getConfigurableServiceRefsFromXml(xmlPath))); + try (Stream pathStream = Files.list(osgiInfPath)) { + pathStream.forEach(xmlPath -> uriFileMap.putAll(getConfigurableServiceRefsFromXml(xmlPath))); } catch (IOException e) { } break; diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlValidationCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlValidationCheck.java index e082421e..e263cb1f 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlValidationCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlValidationCheck.java @@ -31,7 +31,7 @@ import org.openhab.tools.analysis.checkstyle.api.AbstractOhInfXmlCheck; import org.openhab.tools.analysis.utils.CachingHttpClient; -import org.openhab.tools.analysis.utils.ContentReceviedCallback; +import org.openhab.tools.analysis.utils.ContentReceivedCallback; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; @@ -94,7 +94,7 @@ public OhInfXmlValidationCheck() { @Override public void beginProcessing(String charset) { - ContentReceviedCallback callback = new ContentReceviedCallback() { + ContentReceivedCallback callback = new ContentReceivedCallback<>() { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); @Override diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OnlyTabIndentationCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OnlyTabIndentationCheck.java index ddfee9fb..66435114 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OnlyTabIndentationCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OnlyTabIndentationCheck.java @@ -42,10 +42,10 @@ public void setFileTypes(String[] value) { @Override protected void processFiltered(File file, FileText fileText) { - processTabIdentationCheck(fileText); + processTabIndentationCheck(fileText); } - private void processTabIdentationCheck(FileText fileText) { + private void processTabIndentationCheck(FileText fileText) { for (int lineNumber = 0; lineNumber < fileText.size(); lineNumber++) { String line = fileText.get(lineNumber); // if line is empty and does not contain only tabs for indentation diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OverridingParentPomConfigurationCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OverridingParentPomConfigurationCheck.java index e202434c..2ae94e2f 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OverridingParentPomConfigurationCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OverridingParentPomConfigurationCheck.java @@ -57,7 +57,7 @@ protected void processFiltered(File file, FileText fileText) throws CheckstyleEx try { nodes = (NodeList) xpathExpression.evaluate(document, XPathConstants.NODESET); } catch (XPathExpressionException e) { - logger.error("An error has occured while parsing the pom.xml. Check if the file is valid.", e); + logger.error("An error has occurred while parsing the pom.xml. Check if the file is valid.", e); } if (nodes != null) { diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/ParameterizedRegexpHeaderCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/ParameterizedRegexpHeaderCheck.java index b125446f..3b63e445 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/ParameterizedRegexpHeaderCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/ParameterizedRegexpHeaderCheck.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import java.util.stream.Collectors; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; @@ -74,7 +73,7 @@ public void setValues(String[] values) { @Override protected void postProcessHeaderLines() { final List headerLines = getHeaderLines(); - String header = headerLines.stream().collect(Collectors.joining(SEPARATOR)); + String header = String.join(SEPARATOR, headerLines); String formattedHeader = MessageFormat.format(header, values); for (String line : formattedHeader.split(SEPARATOR)) { diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/PomXmlCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/PomXmlCheck.java index 3b00c2c4..8f242543 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/PomXmlCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/PomXmlCheck.java @@ -118,7 +118,7 @@ private void processPomXmlFile(FileText fileText) throws CheckstyleException { // parent folder) if (parentPom.exists()) { Optional maybeDocument = getParsedPom(parentPom); - if (!maybeDocument.isPresent()) { + if (maybeDocument.isEmpty()) { return; } @@ -163,7 +163,7 @@ public void finishProcessing() { private Optional getPomVersion(Document pomXmlDocument, String filePath) throws CheckstyleException { Optional maybeVersionNodeValue = getNodeValue(pomXmlDocument, POM_VERSION_XPATH_EXPRESSION, filePath); - if (!maybeVersionNodeValue.isPresent()) { + if (maybeVersionNodeValue.isEmpty()) { return getNodeValue(pomXmlDocument, POM_PARENT_VERSION_XPATH_EXPRESSION, filePath); } diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/api/AbstractStaticCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/api/AbstractStaticCheck.java index 38fcdc54..40c3ab0c 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/api/AbstractStaticCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/api/AbstractStaticCheck.java @@ -119,7 +119,7 @@ protected Document parseDomDocumentFromFile(FileText fileText) throws Checkstyle Document document = builder.parse(getInputStream(fileText)); return document; } catch (ParserConfigurationException e) { - throw new CheckstyleException("Serious configuration error occured while creating a DocumentBuilder.", e); + throw new CheckstyleException("Serious configuration error occurred while creating a DocumentBuilder.", e); } catch (SAXException e) { throw new CheckstyleException("Unable to read from file: " + fileText.getFile().getAbsolutePath(), e); } catch (IOException e) { @@ -160,17 +160,17 @@ protected org.jsoup.nodes.Document parseHTMLDocumentFromFile(FileText fileText) /** * Compiles an XPathExpression * - * @param expresion the XPath expression + * @param expression the XPath expression * @return compiled XPath expression * @throws CheckstyleException if an error occurred during the compilation */ - protected XPathExpression compileXPathExpression(String expresion) throws CheckstyleException { + protected XPathExpression compileXPathExpression(String expression) throws CheckstyleException { XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); try { - return xpath.compile(expresion); + return xpath.compile(expression); } catch (XPathExpressionException e) { - throw new CheckstyleException("Unable to compile the expression" + expresion, e); + throw new CheckstyleException("Unable to compile the expression" + expression, e); } } diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownCheck.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownCheck.java index ddc71548..0084c0f0 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownCheck.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownCheck.java @@ -45,10 +45,8 @@ public MarkdownCheck() { @Override protected void processFiltered(File file, FileText fileText) throws CheckstyleException { - switch (file.getName()) { - case README_MD_FILE_NAME: - checkReadMe(fileText); - break; + if (file.getName().equals(README_MD_FILE_NAME)) { + checkReadMe(fileText); } } @@ -59,12 +57,7 @@ private void checkReadMe(FileText fileText) { Node readmeMarkdownNode = parseMarkdown(fileText, options); // CallBack is used in order to use the protected log method of the AbstractStaticCheck in the Visitor - MarkdownVisitorCallback callBack = new MarkdownVisitorCallback() { - @Override - public void log(int line, String message) { - MarkdownCheck.this.log(line + 1, message); - } - }; + MarkdownVisitorCallback callBack = (line, message) -> MarkdownCheck.this.log(line + 1, message); MarkdownVisitor visitor = new MarkdownVisitor(callBack, fileText); visitor.visit(readmeMarkdownNode); } diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownVisitor.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownVisitor.java index c9af4887..6a9a8c42 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownVisitor.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownVisitor.java @@ -130,9 +130,9 @@ private void checkEmptyLineBefore(ListBlock listBlock) { // Not checking if the line above is empty if it's another list item return; } else { - boolean isListfirstLineInFile = firstLineOfList == 0; + boolean isListFirstLineInFile = firstLineOfList == 0; // The first line of the file can NOT be list - if (isListfirstLineInFile || !StringUtils.isBlank(fileText.get(firstLineOfList - 1))) { + if (isListFirstLineInFile || !StringUtils.isBlank(fileText.get(firstLineOfList - 1))) { // Log the one-based first line of the list callback.log(firstLineOfList, EMPTY_LINE_BEFORE_LIST_MSG); } @@ -145,10 +145,10 @@ private void checkEmptyLineAfterList(ListBlock listBlock) { boolean isListEnd = lastListItemContent instanceof Paragraph; if (isListEnd) { - String[] lastListItemlines = lastListItemContent.getChars().toString().split(REGEX_NEW_LINES); - if (lastListItemlines.length > 1) { - for (int i = 1; i < lastListItemlines.length; i++) { - if (!lastListItemlines[i].startsWith(" ")) { + String[] lastListItemLines = lastListItemContent.getChars().toString().split(REGEX_NEW_LINES); + if (lastListItemLines.length > 1) { + for (int i = 1; i < lastListItemLines.length; i++) { + if (!lastListItemLines[i].startsWith(" ")) { // Log the one-based line where there is an empty line callback.log(lastListItemContent.getLineNumber(), EMPTY_LINE_AFTER_LIST_MSG); break; @@ -159,7 +159,7 @@ private void checkEmptyLineAfterList(ListBlock listBlock) { } public void visit(ListBlock list) { - list.getChildIterator().forEachRemaining(listItem -> visit(listItem)); + list.getChildIterator().forEachRemaining(this::visit); processListBlock(list); } diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownVisitorCallback.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownVisitorCallback.java index 661ce400..cd3da328 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownVisitorCallback.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/readme/MarkdownVisitorCallback.java @@ -27,5 +27,5 @@ public interface MarkdownVisitorCallback { * @param line line number of the logged message * @param message the message that is logged for the error */ - public void log(int line, String message); + void log(int line, String message); } diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/CachingHttpClient.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/CachingHttpClient.java index 8f6d8f04..cd8d96a3 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/CachingHttpClient.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/CachingHttpClient.java @@ -29,7 +29,7 @@ /** * A simple caching HttpClient * - * A {@link ContentReceviedCallback} is used to convert the downloaded data. + * A {@link ContentReceivedCallback} is used to convert the downloaded data. * The cached entry expires after {@link #RETRY_TIME} * * @author Svilen Valkanov - Initial contribution @@ -43,9 +43,9 @@ public class CachingHttpClient { private static Cache> cache = CacheBuilder.newBuilder() .expireAfterWrite(RETRY_TIME, TimeUnit.MINUTES).build(); - private ContentReceviedCallback callback; + private ContentReceivedCallback callback; - public CachingHttpClient(ContentReceviedCallback callback) { + public CachingHttpClient(ContentReceivedCallback callback) { this.callback = callback; } @@ -64,14 +64,14 @@ public synchronized T get(URL url) throws IOException { throw new IllegalArgumentException("URL must not be null"); } - Optional content = Optional.empty(); + Optional content; try { content = cache.get(url, () -> Optional.of(getContent(url))); } catch (ExecutionException e) { cache.put(url, Optional.empty()); - throw new IOException("Unable to get " + url.toString(), e.getCause()); + throw new IOException("Unable to get " + url, e.getCause()); } - return content.isPresent() ? callback.transform(content.get()) : null; + return content.map(bytes -> callback.transform(bytes)).orElse(null); } private byte[] getContent(URL url) throws IOException { diff --git a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/ContentReceviedCallback.java b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/ContentReceivedCallback.java similarity index 90% rename from custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/ContentReceviedCallback.java rename to custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/ContentReceivedCallback.java index 9d2d2546..74f84969 100644 --- a/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/ContentReceviedCallback.java +++ b/custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/utils/ContentReceivedCallback.java @@ -19,7 +19,7 @@ * * @param - the type of the object */ -public interface ContentReceviedCallback { +public interface ContentReceivedCallback { /** * Called after a successful download attempt is made by the {@link CachingHttpClient} * and should transform the data into a object of type T @@ -27,5 +27,5 @@ public interface ContentReceviedCallback { * @param content HTTP request content, can`t be null * @return the transformed data */ - public T transform(byte[] content); + T transform(byte[] content); } diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/AuthorContributionDescriptionCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/AuthorContributionDescriptionCheckTest.java index 759fef67..c35308f5 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/AuthorContributionDescriptionCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/AuthorContributionDescriptionCheckTest.java @@ -151,9 +151,9 @@ public void testOuterAndInnerClassesWithNoOtherAuthorContributionDescription() t * warning messages are expected at the lines where other authors of outer and inner * classes are located, because other author contribution descriptions are missing there */ - int firstWarningLineOthertAuthor = 3; + int firstWarningLineOtherAuthor = 3; int secondWarningLineOtherAuthor = 10; - lineNumberToWarningMessageExpected.put(firstWarningLineOthertAuthor, + lineNumberToWarningMessageExpected.put(firstWarningLineOtherAuthor, EXPECTED_WARNING_MESSAGE_OTHER_AUTHOR_DESCRIPTION); lineNumberToWarningMessageExpected.put(secondWarningLineOtherAuthor, EXPECTED_WARNING_MESSAGE_OTHER_AUTHOR_DESCRIPTION); @@ -280,7 +280,7 @@ public void testOuterAndInnerClassesWithAuthorContributionDescriptions() throws private void checkFileForAuthorContributionDescription(boolean checkInnerUnits, String fileName) throws Exception { String filePath = getPath(fileName); - String[] expected = null; + String[] expected; if (lineNumberToWarningMessageExpected.isEmpty()) { expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/AuthorTagCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/AuthorTagCheckTest.java index e0823ed3..a089d18d 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/AuthorTagCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/AuthorTagCheckTest.java @@ -94,7 +94,7 @@ public void testOuterAndInnerClassesWithPresentAuthorTag() throws Exception { private void checkFileForAuthorTags(boolean checkInnerUnits, String fileName, Integer... warningLine) throws Exception { String filePath = getPath(fileName); - String[] expected = null; + String[] expected; if (warningLine.length > 0) { expected = new String[warningLine.length]; for (int i = 0; i < warningLine.length; i++) { diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/JavadocMethodStyleCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/JavadocMethodStyleCheckTest.java index fa8d5158..a8cb4e09 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/JavadocMethodStyleCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/JavadocMethodStyleCheckTest.java @@ -106,7 +106,7 @@ public void testMethodJavadocWithParameterNameAndDescriptionNewLine() throws Exc } @Test - public void testMethoJavadocdWithAllWrongDescriptions() throws Exception { + public void testMethodJavadocWithAllWrongDescriptions() throws Exception { String fileName = "MethodWithWrongJavadoc.java"; String[] expectedMessages = generateExpectedMessages(6, EXPECTED_MESSAGE_CONTAINS_DASH, 7, EXPECTED_MESSAGE_PARAMETER_DESCRIPTION_NEWLINE, 8, EXPECTED_MESSAGE_EMPTY_LINES_BETWEEN_TAGS, 9, @@ -119,20 +119,14 @@ public void testMethoJavadocdWithAllWrongDescriptions() throws Exception { @Test public void testMethodJavadocWithParameterNameWithNoDescription() throws Exception { String fileName = "MethodWithNoParamNameDescription.java"; - /** - * methods with missing parameter descriptions should not log anything - * so we pass empty array - */ + // methods with missing parameter descriptions should not log anything so we pass empty array checkFile(fileName, CommonUtil.EMPTY_STRING_ARRAY); } @Test public void testMethodJavadocWithProperTagParameterNameAndDescription() throws Exception { String fileName = "MethodWithProperDescriptions.java"; - /** - * methods with proper parameter description should not log anything - * so we pass empty array - */ + // methods with proper parameter description should not log anything so we pass empty array checkFile(fileName, CommonUtil.EMPTY_STRING_ARRAY); } diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/LoggedMessagesExtension.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/LoggedMessagesExtension.java index e430f67d..5af3199b 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/LoggedMessagesExtension.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/LoggedMessagesExtension.java @@ -52,10 +52,10 @@ public void afterEach(ExtensionContext context) throws Exception { } public List getMessages() { - return listAppender.list.stream().map(event -> event.getMessage()).collect(Collectors.toList()); + return listAppender.list.stream().map(ILoggingEvent::getMessage).collect(Collectors.toList()); } public List getFormattedMessages() { - return listAppender.list.stream().map(event -> event.getFormattedMessage()).collect(Collectors.toList()); + return listAppender.list.stream().map(ILoggingEvent::getFormattedMessage).collect(Collectors.toList()); } } diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/MarkdownCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/MarkdownCheckTest.java index f22c73ed..3ea82355 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/MarkdownCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/MarkdownCheckTest.java @@ -50,7 +50,7 @@ public void testHeader() throws Exception { } @Test - public void testForbiddNodeVisit() throws Exception { + public void testForbiddenNodeVisit() throws Exception { verifyMarkDownFile("testForbiddenNodeVisit", noMessagesExpected()); } @@ -134,16 +134,16 @@ public void testCodeFormattedListElement() throws Exception { } @Test - public void testCodeSectionAtBeginingOfFile() throws Exception { + public void testCodeSectionAtBeginningOfFile() throws Exception { String[] expectedMessages = generateExpectedMessages(1, "The line before code formatting section must be empty."); - verifyMarkDownFile("testCodeSectionAtBeginingOfFile", expectedMessages); + verifyMarkDownFile("testCodeSectionAtBeginningOfFile", expectedMessages); } @Test - public void testListAtBeginingOfFile() throws Exception { + public void testListAtBeginningOfFile() throws Exception { String[] expectedMessages = generateExpectedMessages(1, "The line before a Markdown list must be empty."); - verifyMarkDownFile("testListAtBeginingOfFile", expectedMessages); + verifyMarkDownFile("testListAtBeginningOfFile", expectedMessages); } @Test @@ -174,8 +174,8 @@ public void testListFirstLineSameAsParagraph() throws Exception { } @Test - public void testListBeginingSameAsAnotherLineBegining() throws Exception { - verifyMarkDownFile("testListBeginingSameAsAnotherLineBegining", noMessagesExpected()); + public void testListBeginningSameAsAnotherLineBeginning() throws Exception { + verifyMarkDownFile("testListBeginningSameAsAnotherLineBeginning", noMessagesExpected()); } @Test diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/MissingJavadocFilterCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/MissingJavadocFilterCheckTest.java index 9118524f..e0c7924c 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/MissingJavadocFilterCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/MissingJavadocFilterCheckTest.java @@ -21,7 +21,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** - * Tests for {@link JavadocInnerClassesFilterCheck} + * Tests for {@link MissingJavadocFilterCheck} * * @author Petar Valchev - Initial contribution */ @@ -35,13 +35,13 @@ protected String getPackageLocation() { @Test public void testOuterClassWithJavadoc() throws Exception { String[] locations = new String[] { "10:1" }; - verifyJavadoc("MissingJavadocOuterAndInnnerClass.java", false, locations); + verifyJavadoc("MissingJavadocOuterAndInnerClass.java", false, locations); } @Test public void testOuterAndInnerClassesWithJavadoc() throws Exception { String[] locations = new String[] { "10:1", "12:5" }; - verifyJavadoc("MissingJavadocOuterAndInnnerClass.java", true, locations); + verifyJavadoc("MissingJavadocOuterAndInnerClass.java", true, locations); } @Test @@ -61,7 +61,7 @@ private void verifyJavadoc(String testFileName, boolean checkInnerClasses, Strin String filePath = getPath(testFileName); - String[] expectedMessages = null; + String[] expectedMessages; if (locations != null) { expectedMessages = new String[locations.length]; for (int i = 0; i < locations.length; i++) { diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/NoEmptyLineSeparatorCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/NoEmptyLineSeparatorCheckTest.java index 528787ac..e328eaa7 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/NoEmptyLineSeparatorCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/NoEmptyLineSeparatorCheckTest.java @@ -114,7 +114,7 @@ public void verifyEmptyLinesInMethodDefinitions() throws Exception { } @Test - public void verifyValidConstuctorDefinition() throws Exception { + public void verifyValidConstructorDefinition() throws Exception { verifyJavaFileNoErrors("ValidConstructorDefinition.java"); } @@ -232,7 +232,7 @@ public void verifyMultipleEmptyLinesInSwitchWithCases() throws Exception { String[] expectedMessages = generateExpectedMessages(12, MSG_LINE_AFTER_OPENING_BRACE_EMPTY, 29, MSG_LINE_BEFORE_CLOSING_BRACE_EMPTY, 16, MSG_LINE_BEFORE_CLOSING_BRACE_EMPTY, 19, MSG_FOR_EMPTY_LINE, 27, MSG_LINE_BEFORE_CLOSING_BRACE_EMPTY); - verifyJavaFile("MutlitpleEmptyLinesInSwitchWithCases.java", expectedMessages); + verifyJavaFile("MultipleEmptyLinesInSwitchWithCases.java", expectedMessages); } @Test diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlLabelCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlLabelCheckTest.java index 5aaa0e90..be9d5d5a 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlLabelCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlLabelCheckTest.java @@ -17,7 +17,6 @@ import java.io.File; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.Before; @@ -123,9 +122,9 @@ private void verifyWithPath(final String testSubDirectory, final String testFile final String[] expectedMessages) throws Exception { final String directoryPath = getPath(testSubDirectory); final File testDirectoryPath = new File(directoryPath); - final File[] testFiles = listFilesForFolder(testDirectoryPath, new ArrayList()); - verify(createChecker(configuration), testFiles, directoryPath + testFilePath, Stream.of(expectedMessages) - .map(s -> s.replace("''", "'")).collect(Collectors.toList()).toArray(new String[0])); + final File[] testFiles = listFilesForFolder(testDirectoryPath, new ArrayList<>()); + verify(createChecker(configuration), testFiles, directoryPath + testFilePath, + Stream.of(expectedMessages).map(s -> s.replace("''", "'")).toArray(String[]::new)); } private File[] listFilesForFolder(final File folder, final ArrayList files) { diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlUsageCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlUsageCheckTest.java index 0c8429fc..1964968f 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlUsageCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlUsageCheckTest.java @@ -67,7 +67,7 @@ public void testMissingSupportedBridgeRef() throws Exception { public void testMissingConfigRef() throws Exception { String[] expectedMessages = generateExpectedMessages(0, MessageFormat.format(MESSAGE_MISSING_URI_CONFIGURATION, "binding:ge:config")); - verifyWithPath("missingConfigDesciptionRef", RELATIVE_PATH_TO_THING, expectedMessages); + verifyWithPath("missingConfigDescriptionRef", RELATIVE_PATH_TO_THING, expectedMessages); } @Test diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlValidationCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlValidationCheckTest.java index ad042a92..85d315e0 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlValidationCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlValidationCheckTest.java @@ -75,7 +75,7 @@ public void checkConnection() { Locale.setDefault(new Locale("en", "US")); try { URL url = new URL(THING_SCHEMA_URL); - CachingHttpClient cachingClient = new CachingHttpClient<>(c -> new String(c)); + CachingHttpClient cachingClient = new CachingHttpClient<>(String::new); isResourceAvailable = cachingClient.get(url) != null; } catch (IOException e) { isResourceAvailable = false; @@ -199,7 +199,7 @@ private void verifyWithPath(String testSubDirectory, String testFilePath, String String directoryPath = getPath(testSubDirectory); File testDirectoryPath = new File(directoryPath); - File[] testFiles = listFilesForFolder(testDirectoryPath, new ArrayList()); + File[] testFiles = listFilesForFolder(testDirectoryPath, new ArrayList<>()); verify(createChecker(CONFIGURATION), testFiles, directoryPath + testFilePath, expectedMessages); } diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OnlyTabIndentationCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OnlyTabIndentationCheckTest.java index 41988acc..8f3a7d68 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OnlyTabIndentationCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OnlyTabIndentationCheckTest.java @@ -46,42 +46,42 @@ protected String getPackageLocation() { @Test public void testOneLineXmlFile() throws Exception { - verifyXmlTabIdentation("WhiteSpacesNotUsedBeforeOpeningTags.xml", noMessagesExpected()); + verifyXmlTabIndentation("WhiteSpacesNotUsedBeforeOpeningTags.xml", noMessagesExpected()); } @Test public void testValidJson() throws Exception { - verifyTabIdentation("validJson.json", noMessagesExpected(), false); + verifyTabIndentation("validJson.json", noMessagesExpected(), false); } @Test public void testBadlyFormattedJson() throws Exception { String[] expectedMessages = generateExpectedMessages(7, WHITESPACE_USAGE_WARNING); - verifyTabIdentation("badlyFormattedJson.json", expectedMessages, false); + verifyTabIndentation("badlyFormattedJson.json", expectedMessages, false); } @Test public void testOneIncorrectLine() throws Exception { String[] expectedMessages = generateExpectedMessages(5, WHITESPACE_USAGE_WARNING); - verifyXmlTabIdentation("WhiteSpaceUsedBeforeOpeningTagInOneLine.xml", expectedMessages); + verifyXmlTabIndentation("WhiteSpaceUsedBeforeOpeningTagInOneLine.xml", expectedMessages); } @Test public void testManyIncorrectLinesOnlyShowFirstWarning() throws Exception { String[] expectedMessages = generateExpectedMessages(5, WHITESPACE_USAGE_WARNING); - verifyXmlTabIdentation("WhiteSpaceUsedBeforeOpeningTagInManyLines.xml", expectedMessages); + verifyXmlTabIndentation("WhiteSpaceUsedBeforeOpeningTagInManyLines.xml", expectedMessages); } @Test public void testManyIncorrectLinesShowAllWarnings() throws Exception { String[] expectedMessages = generateExpectedMessages(5, WHITESPACE_USAGE_WARNING, 6, WHITESPACE_USAGE_WARNING); - verifyTabIdentation("WhiteSpaceUsedBeforeOpeningTagInManyLines.xml", expectedMessages, false); + verifyTabIndentation("WhiteSpaceUsedBeforeOpeningTagInManyLines.xml", expectedMessages, false); } @Test public void testXmlWithEmptyLinesAndComments() throws Exception { String fileName = "BasicModuleHandlerFactory.xml"; - verifyTabIdentation(fileName, noMessagesExpected(), false); + verifyTabIndentation(fileName, noMessagesExpected(), false); } @Test @@ -92,19 +92,19 @@ public void testXmlWithMultipleLinesWithSpacesEmptyLinesAndComments() throws Exc WHITESPACE_USAGE_WARNING, 11, WHITESPACE_USAGE_WARNING, 13, WHITESPACE_USAGE_WARNING, 17, WHITESPACE_USAGE_WARNING, 18, WHITESPACE_USAGE_WARNING, 19, WHITESPACE_USAGE_WARNING, 20, WHITESPACE_USAGE_WARNING, 21, WHITESPACE_USAGE_WARNING, 22, WHITESPACE_USAGE_WARNING); - verifyTabIdentation(fileName, expectedMessages, false); + verifyTabIndentation(fileName, expectedMessages, false); } @Test public void testXmlWithOnlyTabsForIndentation() throws Exception { String fileName = "addon.xml"; - verifyTabIdentation(fileName, noMessagesExpected(), false); + verifyTabIndentation(fileName, noMessagesExpected(), false); } @Test public void testAnotherXmlWithOnlyTabsForIndentation() throws Exception { String fileName = "thing-types.xml"; - verifyTabIdentation(fileName, noMessagesExpected(), false); + verifyTabIndentation(fileName, noMessagesExpected(), false); } @Test @@ -117,7 +117,7 @@ public void testXmlWithCDATAAndSpacesForIndentation() throws Exception { WHITESPACE_USAGE_WARNING, 33, WHITESPACE_USAGE_WARNING, 39, WHITESPACE_USAGE_WARNING, 40, WHITESPACE_USAGE_WARNING, 41, WHITESPACE_USAGE_WARNING, 42, WHITESPACE_USAGE_WARNING, 59, WHITESPACE_USAGE_WARNING, 60, WHITESPACE_USAGE_WARNING, 61, WHITESPACE_USAGE_WARNING); - verifyTabIdentation(fileName, expectedMessages, false); + verifyTabIndentation(fileName, expectedMessages, false); } @Test @@ -127,15 +127,14 @@ public void testAnotherXmlWithCDATAAndSpacesForIndentation() throws Exception { 12, WHITESPACE_USAGE_WARNING, 13, WHITESPACE_USAGE_WARNING, 15, WHITESPACE_USAGE_WARNING, 16, WHITESPACE_USAGE_WARNING, 17, WHITESPACE_USAGE_WARNING, 18, WHITESPACE_USAGE_WARNING, 19, WHITESPACE_USAGE_WARNING, 20, WHITESPACE_USAGE_WARNING, 22, WHITESPACE_USAGE_WARNING); - verifyTabIdentation(fileName, expectedMessages, false); + verifyTabIndentation(fileName, expectedMessages, false); } private String[] noMessagesExpected() { - String[] expectedMessages = EMPTY_STRING_ARRAY; - return expectedMessages; + return EMPTY_STRING_ARRAY; } - private void verifyTabIdentation(String fileName, String[] expectedMessages, boolean onlyShowFirstWarning) + private void verifyTabIndentation(String fileName, String[] expectedMessages, boolean onlyShowFirstWarning) throws Exception { String testFileAbsolutePath = getPath(fileName); String messageFilePath = testFileAbsolutePath; @@ -147,7 +146,7 @@ private void verifyTabIdentation(String fileName, String[] expectedMessages, boo verify(createChecker(config), testFileAbsolutePath, messageFilePath, expectedMessages); } - private void verifyXmlTabIdentation(String fileName, String[] expectedMessages) throws Exception { - verifyTabIdentation(fileName, expectedMessages, true); + private void verifyXmlTabIndentation(String fileName, String[] expectedMessages) throws Exception { + verifyTabIndentation(fileName, expectedMessages, true); } } diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/PomXmlCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/PomXmlCheckTest.java index 4bcf1ddf..dee2c7af 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/PomXmlCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/PomXmlCheckTest.java @@ -102,7 +102,7 @@ public void testMasterPom() throws Exception { private void verifyPomXmlFile(String testDirectoryName, String[] expectedMessages) throws Exception { File testDirectory = getTestDirectory(testDirectoryName); - File[] testFiles = listFilesForDirectory(testDirectory, new ArrayList()); + File[] testFiles = listFilesForDirectory(testDirectory, new ArrayList<>()); String testFilePath = testDirectory.getPath() + File.separator + POM_XML_FILE_NAME; verify(createChecker(config), testFiles, testFilePath, expectedMessages); diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/RequiredFilesCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/RequiredFilesCheckTest.java index 6874f193..db2ac6af 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/RequiredFilesCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/RequiredFilesCheckTest.java @@ -131,7 +131,7 @@ private void addExpectedViolation(Map> expectedViolations, private File[] getFilesForDirectory(String directoryName) throws IOException { String directoryAbsolutePath = getPath(directoryName); File directory = new File(directoryAbsolutePath); - File[] files = listFilesForDirectory(directory, new ArrayList()); + File[] files = listFilesForDirectory(directory, new ArrayList<>()); return files; } } diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/utils/CachingHttpClientTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/utils/CachingHttpClientTest.java index f35e4c35..12c04edc 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/utils/CachingHttpClientTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/utils/CachingHttpClientTest.java @@ -42,7 +42,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.stubbing.Answer; @@ -63,7 +62,7 @@ public class CachingHttpClientTest { private static Server server; - private ContentReceviedCallback testCallback = s -> new String(s); + private ContentReceivedCallback testCallback = String::new; private CachingHttpClient testClient = new CachingHttpClient<>(testCallback); @BeforeAll @@ -82,8 +81,7 @@ public static void setUp() throws Exception { try { server.start(); } catch (Exception e) { - fail(MessageFormat.format("Unable to start test server on host {} and port {} : {}", TEST_HOST, TEST_PORT, - e)); + fail(MessageFormat.format("Unable to start test server on host {} and port {}", TEST_HOST, TEST_PORT, e)); } } @@ -102,28 +100,25 @@ public void clearInteractionsWithServer() throws Exception { } private void mockHandler(Handler handler) throws IOException, ServletException { - Mockito.doAnswer(new Answer() { - @Override - public Handler answer(InvocationOnMock invocation) throws Throwable { - Object[] arguments = invocation.getArguments(); - - Request baseRequest = (Request) arguments[2]; - HttpServletRequest request = (HttpServletRequest) arguments[2]; - HttpServletResponse response = (HttpServletResponse) arguments[3]; - - baseRequest.setHandled(true); - - assertThat(request.getMethod(), is(HttpMethod.GET.asString())); - - if (request.getPathInfo().startsWith(PATH_TO_RESOURCE)) { - response.setStatus(HttpStatus.OK_200); - response.setContentType("text/html"); - response.getWriter().println(SERVER_RESPONSE); - } else { - response.setStatus(HttpStatus.NOT_FOUND_404); - } - return null; + Mockito.doAnswer((Answer) invocation -> { + Object[] arguments = invocation.getArguments(); + + Request baseRequest = (Request) arguments[2]; + HttpServletRequest request = (HttpServletRequest) arguments[2]; + HttpServletResponse response = (HttpServletResponse) arguments[3]; + + baseRequest.setHandled(true); + + assertThat(request.getMethod(), is(HttpMethod.GET.asString())); + + if (request.getPathInfo().startsWith(PATH_TO_RESOURCE)) { + response.setStatus(HttpStatus.OK_200); + response.setContentType("text/html"); + response.getWriter().println(SERVER_RESPONSE); + } else { + response.setStatus(HttpStatus.NOT_FOUND_404); } + return null; }).when(handler).handle(any(), any(), any(), any()); } @@ -137,7 +132,7 @@ public void testMultipleUnsuccessfulRequests() throws Exception { testClient.get(unreachableURL); } catch (IOException e) { assertThat(e, instanceOf(IOException.class)); - assertThat(e.getMessage(), equalTo("Unable to get " + unreachableURL.toString())); + assertThat(e.getMessage(), equalTo("Unable to get " + unreachableURL)); assertThat(e.getCause(), instanceOf(FileNotFoundException.class)); } // Next requests do not throw exception @@ -182,7 +177,7 @@ public void testFailureAndSuccess() throws Exception { testClient.get(url); } catch (IOException e) { assertThat(e, instanceOf(IOException.class)); - assertThat(e.getMessage(), equalTo("Unable to get " + url.toString())); + assertThat(e.getMessage(), equalTo("Unable to get " + url)); assertThat(e.getCause(), instanceOf(FileNotFoundException.class)); } diff --git a/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testCodeSectionAtBeginingOfFile/README.md b/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testCodeSectionAtBeginningOfFile/README.md similarity index 51% rename from custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testCodeSectionAtBeginingOfFile/README.md rename to custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testCodeSectionAtBeginningOfFile/README.md index 5dd1319b..8ce3d76f 100644 --- a/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testCodeSectionAtBeginingOfFile/README.md +++ b/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testCodeSectionAtBeginningOfFile/README.md @@ -1,5 +1,5 @@ ``` -function codeSectionOnTheBegining(){ +function codeSectionOnTheBeginning(){ var age= 5; var name= Michael; } diff --git a/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListAtBeginingOfFile/README.md b/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListAtBeginingOfFile/README.md deleted file mode 100644 index 70c062fc..00000000 --- a/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListAtBeginingOfFile/README.md +++ /dev/null @@ -1,3 +0,0 @@ -- list element one -- list element two -- this list started at the begining of the file diff --git a/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListAtBeginningOfFile/README.md b/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListAtBeginningOfFile/README.md new file mode 100644 index 00000000..649db554 --- /dev/null +++ b/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListAtBeginningOfFile/README.md @@ -0,0 +1,3 @@ +- list element one +- list element two +- this list started at the beginning of the file diff --git a/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListBeginingSameAsAnotherLineBegining/README.md b/custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListBeginningSameAsAnotherLineBeginning/README.md similarity index 100% rename from custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListBeginingSameAsAnotherLineBegining/README.md rename to custom-checks/checkstyle/src/test/resources/checkstyle/markdownCheckTest/testListBeginningSameAsAnotherLineBeginning/README.md diff --git a/custom-checks/checkstyle/src/test/resources/checkstyle/missingJavadocFilterCheckTest/MissingJavadocOuterAndInnnerClass.java b/custom-checks/checkstyle/src/test/resources/checkstyle/missingJavadocFilterCheckTest/MissingJavadocOuterAndInnerClass.java similarity index 89% rename from custom-checks/checkstyle/src/test/resources/checkstyle/missingJavadocFilterCheckTest/MissingJavadocOuterAndInnnerClass.java rename to custom-checks/checkstyle/src/test/resources/checkstyle/missingJavadocFilterCheckTest/MissingJavadocOuterAndInnerClass.java index 10d049ad..dd333679 100644 --- a/custom-checks/checkstyle/src/test/resources/checkstyle/missingJavadocFilterCheckTest/MissingJavadocOuterAndInnnerClass.java +++ b/custom-checks/checkstyle/src/test/resources/checkstyle/missingJavadocFilterCheckTest/MissingJavadocOuterAndInnerClass.java @@ -7,7 +7,7 @@ */ package org.openhab.core.buildtools.rules.checkstyle.test; -public class MissingJavadocOuterAndInnnerClass { +public class MissingJavadocOuterAndInnerClass { public class InnerClass{ diff --git a/custom-checks/checkstyle/src/test/resources/checkstyle/noEmptyLineSeparatorCheck/MutlitpleEmptyLinesInSwitchWithCases.java b/custom-checks/checkstyle/src/test/resources/checkstyle/noEmptyLineSeparatorCheck/MultipleEmptyLinesInSwitchWithCases.java similarity index 100% rename from custom-checks/checkstyle/src/test/resources/checkstyle/noEmptyLineSeparatorCheck/MutlitpleEmptyLinesInSwitchWithCases.java rename to custom-checks/checkstyle/src/test/resources/checkstyle/noEmptyLineSeparatorCheck/MultipleEmptyLinesInSwitchWithCases.java diff --git a/custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlUsageCheckTest/missingConfigDesciptionRef/src/main/resources/OH-INF/thing/thing-types.xml b/custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlUsageCheckTest/missingConfigDescriptionRef/src/main/resources/OH-INF/thing/thing-types.xml similarity index 100% rename from custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlUsageCheckTest/missingConfigDesciptionRef/src/main/resources/OH-INF/thing/thing-types.xml rename to custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlUsageCheckTest/missingConfigDescriptionRef/src/main/resources/OH-INF/thing/thing-types.xml diff --git a/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/AvoidMavenPomderivedInClasspath.xml b/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/AvoidMavenPomderivedInClasspath.xml index a17e2255..13c1e76e 100644 --- a/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/AvoidMavenPomderivedInClasspath.xml +++ b/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/AvoidMavenPomderivedInClasspath.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests https://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> Maven pomderived in .classpath 1 diff --git a/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/AvoidOverridingParentPomConfiguration.xml b/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/AvoidOverridingParentPomConfiguration.xml index 7af46b36..c00db946 100644 --- a/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/AvoidOverridingParentPomConfiguration.xml +++ b/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/AvoidOverridingParentPomConfiguration.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests https://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> Override parent pom configuration 1 diff --git a/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/UseSLF4JLoggerRule.xml b/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/UseSLF4JLoggerRule.xml index 0b6d2fd0..1bb15796 100644 --- a/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/UseSLF4JLoggerRule.xml +++ b/custom-checks/pmd/src/test/resources/org/openhab/tools/analysis/pmd/test/xml/UseSLF4JLoggerRule.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests https://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> Java util logger is used diff --git a/custom-checks/pmd/src/test/resources/pmd/ruleset/classpath.xml b/custom-checks/pmd/src/test/resources/pmd/ruleset/classpath.xml index a1e61772..98c4fa50 100644 --- a/custom-checks/pmd/src/test/resources/pmd/ruleset/classpath.xml +++ b/custom-checks/pmd/src/test/resources/pmd/ruleset/classpath.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.net/ruleset_2_0_0.xsd"> Rule set that contains custom defined rules regarding the .classpath files diff --git a/custom-checks/pmd/src/test/resources/pmd/ruleset/customrules.xml b/custom-checks/pmd/src/test/resources/pmd/ruleset/customrules.xml index 2adca011..b8b9a6a2 100644 --- a/custom-checks/pmd/src/test/resources/pmd/ruleset/customrules.xml +++ b/custom-checks/pmd/src/test/resources/pmd/ruleset/customrules.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.net/ruleset_2_0_0.xsd"> Rule set that contains custom defined rules regarding the .classpath files - \ No newline at end of file + diff --git a/custom-checks/pmd/src/test/resources/pmd/ruleset/pom.xml b/custom-checks/pmd/src/test/resources/pmd/ruleset/pom.xml index a6fa5c00..a8b4db74 100644 --- a/custom-checks/pmd/src/test/resources/pmd/ruleset/pom.xml +++ b/custom-checks/pmd/src/test/resources/pmd/ruleset/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.net/ruleset_2_0_0.xsd"> Rule set that contains custom defined rules regarding the pom.xml files diff --git a/sat-plugin/src/main/java/org/openhab/tools/analysis/report/ReportMojo.java b/sat-plugin/src/main/java/org/openhab/tools/analysis/report/ReportMojo.java index 874d31cc..0183f282 100644 --- a/sat-plugin/src/main/java/org/openhab/tools/analysis/report/ReportMojo.java +++ b/sat-plugin/src/main/java/org/openhab/tools/analysis/report/ReportMojo.java @@ -45,6 +45,7 @@ import java.io.InputStreamReader; import java.io.StringWriter; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; @@ -392,9 +393,9 @@ private void generateSummaryByBundle(File htmlOutputFile, File mergedReport) { .appendOffset("+HH:MM", "Z").toFormatter(); htmlString = htmlString.replace("$time", formatter.format(ZonedDateTime.now())); - FileUtils.writeStringToFile(summaryReport, htmlString); + FileUtils.writeStringToFile(summaryReport, htmlString, StandardCharsets.UTF_8); } - String reportContent = FileUtils.readFileToString(summaryReport); + String reportContent = FileUtils.readFileToString(summaryReport, StandardCharsets.UTF_8); final String singleItem = "%s"; Path absoluteIndividualReportPath = htmlOutputFile.toPath(); @@ -407,7 +408,7 @@ private void generateSummaryByBundle(File htmlOutputFile, File mergedReport) { String row = String.format(singleItem, relativePath, bundleName); reportContent = reportContent.replace("", row); - FileUtils.writeStringToFile(summaryReport, reportContent); + FileUtils.writeStringToFile(summaryReport, reportContent, StandardCharsets.UTF_8); getLog().info("Individual report appended to summary report."); } catch (IOException e) { getLog().warn("Can't read or write to summary report. The summary report might be incomplete!", e); diff --git a/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/CheckstyleChecker.java b/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/CheckstyleChecker.java index 71dbfdf7..5c48eaae 100644 --- a/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/CheckstyleChecker.java +++ b/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/CheckstyleChecker.java @@ -106,9 +106,9 @@ public void execute() throws MojoExecutionException { log.debug("Ruleset location is " + ruleset); userProps.setProperty(CHECKSTYLE_RULE_SET_PROPERTY, ruleset); - String supression = getLocation(checkstyleFilter, DEFAULT_FILTER_XML); - log.debug("Filter location is " + supression); - userProps.setProperty(CHECKSTYLE_SUPPRESSION_PROPERTY, supression); + String suppression = getLocation(checkstyleFilter, DEFAULT_FILTER_XML); + log.debug("Filter location is " + suppression); + userProps.setProperty(CHECKSTYLE_SUPPRESSION_PROPERTY, suppression); if (checkstyleProperties != null) { String rulesetProperties = getLocation(checkstyleProperties, ""); diff --git a/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/SpotBugsChecker.java b/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/SpotBugsChecker.java index 69ec112c..7c7f8f77 100644 --- a/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/SpotBugsChecker.java +++ b/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/SpotBugsChecker.java @@ -212,7 +212,7 @@ private String getVisitorsString(String externalLocation) { try { stream = new FileInputStream(file); } catch (FileNotFoundException e) { - getLog().warn("Unable to find file " + resolvedPath.toString()); + getLog().warn("Unable to find file " + resolvedPath); } } else { stream = this.getClass().getClassLoader().getResourceAsStream(SpotBugsChecker.DEFAULT_VISITORS_XML); diff --git a/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/internal/SpotBugsVisitors.java b/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/internal/SpotBugsVisitors.java index 35f17955..54c04576 100644 --- a/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/internal/SpotBugsVisitors.java +++ b/sat-plugin/src/main/java/org/openhab/tools/analysis/tools/internal/SpotBugsVisitors.java @@ -29,7 +29,7 @@ public class SpotBugsVisitors { @XmlElement - List visitor = new ArrayList(); + List visitor = new ArrayList<>(); @Override public String toString() { diff --git a/sat-plugin/src/main/resources/report/create_html.xslt b/sat-plugin/src/main/resources/report/create_html.xslt index 7ee952f8..5dcf580a 100644 --- a/sat-plugin/src/main/resources/report/create_html.xslt +++ b/sat-plugin/src/main/resources/report/create_html.xslt @@ -267,7 +267,7 @@ - <a href="http://findbugs.sourceforge.net/bugDescriptions.html# + <a href="https://findbugs.sourceforge.net/bugDescriptions.html# "> diff --git a/sat-plugin/src/main/resources/rulesets/pmd/customrules.xml b/sat-plugin/src/main/resources/rulesets/pmd/customrules.xml index 1e990590..52e48d18 100644 --- a/sat-plugin/src/main/resources/rulesets/pmd/customrules.xml +++ b/sat-plugin/src/main/resources/rulesets/pmd/customrules.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.net/ruleset_2_0_0.xsd"> Rule set that contains custom rules created for checking all bundles diff --git a/sat-plugin/src/main/resources/rulesets/pmd/rules.xml b/sat-plugin/src/main/resources/rulesets/pmd/rules.xml index b2cfd1a4..bd87101e 100644 --- a/sat-plugin/src/main/resources/rulesets/pmd/rules.xml +++ b/sat-plugin/src/main/resources/rulesets/pmd/rules.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.net/ruleset_2_0_0.xsd"> Default set of PMD rules used for checking all bundles diff --git a/sat-plugin/src/test/resources/report/pmd.xml b/sat-plugin/src/test/resources/report/pmd.xml index 5846d684..8d6db1be 100644 --- a/sat-plugin/src/test/resources/report/pmd.xml +++ b/sat-plugin/src/test/resources/report/pmd.xml @@ -2,15 +2,15 @@ - + An operation on an Immutable object (String, BigDecimal or BigInteger) won't change the object itself - + Do not use if statements that are always true or always false