feat(#1100): add broad-scope lint - #1238
Conversation
|
@yegor256 @volodya-lombrozo plz review |
|
/benchmark |
Benchmark comparison for #1238Comparing this branch against the Biggest changes
Full results (430 entries)
|
|
@rultor merge |
@volodya-lombrozo OK, I'll try to merge now. You can check the progress of the merge here. |
@VasilevNStas @volodya-lombrozo Oops, I failed. You can see the full log here (spent 4min). |
|
The merge bot failed on the proguard step, and I traced the reason. Here is the full picture so we can decide how to fix it. What failedThe rultor merge runs Why this PR is not the causeThis PR is purely declarative: it only adds one XSL sheet ( The real reason: JDK 21 + proguard profileThe <profile>
<id>proguard</id>
<activation>
<jdk>[,22)</jdk>
</activation>The rultor docker image is Proguard 2.7.0 on JDK 21 hits the well-known The smoking gun in .rultor.ymlThe release script explicitly sets the JVM options proguard needs: export MAVEN_OPTS="--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED"
mvn clean deploy -ntp -P!hone,!proguard,reserved,...while the merge script does not set merge:
script: |
mvn clean install -ntp -P!hone,qulice --errors -Dstyle.color=neverSo on merge, proguard runs on JDK 21 without the Why other PRs merged fineRecent merges (#1283, #1282, #1281, #1272) went through before Suggested fix (maintainer-side, not in this PR)Add the same merge:
script: |
export MAVEN_OPTS="--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED"
mvn clean install -ntp -P!hone,!proguard,qulice --errors -Dstyle.color=neverOnce that is in, this PR can be merged as-is — its content is fine (tests green, qulice clean, signed commits). |
|
@volodya-lombrozo Thanks for the review! You've earned +4 points for this: +12 as a basis; -8 for absolutely no comments posted. Your running score is +500; don't forget to check your Zerocracy account too). |
Fixes #1100.
Problem
A private attribute (
local) may have an excessively broad scope: it is used only inside a single nested object, while it is declared at a much higher level. This should lead to a lint warning.Solution / What
New XSLT lint
broad-scopemodeled afterredundant-object: it finds private attributes referenced (via^ξ(?:\.ρ)*\.base prefixes) exclusively within a single object different from the declaration site, and warns that the scope is too broad.Changes
src/main/resources/org/eolang/lints/design/broad-scope.xsl— the new lint.src/main/resources/org/eolang/motives/design/broad-scope.md— motivation.src/test/resources/org/eolang/lints/packs/single/broad-scope/— 3 test packs.Tests
catches-broad-scopeallows-used-on-top-levelallows-used-in-multiple-objects