getSet(ErrorProneFlags errorProneFlags, String name) {
36 | return ImmutableSet.copyOf(getList(errorProneFlags, name));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/error-prone-utils/src/main/java/tech/picnic/errorprone/utils/MoreMatchers.java:
--------------------------------------------------------------------------------
1 | package tech.picnic.errorprone.utils;
2 |
3 | import static com.google.errorprone.matchers.Matchers.typePredicateMatcher;
4 | import static tech.picnic.errorprone.utils.MoreTypePredicates.hasAnnotation;
5 |
6 | import com.google.errorprone.matchers.Matcher;
7 | import com.google.errorprone.matchers.Matchers;
8 | import com.google.errorprone.suppliers.Supplier;
9 | import com.sun.source.tree.AnnotationTree;
10 | import com.sun.source.tree.Tree;
11 | import com.sun.tools.javac.code.Type;
12 |
13 | /**
14 | * A collection of general-purpose {@link Matcher}s.
15 | *
16 | * These methods are additions to the ones found in {@link Matchers}.
17 | */
18 | public final class MoreMatchers {
19 | private MoreMatchers() {}
20 |
21 | /**
22 | * Returns a {@link Matcher} that determines whether a given {@link AnnotationTree} has a
23 | * meta-annotation of the specified type.
24 | *
25 | * @param The type of tree to match against.
26 | * @param annotationType The binary type name of the annotation (e.g.
27 | * "org.jspecify.annotations.Nullable", or "some.package.OuterClassName$InnerClassName")
28 | * @return A {@link Matcher} that matches trees with the specified meta-annotation.
29 | */
30 | public static Matcher hasMetaAnnotation(String annotationType) {
31 | return typePredicateMatcher(hasAnnotation(annotationType));
32 | }
33 |
34 | /**
35 | * Returns a {@link Matcher} that determines whether the type of a given {@link Tree} is a subtype
36 | * of the type returned by the specified {@link Supplier}.
37 | *
38 | * This method differs from {@link Matchers#isSubtypeOf(Supplier)} in that it does not perform
39 | * type erasure.
40 | *
41 | * @param The type of tree to match against.
42 | * @param type The {@link Supplier} that returns the type to match against.
43 | * @return A {@link Matcher} that matches trees with the specified type.
44 | */
45 | public static Matcher isSubTypeOf(Supplier type) {
46 | return typePredicateMatcher(MoreTypePredicates.isSubTypeOf(type));
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/error-prone-utils/src/main/java/tech/picnic/errorprone/utils/package-info.java:
--------------------------------------------------------------------------------
1 | /** Auxiliary utilities for use by Error Prone checks. */
2 | @com.google.errorprone.annotations.CheckReturnValue
3 | @org.jspecify.annotations.NullMarked
4 | package tech.picnic.errorprone.utils;
5 |
--------------------------------------------------------------------------------
/error-prone-utils/src/test/java/tech/picnic/errorprone/utils/FlagsTest.java:
--------------------------------------------------------------------------------
1 | package tech.picnic.errorprone.utils;
2 |
3 | import static org.assertj.core.api.Assertions.assertThat;
4 | import static org.junit.jupiter.params.provider.Arguments.arguments;
5 |
6 | import com.google.common.collect.ImmutableList;
7 | import com.google.common.collect.ImmutableSet;
8 | import com.google.errorprone.ErrorProneOptions;
9 | import java.util.stream.Stream;
10 | import org.junit.jupiter.params.ParameterizedTest;
11 | import org.junit.jupiter.params.provider.Arguments;
12 | import org.junit.jupiter.params.provider.MethodSource;
13 |
14 | final class FlagsTest {
15 | private static Stream getCollectionTestCases() {
16 | /* { args, flag, listed } */
17 | return Stream.of(
18 | arguments(ImmutableList.of(), "Foo", ImmutableList.of()),
19 | arguments(ImmutableList.of("-XepOpt:Foo=bar,baz"), "Qux", ImmutableList.of()),
20 | arguments(ImmutableList.of("-XepOpt:Foo="), "Foo", ImmutableList.of()),
21 | arguments(ImmutableList.of("-XepOpt:Foo=bar"), "Foo", ImmutableList.of("bar")),
22 | arguments(ImmutableList.of("-XepOpt:Foo=bar,bar"), "Foo", ImmutableList.of("bar", "bar")),
23 | arguments(ImmutableList.of("-XepOpt:Foo=bar,baz"), "Foo", ImmutableList.of("bar", "baz")),
24 | arguments(ImmutableList.of("-XepOpt:Foo=,"), "Foo", ImmutableList.of("", "")));
25 | }
26 |
27 | @MethodSource("getCollectionTestCases")
28 | @ParameterizedTest
29 | void getList(ImmutableList args, String flag, ImmutableList listed) {
30 | assertThat(Flags.getList(ErrorProneOptions.processArgs(args).getFlags(), flag))
31 | .containsExactlyElementsOf(listed);
32 | }
33 |
34 | @MethodSource("getCollectionTestCases")
35 | @ParameterizedTest
36 | void getSet(ImmutableList args, String flag, ImmutableList listed) {
37 | assertThat(Flags.getSet(ErrorProneOptions.processArgs(args).getFlags(), flag))
38 | .containsExactlyElementsOf(ImmutableSet.copyOf(listed));
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/generate-docs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e -u -o pipefail
4 |
5 | REPOSITORY_ROOT="$(git rev-parse --show-toplevel)"
6 | WEBSITE_ROOT="${REPOSITORY_ROOT}/website"
7 |
8 | generate_homepage() {
9 | local homepage="${WEBSITE_ROOT}/index.md"
10 |
11 | echo "Generating ${homepage}..."
12 | cat - "${REPOSITORY_ROOT}/README.md" > "${homepage}" << EOF
13 | ---
14 | layout: default
15 | title: Home
16 | nav_order: 1
17 | ---
18 | EOF
19 |
20 | local macos_compat=""
21 | [[ "${OSTYPE}" == "darwin"* ]] && macos_compat="yes"
22 | sed -i ${macos_compat:+".bak"} 's/src="website\//src="/g' "${homepage}"
23 | sed -i ${macos_compat:+".bak"} 's/srcset="website\//srcset="/g' "${homepage}"
24 | }
25 |
26 | # Generate the website.
27 | generate_homepage
28 |
--------------------------------------------------------------------------------
/integration-tests/checkstyle.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e -u -o pipefail
4 |
5 | test_name="$(basename "${0}" .sh)"
6 | project='checkstyle'
7 | repository='https://github.com/checkstyle/checkstyle.git'
8 | revision='checkstyle-10.21.0'
9 | additional_build_flags='-Perror-prone-compile,error-prone-test-compile -Dmaven.compiler.failOnError=true'
10 | additional_source_directories='${project.basedir}${file.separator}src${file.separator}it${file.separator}java,${project.basedir}${file.separator}src${file.separator}xdocs-examples${file.separator}java'
11 | shared_error_prone_flags='-XepExcludedPaths:(\Q${project.basedir}${file.separator}src${file.separator}\E(it|test|xdocs-examples)\Q${file.separator}resources\E|\Q${project.build.directory}${file.separator}\E).*'
12 | patch_error_prone_flags=''
13 | validation_error_prone_flags=''
14 | # Validation skips some tests:
15 | # - The `metadataFilesGenerationAllFiles` test is skipped because it makes line
16 | # number assertions that will fail when the code is formatted or patched.
17 | # - The `allCheckSectionJavaDocs` test is skipped because it validates that
18 | # Javadoc has certain closing tags that are removed by Google Java Format.
19 | validation_build_flags='-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs'
20 |
21 | if [ "${#}" -gt 2 ] || ([ "${#}" = 2 ] && [ "${1:---sync}" != '--sync' ]); then
22 | >&2 echo "Usage: ${0} [--sync] []"
23 | exit 1
24 | fi
25 |
26 | "$(dirname "${0}")/run-integration-test.sh" \
27 | "${test_name}" \
28 | "${project}" \
29 | "${repository}" \
30 | "${revision}" \
31 | "${additional_build_flags}" \
32 | "${additional_source_directories}" \
33 | "${shared_error_prone_flags}" \
34 | "${patch_error_prone_flags}" \
35 | "${validation_error_prone_flags}" \
36 | "${validation_build_flags}" \
37 | $@
38 |
--------------------------------------------------------------------------------
/integration-tests/metrics.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e -u -o pipefail
4 |
5 | test_name="$(basename "${0}" .sh)"
6 | project='metrics'
7 | repository='https://github.com/dropwizard/metrics.git'
8 | revision='v5.0.0-rc22'
9 | additional_build_flags=''
10 | additional_source_directories=''
11 | shared_error_prone_flags='-XepExcludedPaths:.*/target/generated-sources/.* -XepOpt:Slf4jLoggerDeclaration:CanonicalStaticLoggerName=LOGGER'
12 | patch_error_prone_flags=''
13 | validation_error_prone_flags=''
14 | validation_build_flags=''
15 |
16 | if [ "${#}" -gt 2 ] || ([ "${#}" = 2 ] && [ "${1:---sync}" != '--sync' ]); then
17 | >&2 echo "Usage: ${0} [--sync] []"
18 | exit 1
19 | fi
20 |
21 | "$(dirname "${0}")/run-integration-test.sh" \
22 | "${test_name}" \
23 | "${project}" \
24 | "${repository}" \
25 | "${revision}" \
26 | "${additional_build_flags}" \
27 | "${additional_source_directories}" \
28 | "${shared_error_prone_flags}" \
29 | "${patch_error_prone_flags}" \
30 | "${validation_error_prone_flags}" \
31 | "${validation_build_flags}" \
32 | $@
33 |
--------------------------------------------------------------------------------
/integration-tests/prometheus-java-client-init.patch:
--------------------------------------------------------------------------------
1 | --- a/pom.xml
2 | +++ b/pom.xml
3 | @@ -99,7 +99,6 @@
4 | com.google.guava
5 | guava
6 | ${guava.version}
7 | - test
8 |
9 |
10 | org.slf4j
11 | @@ -320,13 +319,24 @@
12 | -Xep:LongDoubleConversion:OFF
13 | -Xep:StringSplitter:OFF
14 | -XepExcludedPaths:.*/generated/.*
15 | + ${error-prone.configuration-args}
16 |
17 |
18 |
19 |
20 | com.google.errorprone
21 | error_prone_core
22 | - 2.38.0
23 | + ${error-prone.version}
24 | +
25 | +
26 | + tech.picnic.error-prone-support
27 | + error-prone-contrib
28 | + ${error-prone-support.version}
29 | +
30 | +
31 | + tech.picnic.error-prone-support
32 | + refaster-runner
33 | + ${error-prone-support.version}
34 |
35 |
10 | error-prone-fork
11 |
12 |
13 | error-prone-fork
14 | https://maven.pkg.github.com/PicnicSupermarket/error-prone
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | error-prone-fork
23 | ${env.GITHUB_ACTOR}
24 | ${env.GITHUB_TOKEN}
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/website/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated by Bundler and Jekyll.
2 | .bundle/
3 | Gemfile.lock
4 | .jekyll-cache/
5 | .jekyll-metadata
6 | .sass-cache/
7 | _site/
8 | vendor/
9 |
10 | # Generated by `../generate-docs.sh`.
11 | *.bak
12 | index.md
13 |
--------------------------------------------------------------------------------
/website/.ruby-version:
--------------------------------------------------------------------------------
1 | 3.1.2
2 |
--------------------------------------------------------------------------------
/website/404.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: Page not found
4 | permalink: /404
5 | nav_exclude: true
6 | search_exclude: true
7 | ---
8 |
9 | ## Page not found :(
10 |
11 | The requested page could not be found.
12 |
--------------------------------------------------------------------------------
/website/Gemfile:
--------------------------------------------------------------------------------
1 | ruby File.read(".ruby-version").strip
2 |
3 | source "https://rubygems.org"
4 | gem "html-proofer", "4.4.1"
5 | gem "jekyll", "4.2.2"
6 | gem "jekyll-sitemap", "1.4"
7 | gem "just-the-docs", "0.4.0.rc2"
8 | gem "webrick", "1.7"
9 |
--------------------------------------------------------------------------------
/website/_config.yml:
--------------------------------------------------------------------------------
1 | # General configuration.
2 | title: Error Prone Support
3 | logo: assets/images/favicon.svg
4 | url: https://error-prone.picnic.tech
5 | description: >-
6 | Error Prone extensions: extra bug checkers and a large battery of Refaster
7 | rules.
8 |
9 | theme: just-the-docs
10 | plugins:
11 | - jekyll-sitemap
12 |
13 | # Files and directories not to be deployed through GitHub pages.
14 | exclude:
15 | - Gemfile
16 | - Gemfile.lock
17 | - generate-version-compatibility-overview.sh
18 | - README.md
19 | - vendor
20 |
21 | # See https://jekyllrb.com/docs/permalinks/#built-in-formats.
22 | permalink: pretty
23 |
24 | # Theme (just-the-docs) configuration.
25 | # See
26 | # https://just-the-docs.github.io/just-the-docs/docs/navigation-structure/#external-navigation-links.
27 | nav_external_links:
28 | - title: Error Prone Support on GitHub
29 | url: https://github.com/PicnicSupermarket/error-prone-support
30 | hide_icon: false
31 |
32 | callouts:
33 | summary:
34 | color: blue
35 | note:
36 | color: grey-dk
37 |
38 | # SEO configuration.
39 | # See https://jekyll.github.io/jekyll-seo-tag/usage.
40 | social:
41 | name: Picnic
42 | links:
43 | - https://github.com/PicnicSupermarket
44 | - https://twitter.com/picnic
45 | - https://www.linkedin.com/company/picnictechnologies
46 | twitter:
47 | username: picnic
48 | card: summary
49 |
--------------------------------------------------------------------------------
/website/_includes/footer_custom.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Copyright © 2017-2024 Picnic Technologies BV
5 |
6 |
--------------------------------------------------------------------------------
/website/_includes/head_custom.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
13 |
15 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/website/_sass/color_schemes/_common.scss:
--------------------------------------------------------------------------------
1 | // Add support for external anchor icons.
2 | .external > svg {
3 | width: 1rem;
4 | vertical-align: text-bottom;
5 | }
6 |
7 | .label {
8 | // Reduce spacing between labels and align with surrounding elements.
9 | margin-left: 0 !important;
10 | }
11 |
12 | footer {
13 | text-align: center;
14 |
15 | img#logo {
16 | width: 2rem;
17 | margin: 0 auto;
18 | display: block;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/website/_sass/color_schemes/_variables.scss:
--------------------------------------------------------------------------------
1 | // Overrides for Just the Docs. See
2 | // https://github.com/just-the-docs/just-the-docs/blob/main/_sass/support/_variables.scss.
3 |
4 | // Grid system.
5 | $nav-width: 400px;
6 |
--------------------------------------------------------------------------------
/website/_sass/color_schemes/eps-dark.scss:
--------------------------------------------------------------------------------
1 | @import "./color_schemes/dark";
2 | @import "_variables";
3 | @import "_common";
4 |
5 | // Swap `$blue-000` and `$blue-300`, mainly for callouts. This is done by
6 | // default for red, but not for other colors.
7 | $blue-000: #183385;
8 | $blue-300: #2c84fa;
9 |
10 | // Use light-theme greys in dark theme so that summary callouts stand out more.
11 | // (Note that the former has four shades, while the latter has five.)
12 | $grey-dk-000: $grey-lt-000;
13 | $grey-dk-100: $grey-lt-100;
14 | $grey-dk-200: $grey-lt-200;
15 | $grey-dk-250: $grey-lt-200;
16 | $grey-dk-300: $grey-lt-300;
17 |
--------------------------------------------------------------------------------
/website/_sass/color_schemes/eps-light.scss:
--------------------------------------------------------------------------------
1 | @import "./color_schemes/light";
2 | @import "_variables";
3 | @import "_common";
4 |
--------------------------------------------------------------------------------
/website/assets/css/just-the-docs-eps-dark.scss:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 | {% include css/just-the-docs.scss.liquid color_scheme="eps-dark" %}
4 |
--------------------------------------------------------------------------------
/website/assets/css/just-the-docs-eps-light.scss:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 | {% include css/just-the-docs.scss.liquid color_scheme="eps-light" %}
4 |
--------------------------------------------------------------------------------
/website/assets/images/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PicnicSupermarket/error-prone-support/27637810db1cfe1cbce3dd0deb2a0d8268c85f22/website/assets/images/android-chrome-192x192.png
--------------------------------------------------------------------------------
/website/assets/images/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PicnicSupermarket/error-prone-support/27637810db1cfe1cbce3dd0deb2a0d8268c85f22/website/assets/images/android-chrome-512x512.png
--------------------------------------------------------------------------------
/website/assets/images/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PicnicSupermarket/error-prone-support/27637810db1cfe1cbce3dd0deb2a0d8268c85f22/website/assets/images/apple-touch-icon.png
--------------------------------------------------------------------------------
/website/assets/images/browserconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | #da532c
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/website/assets/images/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PicnicSupermarket/error-prone-support/27637810db1cfe1cbce3dd0deb2a0d8268c85f22/website/assets/images/favicon-16x16.png
--------------------------------------------------------------------------------
/website/assets/images/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PicnicSupermarket/error-prone-support/27637810db1cfe1cbce3dd0deb2a0d8268c85f22/website/assets/images/favicon-32x32.png
--------------------------------------------------------------------------------
/website/assets/images/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PicnicSupermarket/error-prone-support/27637810db1cfe1cbce3dd0deb2a0d8268c85f22/website/assets/images/mstile-150x150.png
--------------------------------------------------------------------------------
/website/assets/images/picnic-logo@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PicnicSupermarket/error-prone-support/27637810db1cfe1cbce3dd0deb2a0d8268c85f22/website/assets/images/picnic-logo@2x.png
--------------------------------------------------------------------------------
/website/assets/images/site.webmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Error Prone Support documentation",
3 | "short_name": "Error Prone Support",
4 | "icons": [
5 | {
6 | "src": "/assets/images/android-chrome-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | },
10 | {
11 | "src": "/assets/images/android-chrome-512x512.png",
12 | "sizes": "512x512",
13 | "type": "image/png"
14 | }
15 | ],
16 | "theme_color": "#ffffff",
17 | "background_color": "#ffffff",
18 | "display": "standalone"
19 | }
20 |
--------------------------------------------------------------------------------
/website/bugpatterns.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: Bug Patterns
4 | nav_order: 2
5 | has_children: true
6 | ---
7 |
8 | # Bug Patterns
9 |
--------------------------------------------------------------------------------
/website/compatibility.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: Compatibility matrix
4 | nav_order: 2
5 | ---
6 |
7 | # Compatibility matrix
8 |
9 | {% comment %}
10 | XXX: Once available on the default branch, include a link to the
11 | `generate-version-compatibility-overview.sh` script.
12 | {% endcomment %}
13 |
14 | Error Prone Support releases are generally compatible with only a limited
15 | number of Error Prone releases. The table below shows, for each Error Prone
16 | Support release, the Error Prone versions it is expected to be compatible with.
17 | Compatibility is determined by:
18 | 1. Compiling and testing the Error Prone Support release source code against a
19 | given Error Prone version. This validates source and behavioral
20 | compatibility.[^1] [^2]
21 | 2. Applying the released Refaster rules using a given Error Prone version. This
22 | validates that the rules can be read by the targeted version of Error Prone,
23 | proving that the serialization format is compatible.
24 |
25 | | Error Prone Support version | Compatible Error Prone versions |
26 | | --------------------------- | ------------------------------- |
27 | {% for release in site.data.compatibility.releases -%}
28 | | [{{ release.version }}](https://github.com/PicnicSupermarket/error-prone-support/releases/tag/v{{ release.version }}) | {%
29 | for version in release.compatible -%}
30 | [{{ version }}](https://github.com/google/error-prone/releases/tag/v{{ version }}){% unless forloop.last %}, {% endunless %}
31 | {%- endfor %} |
32 | {% endfor %}
33 |
34 | [^1]: Note that this [does not prove][source-binary-compat] that the Error Prone Support and Error Prone versions are _binary_ compatible. This limitation does not appear to be an issue in practice.
35 | [^2]: The approach taken here may yield false negatives, because a reported incompatibility may merely be due to a test API incompatibility.
36 | [source-binary-compat]: https://stackoverflow.com/questions/57871898/
37 |
--------------------------------------------------------------------------------
/website/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PicnicSupermarket/error-prone-support/27637810db1cfe1cbce3dd0deb2a0d8268c85f22/website/favicon.ico
--------------------------------------------------------------------------------
/website/refasterrules.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: Refaster Rules
4 | nav_order: 2
5 | has_children: true
6 | ---
7 |
8 | # Refaster Rules
9 |
--------------------------------------------------------------------------------