From cc731ae81a2150efe0dd276bdb4f1e1d8c01cc26 Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Sat, 22 Sep 2018 09:36:07 +0200 Subject: [PATCH] Updating README.md --- README.md | 70 +++++++++---------- .../violations/lib/reports/ReporterTest.java | 24 ++++++- 2 files changed, 58 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index c7b43537..0c7f9ef2 100644 --- a/README.md +++ b/README.md @@ -3,60 +3,60 @@ This is a Java library for parsing report files from static code analysis. It supports: - * [_AndroidLint_](http://developer.android.com/tools/help/lint.html) - * [_Checkstyle_](http://checkstyle.sourceforge.net/) + * `ANDROIDLINT` [_AndroidLint_](http://developer.android.com/tools/help/lint.html) + * `CHECKSTYLE` [_Checkstyle_](http://checkstyle.sourceforge.net/) * [_Detekt_](https://github.com/arturbosch/detekt) with `--output-format xml`. * [_ESLint_](https://github.com/sindresorhus/grunt-eslint) with `format: 'checkstyle'`. * [_KTLint_](https://github.com/shyiko/ktlint) * [_SwiftLint_](https://github.com/realm/SwiftLint) with `--reporter checkstyle`. * [_TSLint_](https://palantir.github.io/tslint/usage/cli/) with `-t checkstyle` * [_PHPCS_](https://github.com/squizlabs/PHP_CodeSniffer) with `phpcs api.php --report=checkstyle`. - * [_CLang_](https://clang-analyzer.llvm.org/) + * `CLANG` [_CLang_](https://clang-analyzer.llvm.org/) * [_RubyCop_](http://rubocop.readthedocs.io/en/latest/formatters/) with `rubycop -f clang file.rb` * [_GCC_](https://gcc.gnu.org/) * [_ARM-GCC_](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm) * [_Doxygen_](https://www.stack.nl/~dimitri/doxygen/) - * [_CodeNarc_](http://codenarc.sourceforge.net/) - * [_CPD_](http://pmd.sourceforge.net/pmd-4.3.0/cpd.html) - * [_CPPLint_](https://github.com/theandrewdavis/cpplint) - * [_CPPCheck_](http://cppcheck.sourceforge.net/) - * [_CSSLint_](https://github.com/CSSLint/csslint) - * [_DocFX_](http://dotnet.github.io/docfx/) - * [_Findbugs_](http://findbugs.sourceforge.net/) + * `CODENARC` [_CodeNarc_](http://codenarc.sourceforge.net/) + * `CPD` [_CPD_](http://pmd.sourceforge.net/pmd-4.3.0/cpd.html) + * `CPPLINT` [_CPPLint_](https://github.com/theandrewdavis/cpplint) + * `CPPCHECK` [_CPPCheck_](http://cppcheck.sourceforge.net/) + * `CSSLINT` [_CSSLint_](https://github.com/CSSLint/csslint) + * `DOCFX` [_DocFX_](http://dotnet.github.io/docfx/) + * `FINDBUGS` [_Findbugs_](http://findbugs.sourceforge.net/) * [_Spotbugs_](https://spotbugs.github.io/) - * [_Flake8_](http://flake8.readthedocs.org/en/latest/) + * `FLAKE8` [_Flake8_](http://flake8.readthedocs.org/en/latest/) * [_AnsibleLint_](https://github.com/willthames/ansible-lint) with `-p` * [_Mccabe_](https://pypi.python.org/pypi/mccabe) * [_Pep8_](https://github.com/PyCQA/pycodestyle) * [_PyFlakes_](https://pypi.python.org/pypi/pyflakes) - * [_FxCop_](https://en.wikipedia.org/wiki/FxCop) - * [_Gendarme_](http://www.mono-project.com/docs/tools+libraries/tools/gendarme/) - * [_GoLint_](https://github.com/golang/lint) + * `FXCOP` [_FxCop_](https://en.wikipedia.org/wiki/FxCop) + * `GENDARME` [_Gendarme_](http://www.mono-project.com/docs/tools+libraries/tools/gendarme/) + * `GOLINT` [_GoLint_](https://github.com/golang/lint) * [_GoVet_](https://golang.org/cmd/vet/) Same format as GoLint. - * [_GoogleErrorProne_](https://github.com/google/error-prone) + * `GOOGLEERRORPRONE` [_GoogleErrorProne_](https://github.com/google/error-prone) * [_NullAway_](https://github.com/uber/NullAway) Same format as Google Error Prone. - * [_JSHint_](http://jshint.com/) - * _Lint_ A common XML format, used by different linters. - * [_JCReport_](https://github.com/jCoderZ/fawkez/wiki/JcReport) - * [_Klocwork_](http://www.klocwork.com/products-services/klocwork/static-code-analysis) - * [_KotlinMaven_](https://github.com/JetBrains/kotlin) Output from Kotlin Maven Plugin. - * [_KotlinGradle_](https://github.com/JetBrains/kotlin) Output from Kotlin Gradle Plugin. - * [_MyPy_](https://pypi.python.org/pypi/mypy-lang) - * [_PCLint_](http://www.gimpel.com/html/pcl.htm) PC-Lint using the same output format as the Jenkins warnings plugin, [_details here_](https://wiki.jenkins.io/display/JENKINS/PcLint+options) - * [_PerlCritic_](https://github.com/Perl-Critic) - * [_PiTest_](http://pitest.org/) - * [_PyDocStyle_](https://pypi.python.org/pypi/pydocstyle) - * [_PyLint_](https://www.pylint.org/) with `pylint --output-format=parseable`. - * [_PMD_](https://pmd.github.io/) + * `JSHINT` [_JSHint_](http://jshint.com/) + * `LINT` _Lint_ A common XML format, used by different linters. + * `JCREPORT` [_JCReport_](https://github.com/jCoderZ/fawkez/wiki/JcReport) + * `KLOCWORK` [_Klocwork_](http://www.klocwork.com/products-services/klocwork/static-code-analysis) + * `KOTLINMAVEN` [_KotlinMaven_](https://github.com/JetBrains/kotlin) Output from Kotlin Maven Plugin. + * `KOTLINGRADLE` [_KotlinGradle_](https://github.com/JetBrains/kotlin) Output from Kotlin Gradle Plugin. + * `MYPY` [_MyPy_](https://pypi.python.org/pypi/mypy-lang) + * `PCLINT` [_PCLint_](http://www.gimpel.com/html/pcl.htm) PC-Lint using the same output format as the Jenkins warnings plugin, [_details here_](https://wiki.jenkins.io/display/JENKINS/PcLint+options) + * `PERLCRITIC` [_PerlCritic_](https://github.com/Perl-Critic) + * `PITEST` [_PiTest_](http://pitest.org/) + * `PYDOCSTYLE` [_PyDocStyle_](https://pypi.python.org/pypi/pydocstyle) + * `PYLINT` [_PyLint_](https://www.pylint.org/) with `pylint --output-format=parseable`. + * `PMD` [_PMD_](https://pmd.github.io/) * [_Infer_](http://fbinfer.com/) Facebook Infer. With `--pmd-xml`. * [_PHPPMD_](https://phpmd.org/) with `phpmd api.php xml ruleset.xml`. - * [_ReSharper_](https://www.jetbrains.com/resharper/) - * [_SbtScalac_](http://www.scala-sbt.org/) - * [_Simian_](http://www.harukizaemon.com/simian/) - * [_StyleCop_](https://stylecop.codeplex.com/) - * [_XMLLint_](http://xmlsoft.org/xmllint.html) - * [_YAMLLint_](https://yamllint.readthedocs.io/en/stable/index.html) with `-f parsable` - * [_ZPTLint_](https://pypi.python.org/pypi/zptlint) + * `RESHARPER` [_ReSharper_](https://www.jetbrains.com/resharper/) + * `SBTSCALAC` [_SbtScalac_](http://www.scala-sbt.org/) + * `SIMIAN` [_Simian_](http://www.harukizaemon.com/simian/) + * `STYLECOP` [_StyleCop_](https://stylecop.codeplex.com/) + * `XMLLINT` [_XMLLint_](http://xmlsoft.org/xmllint.html) + * `YAMLLINT` [_YAMLLint_](https://yamllint.readthedocs.io/en/stable/index.html) with `-f parsable` + * `ZPTLINT` [_ZPTLint_](https://pypi.python.org/pypi/zptlint) Example reports are available [in the test resources](https://github.com/tomasbjerre/violations-lib/tree/master/src/test/resources), examples of how to generate them are available [here](https://github.com/tomasbjerre/violations-test/blob/master/build.sh). diff --git a/src/test/java/se/bjurr/violations/lib/reports/ReporterTest.java b/src/test/java/se/bjurr/violations/lib/reports/ReporterTest.java index 9985d1ec..76b5ab03 100644 --- a/src/test/java/se/bjurr/violations/lib/reports/ReporterTest.java +++ b/src/test/java/se/bjurr/violations/lib/reports/ReporterTest.java @@ -3,21 +3,43 @@ import static org.assertj.core.api.Assertions.assertThat; import java.io.File; +import java.io.IOException; import java.nio.charset.Charset; +import java.nio.file.OpenOption; +import java.nio.file.StandardOpenOption; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.assertj.core.util.Files; import org.junit.Test; public class ReporterTest { @Test - public void test() { + public void test() throws IOException { File readmeFile = findReadmeFile(new File(".")); String content = Files.contentOf(readmeFile, Charset.forName("UTF-8")); for (Parser shouldBeMentioned : Parser.values()) { assertThat(content) // .as("All parsers should be mentioned in the README.md") // .containsIgnoringCase(shouldBeMentioned.name()); + final int parserIndex = + content.toLowerCase().indexOf("_" + shouldBeMentioned.name().toLowerCase() + "_") + 1; + String parsersName = + content.substring(parserIndex, parserIndex + shouldBeMentioned.name().length()); + String regex = + "(`[^`]+?`[ ]+?)?(\\[_" + parsersName + "_\\][^\\)]+?\\)|_" + parsersName + "_)"; + Matcher matcher = Pattern.compile(regex).matcher(content); + if (!matcher.find()) { + throw new RuntimeException("Did not find " + regex + " in :\n" + content); + } + final String original = matcher.group(2); + final String replaced = + content.replaceAll(regex, "`" + shouldBeMentioned.name() + "` " + original); + content = replaced; } + final OpenOption a; + java.nio.file.Files.write( + readmeFile.toPath(), content.getBytes(Charset.forName("UTF-8")), StandardOpenOption.CREATE); } private File findReadmeFile(File file) {