- A misconfiguration of Antlr4 produced an auxiliary gramma
(UnicodeClasses), that was imported into the main kotlin grammar,
to produce it's own Lexer, which was never used.
- We no longer produce that Lexer, properly moving imports to the
standard directory for that.
- We manually copy a generated version for API compatibility, flagging
it as both Generated and Deprecated for removal in PMD 8
- Renames the rule to `QueueableWithoutFinalizer` to be more neutral.
- Provides a more robust description.
- Provides a more succinct error message.
- Provides a positive sample for the documentation .
When creating a LazyClassSignature or LazyMethodType, make sure
to parse the number of type parameters eagerly, so that AstDisambiguationPass
can get this number without triggering additional parsing.
Bump webrick in /docs in the all-gems group across 1 directory
Bumps the all-gems group with 1 update in the /docs directory: [webrick](https://github.com/ruby/webrick).
Updates `webrick` from 1.8.2 to 1.9.0
- [Release notes](https://github.com/ruby/webrick/releases)
- [Commits](https://github.com/ruby/webrick/compare/v1.8.2...v1.9.0)
---
updated-dependencies:
- dependency-name: webrick
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: all-gems
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Bump bundler from 2.5.3 to 2.5.22
- Bump activesupport from 7.2.1 to 7.2.2
- Bump execjs from 2.9.1 to 2.10.0
- Bump faraday from 2.11.0 to 2.12.0
- Bump i18n from 1.14.5 to 1.14.6
- Bump json from 2.7.2 to 2.7.5
- Bump logger from 1.6.0 to 1.6.1
- Bump rexml from 3.3.6/3.3.8 to 3.3.9
- Bump rufus-scheduler from 3.9.2 to 3.9.2
- Fixes https://github.com/pmd/pmd/security/dependabot/69
- Fixes https://github.com/pmd/pmd/security/dependabot/70
- The package is no longer antlr4, but ast, as is in all other modules
- We keep a deprecated proxy for backwards compatibility
- We annotate the generated classes as such to ignore them from
coverage reports
- for java 17+, there is public API to get the console encoding
-> no problem
- for older java versions, try to use system property
sun.jnu.encoding if it exists
- only then use the fall-backs with illegal reflective access
to private fields/methods on java.io.Console
- Also avoid using reflection utils from apache commons, instead
use reflection directly. The illegal access warnings are then
properly reported against our class
net.sourceforge.pmd.ant.Formatter.
Fixes#1860
- Updated XPath rule to include both primitive and wrapper class:
(PrimitiveType[@Kind = 'boolean'] or ClassType[pmd-java:typeIs('java.lang.Boolean')])
- Added test cases to ensure that methods returning are also flagged correctly.
- Ensured the rule enforces consistent method naming for both primitive and wrapper types.
Rename rule from NonCaseLabelInSwitchStatement
- as it applies to both switch statements and switch expressions
- extend the test cases to cover new java syntax
- as it applies to both switch statements and switch expressions
- extend the test cases to cover new java syntax
Note: For patterns in switch, the java compiler already makes sure, that
default is the last case.
RuleReference#getOverriddenPropertyDescriptors should behave
consistent to #getOverriddenPropertiesByPropertyDescriptor.
RuleSetWriter needs to make sure to
export only the values for properties
of rule references.
Fixes#5222
- We don't test it directly, nor is it our job
- A bad grammar won't be processed, or fail in subtle ways only
detectable in specific tests on the AST (which is included)
Processing errors might contain inside their details
message a CDATA section. This is output itself as
a CDATA section, but XMLStreamWriter#writeCData doesn't
escape it automatically - it just outputs the string
as is. This results in invalid XML.
Fixes#5059
- Improving the constant folder allows other rules to work better
- Fixes#3602
- Curiously, InefficientStringBuffering has been broken since PMD 7.0.0
(regression introduced in #3113)
- Tidy up the code, the fact the `getLogLevelName` was cheating and
returning null when it considered a log to be safe was making the
code harder to think about
- new JModuleSymbol
- UnnecessaryImportRule also supports module imports
- module-info.class can be loaded by ClasspathClassLoader
- Support annotations on modules
- Verify that exported packages are loaded
Only the grandchildren of a trigger block were ending up in the tree,
but the direct children of triggerBlock were missing, e.g.
ForLoopStatement. This caused OperationWithHighCostInLoop to not
find the loop anymore in triggers.
This will probably fix other false negatives in triggers in
other rules as well.
Fixes#5139
@@ -7,12 +7,12 @@ By participating in this project you agree to abide by its terms.
You can find the code of conduct in the file [code_of_conduct.md](code_of_conduct.md).
| NB: the rule designer is developed over at [pmd/pmd-designer](https://github.com/pmd/pmd-designer). Please refer to the specific [contributor documentation](https://github.com/pmd/pmd-designer/blob/master/CONTRIBUTING.md) if your issue, feature request or PR touches the designer. |
| --- |
| NB: the rule designer is developed over at [pmd/pmd-designer](https://github.com/pmd/pmd-designer). Please refer to the specific [contributor documentation](https://github.com/pmd/pmd-designer/blob/main/CONTRIBUTING.md) if your issue, feature request or PR touches the designer. |
* Please create your pull request against the `master` branch. We will rebase/merge it to the maintenance
* Please create your pull request against the `main` branch. We will rebase/merge it to the maintenance
branches, if necessary.
* We are using [checkstyle](http://checkstyle.sourceforge.net/) to enforce a common code style.
@@ -36,7 +36,7 @@ When filing a bug report, please provide as much information as possible, so tha
There is some documentation available under <https://docs.pmd-code.org/latest>. Feel free to create a bug report if
documentation is missing, incomplete or outdated. See [Bug reports](#bug-reports).
The documentation is generated as a Jekyll site, the source is available at: <https://github.com/pmd/pmd/tree/master/docs>. You can find build instructions there.
The documentation is generated as a Jekyll site, the source is available at: <https://github.com/pmd/pmd/tree/main/docs>. You can find build instructions there.
For more on contributing documentation check <https://docs.pmd-code.org/latest/pmd_devdocs_writing_documentation.html>
## Questions
@@ -53,8 +53,8 @@ There are various channels, on which you can ask questions:
PMD uses [checkstyle](http://checkstyle.sourceforge.net/) to enforce a common code style.
See [pmd-checkstyle-config.xml](https://github.com/pmd/build-tools/blob/master/src/main/resources/net/sourceforge/pmd/pmd-checkstyle-config.xml) for the configuration and
[the eclipse configuration files](https://github.com/pmd/build-tools/tree/master/eclipse) that can
See [pmd-checkstyle-config.xml](https://github.com/pmd/build-tools/blob/main/src/main/resources/net/sourceforge/pmd/pmd-checkstyle-config.xml) for the configuration and
[the eclipse configuration files](https://github.com/pmd/build-tools/tree/main/eclipse) that can
[](https://app.gitter.im/#/room/#pmd_pmd:gitter.im?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
. And example is [`SwiftInnerNode`](https://github.com/pmd/pmd/blob/master/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftInnerNode.java).
. And example is [`SwiftInnerNode`](https://github.com/pmd/pmd/blob/main/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftInnerNode.java).
Note that this language specific inner node is package-private, as it is only the base class for the concrete
nodes generated by ANLTR.
* a language specific root node - this provides the root of the AST and our parser will return
subtypes of this node. The root node itself is a "InnerNode".
See [`SwiftRootNode`](https://github.com/pmd/pmd/blob/master/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftRootNode.java).
See [`SwiftRootNode`](https://github.com/pmd/pmd/blob/main/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftRootNode.java).
Note that this language specific root node is package-private, as it is only the base class for the concrete
node generated by ANLTR.
* a language specific terminal node.
See [`SwiftTerminalNode`](https://github.com/pmd/pmd/blob/master/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftTerminalNode.java).
See [`SwiftTerminalNode`](https://github.com/pmd/pmd/blob/main/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftTerminalNode.java).
* a language specific error node.
See [`SwiftErrorNode`](https://github.com/pmd/pmd/blob/master/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftErrorNode.java).
See [`SwiftErrorNode`](https://github.com/pmd/pmd/blob/main/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftErrorNode.java).
* a language name dictionary. This is used to convert ANTLR node names to useful XPath node names.
See [`SwiftNameDictionary'](https://github.com/pmd/pmd/blob/master/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftNameDictionary.java).
See [`SwiftNameDictionary'](https://github.com/pmd/pmd/blob/main/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftNameDictionary.java).
* Once these base classes exist, you need to change the ANTLR grammar to add additional members via `@parser::members`
* Define a package private field `DICO` which creates a new instance of your language name dictionary using the
vocabulary from the generated parser (`VOCABULARY`).
* Define two additional methods to help converting the ANTLR context objects into PMD AST nodes.
The methods are abstract in [`AntlrGeneratedParserBase`](https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrGeneratedParserBase.java)
The methods are abstract in [`AntlrGeneratedParserBase`](https://github.com/pmd/pmd/blob/main/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrGeneratedParserBase.java)
and need to be implemented here for the concrete language: `createPmdTerminal()` and `createPmdError()`.
* In order for the generated code to match and use our custom classes, we have a common ant script, that fiddles with
the generated code. The ant script is [`antlr4-wrapper.xml`](https://github.com/pmd/pmd/blob/master/antlr4-wrapper.xml)
the generated code. The ant script is [`antlr4-wrapper.xml`](https://github.com/pmd/pmd/blob/main/antlr4-wrapper.xml)
and does not need to be adjusted - it has plenty of parameters that can be configured.
The ant script is added in the language module's `pom.xml` where the parameters are set (e.g. name of root name
class). Have a look at Swift's example: [`pmd-swift/pom.xml`](https://github.com/pmd/pmd/blob/master/pmd-swift/pom.xml).
class). Have a look at Swift's example: [`pmd-swift/pom.xml`](https://github.com/pmd/pmd/blob/main/pmd-swift/pom.xml).
* You can add additional methods in your "InnerNode" (e.g. `SwiftInnerNode`) that are available on all nodes.
But on most cases you won't need to do anything.
@@ -115,31 +115,31 @@ definitely don't come for free. It is much effort and requires perseverance to i
have the parser generated.
* The generated code will be placed under `target/generated-sources/antlr4` and will not be committed to
source control.
* You should review [`pmd-swift/pom.xml`](https://github.com/pmd/pmd/blob/master/pmd-swift/pom.xml).
* You should review [`pmd-swift/pom.xml`](https://github.com/pmd/pmd/blob/main/pmd-swift/pom.xml).
### 5. Create a TokenManager
* This is needed to support CPD (copy paste detection)
* We provide a default implementation using [`AntlrTokenManager`](https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrTokenManager.java).
* We provide a default implementation using [`AntlrTokenManager`](https://github.com/pmd/pmd/blob/main/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrTokenManager.java).
* You must create your own "AntlrCpdLexer" such as we do with
If you don't need a custom token filter, you don't need to override the method. It returns the default
`AntlrTokenFilter` which doesn't filter anything.
### 6. Create a PMD parser “adapter”
* Create your own parser, that adapts the ANLTR interface to PMD's parser interface.
* We provide a [`AntlrBaseParser`](https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrBaseParser.java)
* We provide a [`AntlrBaseParser`](https://github.com/pmd/pmd/blob/main/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrBaseParser.java)
implementation that you need to extend to create your own adapter as we do with
* Now you need to create your version handler, as we did with [`SwiftHandler`](https://github.com/pmd/pmd/blob/master/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/SwiftHandler.java).
* Now you need to create your version handler, as we did with [`SwiftHandler`](https://github.com/pmd/pmd/blob/main/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/SwiftHandler.java).
* This class is sort of a gateway between PMD and all parsing logic specific to your language.
* For a minimal implementation, it just needs to return a parser *(see step #6)*.
* It can be used to provide other features for your language like
@@ -154,15 +154,15 @@ definitely don't come for free. It is much effort and requires perseverance to i
* A parser visitor adapter is not needed anymore with PMD 7. The visitor interface now provides a default
implementation.
* The visitor for ANTLR based AST is generated along the parser from the ANTLR grammar file. The
base interface for a visitor is [`AstVisitor`](https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstVisitor.java).
base interface for a visitor is [`AstVisitor`](https://github.com/pmd/pmd/blob/main/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstVisitor.java).
* The generated visitor class for Swift is called `SwiftVisitor`.
* In order to help use this visitor later on, a base visitor class should be created.
See [`SwiftVisitorBase`](https://github.com/pmd/pmd/blob/master/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftVisitorBase.java)
See [`SwiftVisitorBase`](https://github.com/pmd/pmd/blob/main/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/ast/SwiftVisitorBase.java)
as an example.
### 9. Make PMD recognize your language
* Create your own subclass of `net.sourceforge.pmd.lang.impl.SimpleLanguageModuleBase`, see Swift as an example:
* Add for each version of your language a call to `addVersion` in your language module’s constructor.
Use `addDefaultVersion` for defining the default version.
* You’ll need to refer the language version handler created in step #7.
@@ -172,9 +172,9 @@ definitely don't come for free. It is much effort and requires perseverance to i
### 10. Create an abstract rule class for the language
* You need to create your own abstract rule class in order to interface your language with PMD's generic rule
execution.
* See [`AbstractSwiftRule`](https://github.com/pmd/pmd/blob/master/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/AbstractSwiftRule.java) as an example.
* See [`AbstractSwiftRule`](https://github.com/pmd/pmd/blob/main/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/AbstractSwiftRule.java) as an example.
@@ -20,7 +20,7 @@ easy to implement the Tokenizer interface.
Use the following guide to set up a new language module that supports CPD.
1. Create a new Maven module for your language. You can take [the Golang module](https://github.com/pmd/pmd/tree/master/pmd-go/pom.xml) as an example.
1. Create a new Maven module for your language. You can take [the Golang module](https://github.com/pmd/pmd/tree/main/pmd-go/pom.xml) as an example.
- Make sure to add your new module to the parent pom as `<module>` entry, so that it is built alongside the
other languages.
- Also add your new module to the dependencies list in "pmd-languages-deps/pom.xml", so that the new language
@@ -28,7 +28,7 @@ Use the following guide to set up a new language module that supports CPD.
2. Implement a {% jdoc core::cpd.CpdLexer %}.
- For Antlr grammars you can take the grammar from [antlr/grammars-v4](https://github.com/antlr/grammars-v4) and place it in `src/main/antlr4` followed by the package name of the language. You then need to call the appropriate ant wrapper to generate
the lexer from the grammar. To do so, edit `pom.xml` (eg like [the Golang module](https://github.com/pmd/pmd/tree/master/pmd-go/pom.xml)).
the lexer from the grammar. To do so, edit `pom.xml` (eg like [the Golang module](https://github.com/pmd/pmd/tree/main/pmd-go/pom.xml)).
Once that is done, `mvn generate-sources` should generate the lexer sources for you.
You can now implement a CpdLexer, for instance by extending {% jdoc core::cpd.impl.AntlrCpdLexer %}. The following reproduces the Go implementation:
@@ -49,7 +49,7 @@ Use the following guide to set up a new language module that supports CPD.
change each token e.g. into uppercase, so that CPD sees the same strings and can find duplicates even when
the casing differs. See {% jdoc tsql::lang.tsql.cpd.TSqlCpdLexer %} for an example. You will also need a
"CaseChangingCharStream", so that antlr itself is case-insensitive.
- For JavaCC grammars, place your grammar in `etc/grammar` and edit the `pom.xml` like the [Python implementation](https://github.com/pmd/pmd/blob/master/pmd-python/pom.xml) does.
- For JavaCC grammars, place your grammar in `etc/grammar` and edit the `pom.xml` like the [Python implementation](https://github.com/pmd/pmd/blob/main/pmd-python/pom.xml) does.
You can then subclass {% jdoc core::cpd.impl.JavaccCpdLexer %} instead of AntlrCpdLexer.
- If your JavaCC based language is case-insensitive (option `IGNORE_CASE=true`), then you need to implement
{%jdoc core::lang.ast.impl.javacc.JavaccTokenDocument.TokenDocumentBehavior %}, which can change each token
@@ -82,7 +82,7 @@ If your language only supports CPD, then you can subclass {% jdoc core::lang.imp
At this point the new language module should be available in {% jdoc core::lang.LanguageRegistry#CPD %} and usable by CPD like any other language.
4. Update the test that asserts the list of supported languages by updating the `SUPPORTED_LANGUAGES` constant in [BinaryDistributionIT](https://github.com/pmd/pmd/blob/master/pmd-dist/src/test/java/net/sourceforge/pmd/dist/BinaryDistributionIT.java).
4. Update the test that asserts the list of supported languages by updating the `SUPPORTED_LANGUAGES` constant in [BinaryDistributionIT](https://github.com/pmd/pmd/blob/main/pmd-dist/src/test/java/net/sourceforge/pmd/dist/BinaryDistributionIT.java).
5. Add some tests for your CpdLexer by following the [section below](#testing-your-implementation).
@@ -119,7 +119,7 @@ of {% jdoc core::cpd.CpdCapableLanguage#createCpdTokenizer(core::lang.LanguagePr
To implement simple token filtering, you can use {% jdoc core::cpd.impl.BaseTokenFilter %}
as a base class, or another base class in {% jdoc_package core::cpd.impl %}.
Take a look at the [Kotlin token filter implementation](https://github.com/pmd/pmd/blob/master/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/cpd/KotlinCpdLexer.java), or the [Java one](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/cpd/JavaCpdLexer.java).
Take a look at the [Kotlin token filter implementation](https://github.com/pmd/pmd/blob/main/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/cpd/KotlinCpdLexer.java), or the [Java one](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/cpd/JavaCpdLexer.java).
It includes all the sub section, which can be found in the includes directory [_includes/](https://github.com/pmd/pmd.github.io/tree/main/_includes)
* The latest PMD version is configured in `_config.yml` and the variables `site.pmd.latestVersion` are used
e.g. in [_includes/home.html](https://github.com/pmd/pmd.github.io/blob/master/_includes/home.html).
e.g. in [_includes/home.html](https://github.com/pmd/pmd.github.io/blob/main/_includes/home.html).
* Blog - aka "News": <https://pmd.github.io/news/>
* This is a section on main page. It shows the 5 latest news. See [_includes/news.html](https://github.com/pmd/pmd.github.io/blob/master/_includes/news.html).
* This is a section on main page. It shows the 5 latest news. See [_includes/news.html](https://github.com/pmd/pmd.github.io/blob/main/_includes/news.html).
* There is also a sub page "news" which lists all news.
File diff suppressed because it is too large.
Load diff
Loaded 30 of 458 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.