Skip to content

RM-37163: CPD 7.21.0 upgrade - #8

Merged
wener-tiobe merged 2477 commits into
tiobe_pmd7from
37163-CPD-7.21.0-upgrade
Feb 10, 2026
Merged

wener-tiobe merged 2477 commits into
tiobe_pmd7from
37163-CPD-7.21.0-upgrade

Conversation

@wener-tiobe

@wener-tiobe wener-tiobe commented Feb 4, 2026 •

Copy link
Copy Markdown

Describe the PR

Related issues

  • Fixes #

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

oowekyala and others added 30 commits December 17, 2025 15:09
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5.0.0 to 6.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@330a01c...b7c566a)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…#6332)

Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.20.0 to 5.21.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v5.20.0...v5.21.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-version: 5.21.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…6333)

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@018cc2c...37930b1)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [ruby/setup-ruby](https://github.com/ruby/setup-ruby) from 1.269.0 to 1.270.0.
- [Release notes](https://github.com/ruby/setup-ruby/releases)
- [Changelog](https://github.com/ruby/setup-ruby/blob/master/release.rb)
- [Commits](ruby/setup-ruby@d697be2...ac793fd)

---
updated-dependencies:
- dependency-name: ruby/setup-ruby
  dependency-version: 1.270.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
….0 (pmd#6335)

Bumps [com.puppycrawl.tools:checkstyle](https://github.com/checkstyle/checkstyle) from 12.2.0 to 12.3.0.
- [Release notes](https://github.com/checkstyle/checkstyle/releases)
- [Commits](checkstyle/checkstyle@checkstyle-12.2.0...checkstyle-12.3.0)

---
updated-dependencies:
- dependency-name: com.puppycrawl.tools:checkstyle
  dependency-version: 12.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/cache](https://github.com/actions/cache) from 4.3.0 to 5.0.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@0057852...9255dc7)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: 5.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [bigdecimal](https://github.com/ruby/bigdecimal) from 3.3.1 to 4.0.0.
- [Release notes](https://github.com/ruby/bigdecimal/releases)
- [Changelog](https://github.com/ruby/bigdecimal/blob/master/CHANGES.md)
- [Commits](ruby/bigdecimal@v3.3.1...v4.0.0)

---
updated-dependencies:
- dependency-name: bigdecimal
  dependency-version: 4.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…3.2.0 to 3.3.1 (pmd#6339)

chore(deps): bump org.apache.maven.plugins:maven-release-plugin

Bumps [org.apache.maven.plugins:maven-release-plugin](https://github.com/apache/maven-release) from 3.2.0 to 3.3.1.
- [Release notes](https://github.com/apache/maven-release/releases)
- [Commits](apache/maven-release@maven-release-3.2.0...maven-release-3.3.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-release-plugin
  dependency-version: 3.3.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
….3.1 to 3.4.0 (pmd#6341)

chore(deps): bump org.apache.maven.plugins:maven-source-plugin

Bumps [org.apache.maven.plugins:maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.3.1 to 3.4.0.
- [Release notes](https://github.com/apache/maven-source-plugin/releases)
- [Commits](apache/maven-source-plugin@maven-source-plugin-3.3.1...maven-source-plugin-3.4.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-source-plugin
  dependency-version: 3.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@wener-tiobe wener-tiobe changed the title 37163 cpd 7.21.0 upgrade RM-37163: cpd 7.21.0 upgrade Feb 4, 2026
@wener-tiobe wener-tiobe changed the title RM-37163: cpd 7.21.0 upgrade RM-37163: CPD 7.21.0 upgrade Feb 4, 2026

@brouwers-tiobe brouwers-tiobe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes after merge (in 9b0dc2b) make sense, updating the version for modules exclusive to TIOBE and fixing remaining code issues.

LGTM!

@brouwers-tiobe
brouwers-tiobe self-requested a review February 4, 2026 14:58
@wener-tiobe
wener-tiobe merged commit 6a1959a into tiobe_pmd7 Feb 10, 2026
16 of 17 checks passed
@wener-tiobe
wener-tiobe deleted the 37163-CPD-7.21.0-upgrade branch February 10, 2026 08:12
wener-tiobe pushed a commit that referenced this pull request Oct 16, 2026
* feat(kotlin): add KotlinNodeTypeData with package-private setters and InternalApiBridge

KotlinNodeTypeData stores type-mapper results on AST nodes via DataMap.
Setters are package-private; InternalApiBridge exposes them to callers
outside the types package (e.g. KotlinLanguageProcessor).

* feat(kotlin): add KotlinTypeAnalysisContext and holder with kotlin-type-mapper deps

Add KotlinTypeAnalysisContext (indexes call sites, declarations, type
hierarchy from TypedAst) and KotlinTypeAnalysisContextHolder (global +
thread-local slots). Add kotlin-type-mapper-model and -analyzer deps.

* feat(kotlin): integrate kotlin-type-mapper AST annotation phase

Add KotlinTypeAnnotationVisitor, AnnotationAttributeAnnotator, and
DelegationSpecifierAnnotator to walk parsed ASTs and set @typename /
@ReturnTypeName attributes on declaration nodes. KotlinLanguageProcessor
now runs kotlin-type-mapper before parsing and annotates each file via
InternalApiBridge; falls back gracefully when no auxClasspath is set.

* test(kotlin): expand KotlinTypeAnnotationVisitorTest to full visitor coverage

9 tests covering all node types with specific type assertions:
PropertyDeclaration, FunctionDeclaration, CatchBlock, ForStatement (loop var
+ collection param), ClassParameter, ClassDeclaration (simple name without
package; FQN with package declaration), annotation FQN. Uses
KotlinParsingHelper for production-like parsing.

* fix(kotlin): upgrade ktm to 0.5.1, fix NPE, add missing tests

- Upgrade kotlin-type-mapper deps from 0.5.1-SNAPSHOT to 0.5.1
- Add delegation specifier tests (superclass + interface) to KotlinTypeAnnotationVisitorTest
- Add KotlinAuxClasspathIntegrationTest: end-to-end auxClasspath flow
- Remove KotlinNodeTypeDataTest.typeInfoAvailableFalseWhenNotSet (always failed)
- Add KotlinTypeAnalysisContextHolder.clear() to test teardown
- Add kotlin-type-mapper attribution to kotlin.md docs
- Fix NPE in KotlinAuxClasspathResolver when path has no filename component

* refactor(kotlin): move KotlinTypeAnalysisContext to rule.internal package

Was in rule.xpath.internal, implying XPath-only use. Both classes are
general infrastructure usable by Java-based rules too. Move to rule.internal,
add @experimental @SInCE 7.27.0, add japicmp exclusion for new package.

* refactor(kotlin): extract analyzeAndBuildVisitor to remove duplication

runTypeAnalysis() and runSingleFileAnalysis() shared identical core logic:
fromSources, context creation, setGlobal/clearGlobal. Extract to private
analyzeAndBuildVisitor(); callers add context-specific debug logging.

* feat(kotlin): upgrade ktm to 0.6.0-SNAPSHOT, use resolveAbsolutePath (#7)

Use TypedAstAccessorsKt.hasSourceRoot(ast) to explicitly distinguish
disk-based analysis (real abs path available) from in-memory analysis
(fromSources, sourceRoot is ""). For in-memory analysis, only the
basename is indexed — no bogus "/" + relativePath key is created.
For disk analysis, TypedAstAccessorsKt.resolveAbsolutePath(ast, file)
provides the canonical abs path.

Document that the basename index is an intentional fallback for cases
where PMD paths differ from ktm paths, and that it is inherently
ambiguous when multiple files share the same filename across packages.

* refactor(kotlin): store TypedAst in context, delegate isSubtypeOf to ktm (#8)

Store TypedAst in KotlinTypeAnalysisContext and delegate isSubtypeOf() to
TypedAstHierarchyQueriesKt.isSubtypeOf(). Removes the separate typeHierarchy
field; getTypeHierarchy() now delegates to typedAst.getTypeHierarchy().
The empty context (null typedAst) falls back to name-equivalence only.

Note: ktm#20 filed to add a cached upward-BFS variant for better per-node
rule evaluation performance.

* docs+test(kotlin): document endLine/endColumn span semantics from ktm 0.6.0 (#9)

- Document ktm 0.6.0 line semantics in callSitesAt/callSitesInRange javadoc:
  CallSiteAst.line = callee-name token; endLine/endColumn now available.
- Add compilation-check test asserting getEndLine() >= 0 is readable.
- Add 5 line-number-sensitive tests to KotlinTypeAnnotationVisitorTest covering
  multiline functions, multiple annotations on separate lines, leading blank lines,
  lambdas, and chained calls; each asserts the exact PMD beginLine.
- Document the +/-1 fallback in both lookupByLine and lookupWithFallback: needed
  when ktm reports the annotation line but PMD reports the keyword line.

* feat(kotlin): expose callsOnReceiver/callsReturning delegation from ktm 0.6.0 (#10)

Add callsOnReceiver, callsOnReceiverSubtype, callsReturning, callsReturningSubtype
to KotlinTypeAnalysisContext, delegating to TypedAstCallQueriesKt. These methods use
the dispatchReceiverType and extensionReceiverType fields introduced in CallSiteAst 0.6.0.
Add note to class Javadoc that ktm records concrete expanded types (not alias names).
Tests verify dispatchReceiverType is non-null for method calls and that both
callsOnReceiver and callsReturning find expected call sites.

* perf(kotlin): use isSubtypeOfUpward for O(ancestors) hierarchy check (ktm pmd#20)

Switch isSubtypeOf delegation from isSubtypeOf (downward BFS over all subtypes)
to isSubtypeOfUpward (upward walk of actual's supertypes, O(ancestors ~3-10)).
Also gains Object/Any short-circuit added in the same ktm PR pmd#21.

* refactor(kotlin): defer call-site queries, use TypedAst direct API (ktm pmd#22/pmd#23)

- Remove callsOnReceiver/callsOnReceiverSubtype/callsReturning/callsReturningSubtype
  from KotlinTypeAnalysisContext; deferred to add-kotlin-typealias-support branch
  alongside constructorCallsOf support (ktm pmd#22)
- Use TypedAst.hasSourceRoot() and TypedAst.resolveAbsolutePath(FileAst) directly
  instead of TypedAstAccessorsKt static dispatch (ktm pmd#23)
- Add missing @experimental + @experimental javadoc on KotlinTypeAnnotationVisitor
- Add missing @experimental javadoc on KotlinTypeAnalysisContext/Holder

* chore(kotlin): upgrade kotlin-type-mapper to 0.6.0 release

* refactor(kotlin): simplify KotlinParser usage in annotators

* Refactor Kotlin type-awareness flow and tighten Kotlin checks

* Warn once for missing Kotlin aux classpath

* docs(kotlin): note XPath/designer type attr exposure deferred to follow-up

* fix(kotlin): address trivial review comments from adangel

- pom.xml: extract kotlin.type.mapper.version property
- release_notes.md: simplify XPath/Designer limitation note
- KotlinLanguageProcessor: fix @SInCE to 7.25.0; use direct KtKotlinFile
  cast in parser lambda instead of instanceof check + debug log
- KotlinTypeAwarenessSupport: tighten annotateIfPossible to KtKotlinFile;
  remove try-catch in analyzeAndBuildVisitor (fail fast)
- KotlinTypeAnnotationVisitor: tighten annotate() to KtKotlinFile
- KotlinNodeTypeData + InternalApiBridge: tighten isTypeInfoAvailable /
  setTypeInfoAvailable to KtKotlinFile
- AnnotationAttributeAnnotator: use .children().first() for params node;
  throw on param count mismatch; rethrow IndexOutOfBoundsException with
  AssertionUtil.contexted(); remove unused LOG
- DelegationSpecifierAnnotator: rethrow IndexOutOfBoundsException with
  AssertionUtil.contexted(); remove unused LOG

* refactor(kotlin): remove KotlinTypeAnalysisContextHolder static state

Replace static GLOBAL_CONTEXT/THREAD_CONTEXT fields with per-file root-node
storage. KotlinTypeAnalysisContext is now stored on each KtKotlinFile via
KotlinNodeTypeData (new ANALYSIS_CONTEXT_KEY), stamped by
KotlinTypeAwarenessSupport.annotateIfPossible() after annotation completes.

- KotlinNodeTypeData: add getAnalysisContext/setAnalysisContext(KtKotlinFile)
- InternalApiBridge: expose setAnalysisContext bridge method
- KotlinTypeAwarenessSupport: hold KotlinTypeAnalysisContext as instance
  AtomicReference; set on root node per file; remove ContextHolder calls
- Delete KotlinTypeAnalysisContextHolder (static state gone)
- Delete KotlinTypeXPathTestHelper (only existed to inject into holder)
- KotlinTypeAnalysisContextTest: build context directly in @beforeeach;
  remove two holder-specific tests (holder no longer exists)

XPath functions (future): retrieve context via
KotlinNodeTypeData.getAnalysisContext(root) instead of the static holder.

* refactor(kotlin): split AnnotationAttributeAnnotator into two classes

Extract function-parameter type annotation into a dedicated class,
separating the two unrelated responsibilities.

- New FunctionParameterAnnotator: setFunctionParameterTypes +
  annotateParameterNodes (moved verbatim from AnnotationAttributeAnnotator)
- AnnotationAttributeAnnotator: annotation FQN logic only; remove
  KtFunctionDeclaration, KtFunctionValueParameters, ParameterAst imports;
  update javadoc
- KotlinTypeAnnotationVisitor: call FunctionParameterAnnotator instead of
  AnnotationAttributeAnnotator for parameter types; update javadoc

* refactor(kotlin): rename AnnotationAttributeAnnotator -> AnnotationFqnAnnotator

Avoids double use of "annotation" (Kotlin @annotation concept vs. "annotates
the AST"). Also rename setAnnotationAttributes -> setAnnotationFqns for
consistency with the class name.

* refactor(kotlin): KotlinTypeAnnotationVisitor: use KotlinTypeAnalysisContext instead of TypedAst

Eliminate the duplicate declaration index built inside the visitor.
KotlinTypeAnalysisContext already indexes by abs path, basename, .kt
extension fallback, and +/-1 line tolerance via declarationsAt().

- Constructor: TypedAst -> KotlinTypeAnalysisContext; drop byFilename field
- annotate(): remove filename extraction + byFilename lookup; delegate
  directly to AnnotatingVisitor(ctx, absPath)
- AnnotatingVisitor: take (ctx, absPath); call ctx.declarationsAt(absPath, line)
  instead of lookupWithFallback(byLine, line)
- Remove lookupWithFallback static method (superseded by ctx.declarationsAt)
- Remove now-unused imports: File, ArrayList, Collections, HashMap, Map,
  FileAst, TypedAst
- KotlinTypeAwarenessSupport: pass ctx (not ast) to visitor constructor

* fix(kotlin): use ktm fromPaths for disk files; fix AtomicRef race (items 5+6)

Item 5 — memory: KotlinTypeAwarenessSupport.prepare() now passes List<Path> to
KotlinTypeMapper.fromPaths() when all source files are on disk. KTM reads the
files itself, so source strings are not duplicated between PMD's TextFile cache
and the analyser — halves peak memory for disk-backed analysis runs. Designer /
in-memory files fall back to the existing fromSources(Map<String,String>) path.

Item 6 — race: annotateIfPossible() single-file branch previously read back
analysisContext.get() after runSingleFileAnalysis() set it. A concurrent
Designer parse could race between the set and the re-read, stamping the wrong
context on the root node. Fixed by exposing getContext() on
KotlinTypeAnnotationVisitor and using the visitor's own ctx directly.

Also bumps kotlin-type-mapper dependency to 0.6.1-SNAPSHOT (adds fromPaths).

* chore(kotlin): bump kotlin-type-mapper to 0.6.1 (released)

* refactor(kotlin): remove basename fallback from analysis context index

Index by canonical abs path (disk) or relativePath (in-memory) only.
Basename fallback was never needed: disk paths always match (PMD passes
the same paths it got from FS), and in-memory uses the fromSources key
directly. Add fail-fast clash detection so two files mapping to the same
index key throw immediately instead of silently corrupting results.

* refactor(kotlin): store annotation FQNs as List<String> instead of comma-joined String

Addresses adangel review suggestion. SimpleDataKey<List<String>> stores
the list directly; no join on set, no split on get. Remove stale
InternalApiBridge.setAnnotationFqNames bridge method (unused).

* refactor(kotlin): remove sanitizeKtFilename workaround; use absPath directly

sanitizeKtFilename silently masked two bugs:
- buildSourceMap keyed by getFileName() (basename) while annotate()
  looked up by getAbsolutePath() — only worked via now-removed basename fallback
- single-file path used a sanitized name inconsistently

Fix: buildSourceMap keys by getAbsolutePath(), single-file path uses
absPath as-is on both sides. Keys always match without fallback.
Add validateKotlinPath() with fail-fast throw for null/empty absPath.

* docs(kotlin): update comments — Designer fixed in pmd-designer#376, in-memory fallback is for test framework only

* [test] use snippet.<ext> filename in RuleTst instead of bare "file"

Gives the virtual in-memory file a proper language extension so that
kotlin-type-mapper (and other language processors) can identify the
language from the filename during the pre-analysis prepare() step.

Suggested by adangel in PR pmd#6795 review.

* [kotlin] remove AtomicReference and single-file fallback from KotlinTypeAwarenessSupport

Replace AtomicReference fields with volatile fields — lifecycle guarantees
happen-before between prepare() and annotateIfPossible(), volatile ensures
visibility across threads.

Remove the 'if (visitor == null)' single-file workaround from annotateIfPossible().
Fix the last bypass caller instead: KotlinParsingHelper now overrides doParse()
to call prepareForSingleDocument() before parsing, so KotlinTypeAnnotationVisitorTest
tests go through a proper prepare() step without needing a full PmdAnalysis run.

RuleTst.java was fixed in the previous commit. Designer bypass is addressed
by adangel's pmd-designer#376.

Suggested by adangel in PR pmd#6795 review.

* [kotlin] use plain fields instead of volatile in KotlinTypeAwarenessSupport

Plain fields are sufficient: prepare() completes before launchAnalysis()
submits file-processing tasks to threads, so JMM executor task submission
guarantees visibility. Avoids AvoidUsingVolatile PMD dogfood violation.

* [kotlin] Simplifications and fixes from review

- moving KotlinTypeAnnotationVisitor into internal package
- simplifying implementations of AnnotationFqnAnnotator, DelegationSpecifierAnnotator and FunctionParameterAnnotator
- Correcting `@since` javadoc tags
- add all internal packages to japicmp

* [doc] Release notes (pmd#6795)

---------

Co-authored-by: Andreas Dangel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.