a lot of random changes

This commit is contained in:
Alex Fedulov Local user 2024-11-22 14:59:02 +05:00
parent 0fdeb67010
commit a73f81aec4
425 changed files with 39452 additions and 1630 deletions

View File

@ -1,47 +1,83 @@
# PMD CI Scripts
This folder contains scripts used for CI, that are PMD specific.
It uses the common scripts from [build-tools](https://github.com/pmd/build-tools).
Added line: 8803
Added line: 397
Added line: 2389
## .ci/files/public-env.gpg
Added line: 2050
This files contains the following environment variables:
Added line: 893
* DANGER_GITHUB_API_TOKEN: Token for danger to add comments to PRs as <https://github.com/pmd-test>.
Added line: 7092
Added line: 1776
Added line: 1458
Added line: 371
The token needs the scope "public_repo". Note: The default GITHUB_TOKEN can't be used, because
danger runs in pull request builds from fork and the default GITHUB_TOKEN has read-only access there
Added line: 2166
and can't write comments. Therefore the personal access token of the bot account "pmd-test" is used.
pmd-test has no commit permissions, but can comment on any public repo, including pmd/pmd.
Added line: 9706
* PMD_CI_CHUNK_TOKEN: Token for uploading reports to chunk.io
Added line: 2997
Added line: 7686
The file is encrypted, so that the tokens are not automatically disabled when github detects them
in clear text.
**Decrypting**:
Added line: 2218
Added line: 5258
gpg --batch --yes --decrypt --passphrase="GnxdjywUEPveyCD1RLiTd7t8CImnefYr" \
Added line: 6105
--output .ci/files/public-env .ci/files/public-env.gpg
Added line: 2860
**Encrypting**:
gpg --batch --symmetric --cipher-algo AES256 \
Added line: 7658
--armor --passphrase="GnxdjywUEPveyCD1RLiTd7t8CImnefYr" \
--output .ci/files/public-env.gpg .ci/files/public-env
## Local tests with docker
Added line: 2256
Added line: 7698
Using the same docker container as described in [build-env @ build-tools](https://github.com/pmd/build-tools).
Added line: 4848
Added line: 8614
### Testing a push build (snapshot)
Added line: 6717
Added line: 6493
Added line: 2139
Added line: 6240
Start docker without binding to local directory, so that we can do a fresh checkout
Added line: 9468
$ docker run \
Added line: 860
--interactive \
Added line: 7791
--tty \
Added line: 7787
--name pmd-build-env_pmd \
Added line: 1200
Added line: 966
Added line: 8897
Added line: 3773
pmd-build-env:latest
Added line: 7538
Added line: 1343
Added line: 2876
```
export LANG=en_US.UTF-8
export PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/main/scripts
@ -50,40 +86,61 @@ export PMD_CI_SECRET_PASSPHRASE="xyz"
export PMD_CI_DEBUG=true
MAIN_BRANCH="main"
Added line: 6291
eval $(~/create-gh-actions-env.sh push pmd/pmd $MAIN_BRANCH)
Added line: 7570
cd /workspaces/pmd
rmdir pmd && mkdir pmd
cd pmd
Added line: 4917
Added line: 3164
git init
git remote add origin https://github.com/pmd/pmd
Added line: 1903
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/${MAIN_BRANCH}:refs/remotes/origin/${MAIN_BRANCH}
git checkout --progress --force -B ${MAIN_BRANCH} refs/remotes/origin/${MAIN_BRANCH}
Added line: 5869
Added line: 5152
f=check-environment.sh; \
mkdir -p .ci && \
Added line: 2051
Added line: 1620
( [ -e .ci/$f ] || curl -sSL "${PMD_CI_SCRIPTS_URL}/$f" > ".ci/$f" ) && \
chmod 755 .ci/$f && \
.ci/$f
.ci/build.sh
Added line: 9212
Added line: 7311
Added line: 1160
```
Added line: 6015
### Testing a pull request
Added line: 9301
Same as the above, but this line changes:
```
eval $(~/create-gh-actions-env.sh pull_request pmd/pmd $MAIN_BRANCH)
Added line: 6346
```
Added line: 8915
Added line: 4922
Maybe update `/workspaces/event.json` to fill in a real pull request number, so that
Added line: 7442
danger can comment the correct PR.
Added line: 5479
And the checkout must be different. Example for PR 3220:
Added line: 7539
Added line: 7078
```
Added line: 4982
PMD_CI_PULL_REQUEST_NUMBER=3220
cd /workspace/pmd
rmdir pmd && mkdir pmd
@ -93,13 +150,25 @@ git init
git remote add origin https://github.com/pmd/pmd
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/pull/${PMD_CI_PULL_REQUEST_NUMBER}/merge:refs/remotes/pull/${PMD_CI_PULL_REQUEST_NUMBER}/merge
git checkout --progress --force refs/remotes/pull/${PMD_CI_PULL_REQUEST_NUMBER}/merge
Added line: 6442
Added line: 5540
Added line: 9041
Added line: 4588
```
### Forked build
Added line: 5245
Added line: 5591
A build executing on a forked repository.
Added line: 5218
Added line: 2624
```
Added line: 7960
Added line: 6452
Added line: 997
$(~/create-gh-actions-env.sh push adangel/pmd $MAIN_BRANCH)
Added line: 695
```
@ -110,39 +179,60 @@ export LANG=en_US.UTF-8
export PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/main/scripts
export PMD_CI_SECRET_PASSPHRASE="xyz"
Added line: 9624
export PMD_CI_DEBUG=true
Added line: 9218
TAG_NAME=pmd_releases/6.33.0
Added line: 9734
eval $(~/create-gh-actions-env.sh push pmd/pmd refs/tags/$TAG_NAME)
Added line: 455
Added line: 3217
Added line: 157
Added line: 7411
rmdir pmd && mkdir pmd
cd pmd
Added line: 2538
Added line: 6507
git init
Added line: 6832
Added line: 7703
git remote add origin https://github.com/pmd/pmd
Added line: 3659
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/tags/$TAG_NAME:refs/tags/$TAG_NAME
git checkout --progress --force refs/tags/$TAG_NAME
Added line: 4727
Added line: 4641
Added line: 2311
f=check-environment.sh; \
mkdir -p .ci && \
( [ -e .ci/$f ] || curl -sSL "${PMD_CI_SCRIPTS_URL}/$f" > ".ci/$f" ) && \
Added line: 3275
Added line: 5836
chmod 755 .ci/$f && \
.ci/$f
Added line: 3796
Added line: 59
Added line: 7823
Added line: 1286
Added line: 720
Added line: 9688
Added line: 6803
#
# .ci/build.sh
Added line: 9008
Added line: 2611
#
```
Calling `.ci/build.sh` directly would re-release the tag $TAG_NAME - that's why it is commented out.
All the side-effects of a release would be carried out like creating and publishing a release on github,
Added line: 3239
Added line: 9164
Added line: 3855
uploading the release to sourceforge, uploading the docs to docs.pmd-code.org, uploading a
new baseline for the regression tester and so on. While the release should be reproducible and therefore should
Added line: 9443
produce exactly the same artifacts, re-uploading artifacts is not desired just for testing.
Added line: 8770
Note that maven-central would not be changed, since this is skipped via MAVEN_OPTS:
`MAVEN_OPTS` contains `-DskipRemoteStaging=true`, so that no maven artifacts are deployed
@ -156,4 +246,3 @@ Make sure to cleanup after the test, e.g. discard the draft github release.
## Workflow git-repo-sync
Synchronizes the github git repository pmd/pmd on every push to sourceforge.

View File

@ -1,34 +1,123 @@
Added line: 9032
Added line: 4984
Added line: 8296
Added line: 5358
Added line: 3781
Added line: 8576
Added line: 638
---
Added line: 4863
Added line: 4881
Added line: 1053
name: Rule violation (false-positive)
Added line: 6392
Added line: 2892
Added line: 419
Added line: 5445
Added line: 9875
Added line: 2837
Added line: 2727
about: Let us know about a false-positive (a violation is reported on code that is not problematic)
Added line: 2040
labels: 'a:false-positive'
Added line: 4646
Added line: 5328
Added line: 5556
Added line: 1343
Added line: 8597
Added line: 4832
Added line: 6373
Added line: 59
Added line: 9107
Added line: 679
Added line: 7562
Added line: 4826
Added line: 3685
Added line: 3413
---
Added line: 8862
Added line: 3581
Added line: 3115
Added line: 8214
Added line: 8330
Added line: 5011
Added line: 4960
Added line: 5711
Added line: 715
Added line: 5443
<!-- Please, prefix the report title with the language it applies to within brackets, such as [java] or [apex] -->
Added line: 2178
Added line: 3165
Added line: 2575
Added line: 8688
**Affects PMD Version:**
Added line: 3366
Added line: 3430
Added line: 8099
Added line: 1991
**Rule:**
Added line: 812
Added line: 6221
Added line: 8729
Added line: 3231
Added line: 8470
Added line: 782
Added line: 8999
Please provide the rule name and a link to the rule documentation:
Added line: 5171
Added line: 4827
Added line: 9685
Added line: 7949
Added line: 5263
Added line: 4070
Added line: 9530
Added line: 5361
Added line: 8332
Added line: 8267
Added line: 1113
Added line: 5193
Added line: 8746
<https://docs.pmd-code.org/latest/pmd_rules_XXX_XXX.html#XXX>
Added line: 3665
Added line: 5900
**Description:**
Added line: 3935
**Code Sample demonstrating the issue:**
```java
Added line: 1406
Added line: 1622
Added line: 3566
Added line: 9658
Added line: 1428
Added line: 5834
```
Added line: 7530
Added line: 2119
Added line: 9424
Added line: 6322
Added line: 971
Added line: 2904
Added line: 5053
**Expected outcome:**
Added line: 4245
Added line: 7901
Added line: 1581
Added line: 1774
Added line: 4867
PMD reports a violation at line ..., but that's wrong. That's a false positive.
Added line: 1008
Added line: 8833
Added line: 4235
**Running PMD through:** *[CLI | Ant | Maven | Gradle | Designer | Other]*
Added line: 2257
Added line: 250
Added line: 9807
Added line: 2685

View File

@ -1,30 +1,119 @@
---
Added line: 2036
Added line: 4210
Added line: 227
name: Rule violation (false-negative)
Added line: 5393
about: Let us know about a false-negative (no violation is reported on problematic code)
Added line: 3768
Added line: 2929
Added line: 336
Added line: 5100
Added line: 2776
title: ''
labels: 'a:false-negative'
Added line: 4378
Added line: 407
assignees: ''
---
Added line: 9712
Added line: 9804
Added line: 1425
Added line: 5548
Added line: 5560
Added line: 3441
<!-- Please, prefix the report title with the language it applies to within brackets, such as [java] or [apex] -->
Added line: 2963
Added line: 7108
Added line: 2911
**Affects PMD Version:**
Added line: 1130
Added line: 9851
Added line: 5619
Added line: 9719
Added line: 9518
Added line: 3632
**Rule:**
Added line: 9277
Added line: 7944
Added line: 8135
Added line: 3267
Added line: 7738
Added line: 672
Please provide the rule name and a link to the rule documentation:
Added line: 1330
Added line: 6999
Added line: 876
Added line: 9910
Added line: 8195
Added line: 1054
Added line: 8073
Added line: 8012
Added line: 4868
Added line: 8284
<https://docs.pmd-code.org/latest/pmd_rules_XXX_XXX.html#XXX>
Added line: 743
Added line: 7518
Added line: 7900
Added line: 2604
Added line: 1081
Added line: 907
Added line: 6001
Added line: 3968
Added line: 494
Added line: 5240
Added line: 2555
Added line: 3475
**Description:**
Added line: 8125
Added line: 8447
**Code Sample demonstrating the issue:**
Added line: 1790
Added line: 8745
Added line: 1553
```java
Added line: 9167
Added line: 2857
```
**Expected outcome:**
Added line: 6821
Added line: 4778
Added line: 9347
Added line: 1381
Added line: 1941
Added line: 2406
Added line: 667
PMD should report a violation at line ..., but doesn't. This is a false-negative.
Added line: 4537
Added line: 7420
Added line: 1685
Added line: 1244
Added line: 8605
Added line: 2527
Added line: 5885
Added line: 1636
**Running PMD through:** *[CLI | Ant | Maven | Gradle | Designer | Other]*
Added line: 4259
Added line: 2521
Added line: 5929
Added line: 7218
Added line: 532
Added line: 7458
Added line: 6443
Added line: 8367
Added line: 2443
Added line: 877
Added line: 9012
Added line: 2250
Added line: 7945

View File

@ -1,29 +1,118 @@
Added line: 8008
---
Added line: 1876
Added line: 1268
Added line: 3166
Added line: 3540
Added line: 1506
Added line: 4949
Added line: 8344
Added line: 4443
name: New Rule
about: You have an idea for a new rule? Great!
Added line: 1249
Added line: 509
Added line: 7136
Added line: 7138
Added line: 3547
title: ''
Added line: 8854
Added line: 7303
labels: 'a:new-rule'
assignees: ''
Added line: 7663
Added line: 4379
Added line: 3661
Added line: 5641
Added line: 1266
Added line: 2763
Added line: 7480
Added line: 1665
Added line: 7945
Added line: 8173
Added line: 1305
---
Added line: 1184
Added line: 783
Added line: 1036
<!-- Please, prefix the report title with the language it applies to within brackets, such as [java] or [apex] -->
Added line: 1687
**Proposed Rule Name:**
Added line: 9420
Added line: 9768
Added line: 6958
Added line: 3107
Added line: 4488
Added line: 5921
Added line: 8999
Added line: 3663
Added line: 9343
Added line: 8596
Added line: 4528
Added line: 7451
Added line: 9562
Added line: 2129
Added line: 7611
Added line: 3602
Added line: 9038
**Proposed Category:** One of [Best Practices | Code Style | Design | Documentation | Error Prone | Multithreading | Performance | Security]
Added line: 141
Added line: 9794
Added line: 3369
Added line: 9168
Added line: 3697
Added line: 6694
Added line: 691
Added line: 8738
Added line: 9018
Added line: 4391
Added line: 108
Added line: 4367
Added line: 5549
Added line: 6995
Added line: 4529
**Code Sample:** This should include code, that should be flagged by the rule. If possible, the "correct" code
Added line: 9295
Added line: 4422
Added line: 4374
Added line: 8540
Added line: 689
Added line: 5886
Added line: 4050
Added line: 972
Added line: 3942
according to this new rule should also be demonstrated.
Added line: 3608
Added line: 1933
Added line: 2038
Added line: 7483
Added line: 4764
Added line: 8361
Added line: 6882
Added line: 6080
Added line: 4487
**Possible Properties:**
Added line: 5330
Added line: 6096
Added line: 8622
Added line: 4534
Added line: 7766
Added line: 8069
Added line: 6191
Added line: 7601
* Should this rule be customizable via properties?
Added line: 4112
Added line: 3265
Added line: 200
Added line: 6273
Added line: 7004
Added line: 7373

View File

@ -1,20 +1,109 @@
Added line: 6559
Added line: 7645
---
Added line: 7179
Added line: 4967
Added line: 9013
Added line: 7132
Added line: 1160
Added line: 3987
Added line: 7629
Added line: 4406
Added line: 7359
Added line: 930
Added line: 3460
Added line: 64
Added line: 50
Added line: 5031
name: Feature request
Added line: 3860
Added line: 954
Added line: 605
about: Suggest an idea for this project
Added line: 9836
Added line: 7559
Added line: 8444
Added line: 840
title: ''
Added line: 1809
Added line: 5258
Added line: 2334
Added line: 3166
labels: 'an:enhancement'
Added line: 1482
Added line: 4357
Added line: 1404
Added line: 6594
Added line: 4917
Added line: 5823
Added line: 2230
assignees: ''
Added line: 7536
Added line: 5103
Added line: 3902
Added line: 492
Added line: 3161
---
**Is your feature request related to a problem? Please describe.**
Added line: 834
Added line: 2572
Added line: 4912
Added line: 2318
Added line: 22
Added line: 3312
Added line: 8830
Added line: 3142
Added line: 5843
Added line: 4808
Added line: 2269
Added line: 5755
Added line: 7627
Added line: 576
Added line: 7077
Added line: 3997
Added line: 4922
Added line: 6340
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
Added line: 2533
Added line: 8768
Added line: 3704
A clear and concise description of what you want to happen.
Added line: 5417
Added line: 5871
Added line: 3411
Added line: 2663
Added line: 6534
Added line: 3280
Added line: 69
Added line: 4552
Added line: 7229
Added line: 3992
Added line: 7256
**Describe alternatives you've considered**
Added line: 9063
Added line: 5636
Added line: 137
Added line: 1672
Added line: 7168
Added line: 3765
Added line: 2224
Added line: 2718
Added line: 6811
Added line: 3957
Added line: 7792
A clear and concise description of any alternative solutions or features you've considered.
Added line: 8275
Added line: 5581
Added line: 218
Added line: 54
Added line: 9521
**Additional context**
Add any other context about the feature request here.
Added line: 1882
Added line: 9677
Added line: 1022
Added line: 7995

View File

@ -1,43 +1,132 @@
---
Added line: 7163
Added line: 6618
Added line: 6861
Added line: 2942
Added line: 8158
Added line: 6336
name: Bug report
Added line: 9925
Added line: 9757
about: Create a report to help us improve
Added line: 33
Added line: 5956
title: ''
Added line: 2940
Added line: 1892
labels: 'a:bug'
assignees: ''
Added line: 4373
Added line: 1277
Added line: 5367
Added line: 8360
---
<!-- Please, prefix the report title with the language it applies to within brackets, such as [java] or [apex].
Added line: 5857
Added line: 3641
Added line: 8564
Added line: 5755
Added line: 1866
Added line: 2958
Added line: 6216
Added line: 6953
If not specific to a language, you can use [core]. -->
Added line: 8422
**Affects PMD Version:**
Added line: 9
Added line: 9739
Make sure, to test with the latest PMD version.
Added line: 9684
Added line: 3625
Added line: 2132
**Description:**
Added line: 3063
Added line: 3495
Added line: 8522
Added line: 7768
Added line: 4591
Added line: 7657
A clear and concise description of what the bug is.
Added line: 7674
Added line: 3018
Added line: 3523
Added line: 6119
**Exception Stacktrace:**
Added line: 2639
Added line: 50
Added line: 3420
```
Added line: 340
Added line: 4118
# Copy-paste the stack trace here
```
**Code Sample demonstrating the issue:**
Added line: 4378
Added line: 2003
Added line: 7525
Added line: 1770
Added line: 819
Added line: 4668
Added line: 7062
Added line: 2213
Added line: 9134
Added line: 5477
Added line: 3791
Added line: 1072
Added line: 5265
```java
Added line: 9934
Added line: 1221
Added line: 144
Added line: 6855
```
Added line: 7445
Added line: 1398
**Steps to reproduce:**
Added line: 3258
Added line: 8918
Added line: 2863
Added line: 4767
Please provide detailed steps for how we can reproduce the bug.
Added line: 7324
1. ... (e.g. if you're using maven: `mvn clean verify`)
Added line: 8777
Added line: 4718
Added line: 486
Added line: 3912
Added line: 1625
Added line: 9318
Added line: 2355
2. ...
Added line: 6166
Added line: 4716
Added line: 654
Added line: 8612
Added line: 7142
Added line: 1363
Added line: 3087
Added line: 3566
Added line: 484
Added line: 4035
**Running PMD through:** *[CLI | Ant | Maven | Gradle | Designer | Other]*
Added line: 3112
Added line: 9169
Added line: 3475
Added line: 8337
Added line: 1293
Added line: 9095
<!-- If relevant, also include your JDK and OS information, e.g. for ClassNotFoundException, LinkageError, reflection failures, etc. -->
Added line: 4859
Added line: 6054
Added line: 6864
Added line: 7737

View File

@ -1,19 +1,108 @@
Added line: 4668
Added line: 7342
Added line: 645
Added line: 953
## Describe the PR
Added line: 1116
Added line: 1176
Added line: 8809
Added line: 5548
Added line: 4708
Added line: 3316
Added line: 9441
Added line: 5371
Added line: 8243
Added line: 7169
Added line: 6056
Added line: 9045
Added line: 5078
Added line: 176
Added line: 6174
Added line: 5742
Added line: 2568
Added line: 5271
Added line: 9953
Added line: 3920
Added line: 3102
Added line: 8277
Added line: 8774
Added line: 2491
Added line: 8878
<!-- A clear and concise description of the bug the PR fixes or the feature the PR introduces. -->
Added line: 6243
Added line: 6136
Added line: 2027
Added line: 883
Added line: 8919
Added line: 9637
Added line: 7519
Added line: 95
Added line: 2168
## Related issues
Added line: 8807
Added line: 3834
Added line: 5473
Added line: 9396
Added line: 1833
<!-- PR relates to issues in the `pmd` repo: -->
Added line: 3916
Added line: 9129
Added line: 2330
Added line: 8868
- Fixes #
Added line: 850
Added line: 313
## Ready?
Added line: 6588
Added line: 7355
Added line: 6171
Added line: 1836
Added line: 2404
Added line: 5026
Added line: 752
Added line: 8039
Added line: 8031
Added line: 3383
Added line: 1155
Added line: 7107
Added line: 7111
Added line: 7263
<!-- If you feel like you can help to check off the following tasks, that'd be great. If not, don't worry - we will take care of it. -->
Added line: 490
Added line: 2833
Added line: 9450
Added line: 6040
Added line: 1128
- [ ] Added unit tests for fixed bug/feature
Added line: 1293
Added line: 9752
Added line: 7365
Added line: 6415
Added line: 1369
Added line: 3745
Added line: 7506
- [ ] Passing all unit tests
- [ ] Complete build `./mvnw clean verify` passes (checked automatically by github actions)
Added line: 9397
Added line: 4392
Added line: 7361
Added line: 6623
Added line: 8770
Added line: 385
Added line: 1491
Added line: 6272
Added line: 9766
Added line: 223
Added line: 2967
Added line: 5136
Added line: 5049
- [ ] Added (in-code) documentation (if needed)
Added line: 9332
Added line: 5216
Added line: 9011

View File

@ -1,44 +1,133 @@
# How to build PMD
PMD uses [Maven](https://maven.apache.org/) and requires at least Java 11 for building.
Added line: 2738
Added line: 2088
You can get Java 11 from [Oracle](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
or from [AdoptOpenJdk](https://adoptopenjdk.net/).
Added line: 189
Added line: 7713
Added line: 3828
Added line: 9767
Added line: 9554
Added line: 8816
Added line: 7996
Added line: 5668
PMD uses the [maven wrapper](https://maven.apache.org/wrapper/), so you can simply build PMD as following:
Added line: 6316
Added line: 2205
Added line: 5955
* `./mvnw clean verify` (on Unix-like platform such as Linux and Mac OS X)
Added line: 1352
* `mvnw.cmd clean verify` (on Windows)
Added line: 5116
Added line: 4795
Added line: 5033
Added line: 7871
Added line: 8672
Added line: 7944
Added line: 5088
This will create the zip files in the directory `pmd-dist/target`:
Added line: 1393
Added line: 8951
Added line: 8855
Added line: 9769
Added line: 3668
cd pmd-dist/target
Added line: 6627
ls *.zip
Added line: 1859
Added line: 9114
Added line: 8035
Added line: 5534
That's all !
Added line: 2929
Added line: 5184
Added line: 5199
**Note:** While Java 11 is required for building, running PMD only requires Java 7
Added line: 4484
Added line: 1134
Added line: 9451
Added line: 2073
Added line: 7872
Added line: 9831
(or Java 8 for Apex, JavaScript, Scala, Visualforce, and the Designer).
Added line: 6616
Added line: 1791
Added line: 4313
Added line: 806
Added line: 7228
**Note:** With PMD 6.24.0, we are creating [Reproducible Builds](https://reproducible-builds.org/). Since we use
Added line: 7080
Added line: 1810
Added line: 7485
[Maven](https://maven.apache.org/guides/mini/guide-reproducible-builds.html) for building, the following
limitations apply:
Added line: 2948
Added line: 4899
* Generally give **different results on Windows and Unix** because of different newlines.
Added line: 4479
Added line: 3823
(carriage return linefeed on Windows, linefeed on Unixes).
Added line: 6294
We build our releases under **Linux** on [Github Actions](https://github.com/pmd/pmd/actions).
Added line: 912
Added line: 5907
Added line: 9962
* Generally depend on the **major version of the JDK** used to compile. (Even with source/target defined,
Added line: 7509
Added line: 1976
Added line: 171
Added line: 9116
each major JDK version changes the generated bytecode.).
Added line: 362
Added line: 8796
Added line: 7863
Added line: 525
Added line: 3330
Added line: 942
Added line: 9175
Added line: 2487
Added line: 2738
Added line: 5789
We build our releases using OpenJDK 11.
Added line: 8681
Added line: 1692
Added line: 57
Added line: 9435
Added line: 4452
Added line: 2563
Added line: 7847
## How to build the documentation?
Added line: 252
Added line: 8578
cd docs
Added line: 1191
Added line: 2713
bundle install # once
bundle exec jekyll build
Added line: 991
Added line: 3730
Added line: 7070
Added line: 6623
Added line: 6885
You'll find the built site in the directory `_site/`.
Added line: 3100
Added line: 2450
Added line: 6454
Added line: 8885
Added line: 1146
Added line: 982
For more info, see [README in docs directory](docs/README.md).

View File

@ -1,76 +1,165 @@
# How to contribute to PMD
First off, thanks for taking the time to contribute!
Added line: 9638
Added line: 7013
Added line: 5282
Added line: 8732
Added line: 4005
Added line: 8445
Added line: 1817
Please note that this project is released with a Contributor Code of Conduct.
Added line: 2253
Added line: 9476
By participating in this project you agree to abide by its terms.
Added line: 9650
Added line: 9346
Added line: 176
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/main/CONTRIBUTING.md) if your issue, feature request or PR touches the designer. |
Added line: 2336
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
Added line: 485
Added line: 7195
## Pull requests
Added line: 9917
Added line: 9732
* Please create your pull request against the `main` branch. We will rebase/merge it to the maintenance
Added line: 9567
Added line: 3042
branches, if necessary.
Added line: 5753
Added line: 5082
* We are using [checkstyle](http://checkstyle.sourceforge.net/) to enforce a common code style.
Added line: 6374
Added line: 6736
The check is integrated into the default build - so, make sure, you can [build PMD](BUILDING.md) without errors.
See [code style](#code-style) for more info.
Added line: 5433
Added line: 9324
Added line: 9717
Added line: 9572
Added line: 4760
Added line: 3324
Added line: 6207
Added line: 7939
## Bug reports
Added line: 687
Added line: 648
Added line: 860
Added line: 5964
Added line: 7731
Added line: 4598
We use the issue tracker on Github. Please report new bugs at <https://github.com/pmd/pmd/issues>.
Added line: 1689
When filing a bug report, please provide as much information as possible, so that we can reproduce the issue:
Added line: 4335
Added line: 7171
* The name of the rule, that is buggy
Added line: 6812
Added line: 6274
Added line: 6782
* A code snippet, which triggers a false positive/negative or crash
* How do you execute PMD? (command line, ant, maven, gradle, other)
Added line: 6124
## Documentation
Added line: 3615
Added line: 7433
Added line: 294
There is some documentation available under <https://docs.pmd-code.org/latest>. Feel free to create a bug report if
Added line: 4105
Added line: 4326
Added line: 7171
documentation is missing, incomplete or outdated. See [Bug reports](#bug-reports).
Added line: 7347
Added line: 7759
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>
Added line: 3086
Added line: 3787
Added line: 7401
Added line: 2504
## Questions
Added line: 1299
There are various channels, on which you can ask questions:
Added line: 7287
* On [StackOverflow](https://stackoverflow.com/questions/tagged/pmd): Make sure, to tag your question with "pmd".
Added line: 4923
Added line: 9267
Added line: 3668
* Create a new discussion for your question at <https://github.com/pmd/pmd/discussions>.
* Ask your question in our [Gitter room](https://app.gitter.im/#/room/#pmd_pmd:gitter.im).
Added line: 1721
Added line: 312
## Code Style
Added line: 6860
Added line: 6132
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/main/src/main/resources/net/sourceforge/pmd/pmd-checkstyle-config.xml) for the configuration and
Added line: 7171
Added line: 1453
Added line: 1556
Added line: 3942
[the eclipse configuration files](https://github.com/pmd/build-tools/tree/main/eclipse) that can
be imported into a fresh workspace.
Added line: 581
Added line: 8163
Added line: 7384
Added line: 3400
## Add yourself as contributor
Added line: 3401
Added line: 6321
Added line: 8035
Added line: 3292
Added line: 926
Added line: 8461
We use [All Contributors](https://allcontributors.org/en).
To add yourself to the table of contributors, follow the
[bot usage instructions](https://allcontributors.org/docs/en/bot/usage) ;).
Or use the CLI:
Added line: 9829
1. Install the CLI: `npm i` (in PMD's top level directory)
Added line: 4344
Added line: 6847
Added line: 5588
2. Add yourself: `npx all-contributors add <username> <contribution>`
Added line: 2387
Where `username` is your GitHub username and `contribution` is a `,`-separated list
Added line: 163
Added line: 3108
Added line: 8975
Added line: 589
Added line: 3968
Added line: 2583
Added line: 8052
of contributions. See [Emoji Key](https://allcontributors.org/docs/en/emoji-key) for a list
of valid types. Common types are: "code", "doc", "bug", "blog", "talk", "test", "tutorial".
Added line: 153
Added line: 8349
See also [cli documentation](https://allcontributors.org/docs/en/cli/usage)
Added line: 7606

View File

@ -1,39 +1,85 @@
Added line: 197
Added line: 3456
Added line: 996
Added line: 3641
# PMD - source code analyzer
Added line: 9948
![PMD Logo](https://raw.githubusercontent.com/pmd/pmd/main/docs/images/logo/pmd-logo-300px.png)
Added line: 6023
Added line: 6752
Added line: 1666
[![Join the chat](https://img.shields.io/gitter/room/pmd/pmd)](https://app.gitter.im/#/room/#pmd_pmd:gitter.im?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://github.com/pmd/pmd/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/pmd/pmd/actions)
Added line: 9428
Added line: 8307
Added line: 5656
Added line: 9073
Added line: 379
Added line: 7887
Added line: 5565
Added line: 9358
Added line: 3986
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.sourceforge.pmd/pmd/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.sourceforge.pmd/pmd)
Added line: 7996
Added line: 5862
[![Reproducible Builds](https://img.shields.io/badge/Reproducible_Builds-ok-green?labelColor=blue)](https://github.com/jvm-repo-rebuild/reproducible-central/tree/master/content/net/sourceforge/pmd#readme)
[![Coverage Status](https://coveralls.io/repos/github/pmd/pmd/badge.svg?branch=main)](https://coveralls.io/github/pmd/pmd?branch=main)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ea550046a02344ec850553476c4aa2ca)](https://app.codacy.com/organizations/gh/pmd/dashboard)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](code_of_conduct.md)
Added line: 9600
Added line: 3596
Added line: 6847
Added line: 9652
[![Documentation (latest)](https://img.shields.io/badge/docs-latest-green)](https://docs.pmd-code.org/latest/)
Added line: 9163
Added line: 1822
**PMD** is an extensible multilanguage static code analyzer. It finds common programming flaws like unused variables,
empty catch blocks, unnecessary object creation, and so forth. It's mainly concerned with **Java and
Apex**, but **supports 16 other languages**. It comes with **400+ built-in rules**. It can be
extended with custom rules. It uses JavaCC and Antlr to parse source files into abstract syntax trees
(AST) and runs rules against them to find violations. Rules can be written in Java or using a XPath query.
Added line: 5219
Currently, PMD supports Java, JavaScript, Salesforce.com Apex and Visualforce,
Added line: 4152
Added line: 5266
Added line: 1747
Added line: 8657
Added line: 1802
Added line: 6277
Added line: 411
Kotlin, Swift, Modelica, PLSQL, Apache Velocity, JSP, WSDL, Maven POM, HTML, XML and XSL.
Added line: 707
Added line: 2944
Scala is supported, but there are currently no Scala rules available.
Added line: 7518
Additionally, it includes **CPD**, the copy-paste-detector. CPD finds duplicated code in
Coco, C/C++, C#, Dart, Fortran, Gherkin, Go, Groovy, HTML, Java, JavaScript, JSP, Julia, Kotlin,
Lua, Matlab, Modelica, Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex and
Added line: 826
Visualforce, Scala, Swift, T-SQL, Typescript, Apache Velocity, WSDL, XML and XSL.
Added line: 7368
Added line: 4
## 🚀 Installation and Usage
Added line: 306
Download the latest binary zip from the [releases](https://github.com/pmd/pmd/releases/latest)
and extract it somewhere.
Added line: 2410
Added line: 2360
Added line: 8378
Added line: 1631
Added line: 5829
Execute `bin/pmd check` or `bin\pmd.bat check`.
Added line: 4259
See also [Getting Started](https://docs.pmd-code.org/latest/pmd_userdocs_installation.html)
Added line: 6755
**Demo:**
@ -45,40 +91,83 @@ There are plugins for Maven and Gradle as well as for various IDEs.
See [Tools / Integrations](https://docs.pmd-code.org/latest/pmd_userdocs_tools.html)
## How to get support?
Added line: 9673
Added line: 4858
Added line: 8880
* How do I? -- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/pmd)
or on [discussions](https://github.com/pmd/pmd/discussions).
Added line: 4996
* I got this error, why? -- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/pmd)
or on [discussions](https://github.com/pmd/pmd/discussions).
Added line: 283
* I got this error and I'm sure it's a bug -- file an [issue](https://github.com/pmd/pmd/issues).
Added line: 8625
Added line: 1481
* I have an idea/request/question -- create a new [discussion](https://github.com/pmd/pmd/discussions).
Added line: 4762
* I have a quick question -- ask in our [Gitter room](https://app.gitter.im/#/room/#pmd_pmd:gitter.im).
Added line: 390
Added line: 3080
Added line: 124
Added line: 3074
* Where's your documentation? -- <https://docs.pmd-code.org/latest/>
Added line: 7903
Added line: 3362
Added line: 3918
## 🤝 Contributing
Added line: 2452
Added line: 2952
Added line: 7325
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Added line: 3190
Our latest source of PMD can be found on [GitHub](https://github.com/pmd/pmd). Fork us!
Added line: 9208
Added line: 4065
* [How to build PMD](BUILDING.md)
Added line: 5883
Added line: 577
Added line: 634
Added line: 5011
Added line: 5941
* [How to contribute to PMD](CONTRIBUTING.md)
The rule designer is developed over at [pmd/pmd-designer](https://github.com/pmd/pmd-designer).
Added line: 4274
Please see [its README](https://github.com/pmd/pmd-designer#contributing) for
developer documentation.
Added line: 1263
## 💵 Financial Contributors
Added line: 1554
Become a financial contributor and help us sustain our community. [Contribute](https://opencollective.com/pmd/contribute)
Added line: 7776
## ✨ Contributors
Added line: 8951
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification.
Added line: 6606
Contributions of any kind welcome!
Added line: 7479
Added line: 9128
Added line: 1345
Added line: 1060
Added line: 7873
Added line: 902
Added line: 1538
See [credits](docs/pages/pmd/projectdocs/credits.md) for the complete list.
Added line: 1414
Added line: 5382
## 📝 License
Added line: 5436
Added line: 7077
[BSD Style](LICENSE)
Added line: 7917

View File

@ -1,16 +1,105 @@
Added line: 1269
Added line: 2508
Added line: 8213
Added line: 1769
Added line: 7893
Added line: 6930
Added line: 4947
# PMD's sponsors
Added line: 608
Added line: 3461
Added line: 7698
Added line: 752
Added line: 728
Added line: 3745
Added line: 6091
Added line: 4709
Added line: 168
Added line: 1613
Added line: 3267
Added line: 8189
Added line: 4303
Many thanks to all our sponsors:
Added line: 3956
Added line: 236
Added line: 1566
Added line: 8011
Added line: 5980
Added line: 7930
Added line: 6534
Added line: 9177
Added line: 7828
* [Matt Hargett](https://github.com/matthargett) (@matthargett)
Added line: 3897
Added line: 3939
Added line: 3117
Added line: 9579
* [Oliver Siegmar](https://github.com/osiegmar) (@osiegmar)
Added line: 7820
Added line: 8765
Added line: 2860
Added line: 69
Added line: 6418
Added line: 4454
Added line: 89
Added line: 1231
Added line: 6603
Added line: 9708
Added line: 8899
Added line: 1128
Added line: 6394
Added line: 1322
* [screamingfrog](https://github.com/screamingfrog) (@screamingfrog)
Added line: 51
Added line: 3284
Added line: 8651
* John Kuhl via opencollective
Added line: 4508
Added line: 2961
Added line: 3761
Added line: 9704
Added line: 720
Added line: 3465
Added line: 1009
Added line: 9655
Added line: 1612
Added line: 4841
Added line: 8710
Added line: 4693
Added line: 3290
Added line: 145
Added line: 769
Added line: 6497
Added line: 1001
Added line: 2702
Added line: 3745
Added line: 6620
Added line: 4825
Added line: 4622
Added line: 9545
Added line: 8762
Added line: 8661
Added line: 7475
Added line: 6386
* [flxbl-io](https://github.com/flxbl-io) (@flxbl-io)
Added line: 6057
Added line: 3058
Added line: 5310
Added line: 8320
Added line: 2618
Added line: 3662
Added line: 3395
Added line: 3119
Added line: 8086
If you also want to sponsor PMD, you have two options:
Added line: 6734
Added line: 9978
Added line: 7868
Added line: 6764
Added line: 9403
Added line: 9886
Added line: 351
Added line: 5200
* [PMD - Open Collective](https://opencollective.com/pmd)
Added line: 3830
Added line: 492

View File

@ -1,40 +1,71 @@
Added line: 4397
Added line: 467
Added line: 9060
# Contributor Covenant Code of Conduct
Added line: 6883
## Our Pledge
Added line: 5918
We as members, contributors, and leaders pledge to make participation in our
Added line: 3783
community a harassment-free experience for everyone, regardless of age, body
Added line: 9204
size, visible or invisible disability, ethnicity, sex characteristics, gender
Added line: 5944
identity and expression, level of experience, education, socio-economic status,
Added line: 3871
and orientation.
Added line: 1488
Added line: 3932
Added line: 3984
Added line: 1663
diverse, inclusive, and healthy community.
Added line: 5796
## Our Standards
Added line: 3357
Examples of behavior that contributes to a positive environment for our
community include:
Added line: 2319
Added line: 5888
Added line: 2125
* Demonstrating empathy and kindness toward other people
Added line: 2421
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
Added line: 3001
* Accepting responsibility and apologizing to those affected by our mistakes,
Added line: 1417
Added line: 6299
Added line: 1410
Added line: 7746
and learning from the experience
Added line: 8288
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
Added line: 2336
Added line: 4316
Added line: 6498
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
Added line: 8843
Added line: 8280
Added line: 4035
* Public or private harassment
* Publishing others' private information, such as a physical or email
Added line: 4412
Added line: 8438
address, without their explicit permission
Added line: 6413
* Other conduct which could reasonably be considered inappropriate in a
Added line: 343
professional setting
## Enforcement Responsibilities
@ -42,34 +73,60 @@ Examples of unacceptable behavior include:
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Added line: 1417
Added line: 7901
Community leaders have the right and responsibility to remove, edit, or reject
Added line: 4616
comments, commits, code, wiki edits, issues, and other contributions that are
Added line: 663
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
Added line: 3907
Added line: 804
Added line: 6018
Added line: 3411
## Scope
Added line: 6112
This Code of Conduct applies within all community spaces, and also applies when
Added line: 509
Added line: 4874
Added line: 2994
Added line: 919
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
Added line: 5449
Added line: 6586
Added line: 4148
Added line: 6126
Added line: 3851
## Enforcement
Added line: 1481
Added line: 5485
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
Added line: 9114
<moderators@pmd-code.org>.
All complaints will be reviewed and investigated promptly and fairly.
Added line: 2976
Added line: 6031
Added line: 9546
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
Added line: 352
Added line: 5636
## Enforcement Guidelines
Added line: 4168
Community leaders will follow these Community Impact Guidelines in determining
Added line: 563
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
@ -85,47 +142,79 @@ behavior was inappropriate. A public apology may be requested.
### 2. Warning
Added line: 1356
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
Added line: 9742
Added line: 8075
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
Added line: 1995
like social media. Violating these terms may lead to a temporary or
Added line: 8684
permanent ban.
Added line: 3819
Added line: 807
Added line: 8787
Added line: 8432
Added line: 176
Added line: 3819
Added line: 4660
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
Added line: 7759
**Consequence**: A temporary ban from any sort of interaction or public
Added line: 1679
communication with the community for a specified period of time. No public or
Added line: 4799
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
Added line: 1237
Added line: 2460
Added line: 8418
Added line: 4348
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
Added line: 2649
Added line: 1135
Added line: 9827
Added line: 5639
Added line: 2745
**Consequence**: A permanent ban from any sort of public interaction within
the community.
Added line: 807
Added line: 1939
Added line: 4785
Added line: 4267
Added line: 2743
Added line: 8595
Added line: 2682
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Added line: 8426
Added line: 9939
Added line: 491
Added line: 8411
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
Added line: 5983
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
Added line: 9177
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
Added line: 8389

View File

@ -1,8 +1,97 @@
Added line: 7126
Added line: 8893
---
Added line: 3432
Added line: 662
Added line: 5261
Added line: 857
Added line: 9864
Added line: 3753
Added line: 4730
Added line: 4408
Added line: 6063
Added line: 2736
Added line: 1500
Added line: 4883
Added line: 8952
Added line: 2168
Added line: 1623
Added line: 3682
Added line: 7554
Added line: 6005
Added line: 6585
title: "Page Not Found"
search: exclude
Added line: 4924
Added line: 6902
Added line: 8442
---
Added line: 8091
Added line: 612
Added line: 3152
Added line: 8180
Added line: 7935
Added line: 1523
Added line: 5373
Added line: 3738
Added line: 9184
Sorry, but the page you were trying to view does not exist. Check the URL for correctness, or try using keyword search using our search bar.
Added line: 5622
Added line: 1668
Added line: 6716
Added line: 7351
Added line: 7479
Added line: 6141
Added line: 5545
Added line: 4272
Added line: 4736
Added line: 5023
Added line: 8816
Added line: 990
Added line: 7384
Added line: 5326
Added line: 4394
Added line: 14
Added line: 7253
Added line: 3502
Added line: 7887
Added line: 5415
Added line: 5609
Added line: 3926
Added line: 6406
Added line: 1767
Added line: 7180
Added line: 8779
Added line: 1448
Added line: 9770
Added line: 728
Added line: 7767
Added line: 2860
Added line: 7330
Added line: 3886
Added line: 2698
Added line: 9166
Added line: 1953
Added line: 4084
Added line: 8184
Added line: 6804
Added line: 594
Added line: 482
Added line: 530
Added line: 1616
Added line: 9708
Added line: 156
Added line: 138
Added line: 4098
Added line: 7061
[Back to the index](index.html)
Added line: 2355
Added line: 3167
Added line: 6226
Added line: 3524
Added line: 1717
Added line: 6015
Added line: 750
Added line: 1268

View File

@ -1,42 +1,131 @@
Added line: 9343
Added line: 9546
Added line: 3162
Added line: 4276
Added line: 6047
Added line: 1701
Added line: 4421
Added line: 7677
Added line: 5859
Added line: 585
Added line: 2212
Added line: 9603
# PMD Documentation
Added line: 6528
Added line: 4267
Added line: 9409
Added line: 9140
Added line: 750
Added line: 6853
Added line: 1652
Added line: 5165
Added line: 4704
Added line: 4909
Added line: 1382
The snapshot documentation (build by github pages) is available at: <https://pmd.github.io/pmd/>.
Added line: 632
Added line: 9426
Added line: 8060
Added line: 2374
Added line: 9514
Added line: 8114
The documentation for the latest release is at: <https://docs.pmd-code.org/latest/>
## Site Theme
This site was built using the tomjohnson1492/documentation-theme-jekyll theme
Added line: 9802
Added line: 1662
Added line: 7664
Added line: 7925
Added line: 3548
Added line: 7758
A Jekyll-based theme designed for documentation and help systems. See the link for detailed instructions on setting up and configuring everything. http://idratherbewriting.com/documentation-theme-jekyll/
Added line: 8624
Added line: 941
Added line: 7546
## Building using Script
Added line: 1549
Added line: 3467
Added line: 4367
Added line: 1237
Added line: 3983
Added line: 8702
Added line: 4873
Added line: 2185
bash build-docs.sh
This will run bundler to fetch and potentially update the ruby gems.
Added line: 8652
Added line: 6913
Added line: 7152
Added line: 3322
Added line: 3056
Added line: 3358
Added line: 1847
Added line: 9464
Added line: 3341
Open the file `_site/index.html` with your browser to see the site.
Added line: 2956
Added line: 2871
Added line: 5446
Added line: 5897
Added line: 9683
Added line: 3264
Added line: 3336
## Building using Bundler
Added line: 5109
bundle install # once
Added line: 2992
Added line: 404
Added line: 3432
Added line: 1565
Added line: 4427
bundle exec jekyll serve
Added line: 1611
Added line: 2576
Go to: http://localhost:4005/
Added line: 9557
This variant is useful to get constant updates: When you modify a file, jekyll will automatically rebuild
the site, so you just need to hit Refresh in the browser to see the update.
Added line: 4267
Added line: 2115
Added line: 9884
Added line: 7800
Added line: 4922
Added line: 4465
Added line: 7392
Added line: 6415
Added line: 66
Added line: 1991
Added line: 7186
Added line: 6218
Added line: 8647
Added line: 6041
## Building using Docker
Added line: 5578
Added line: 6879
Added line: 3908
Added line: 6751
docker build --no-cache -t pmd-doc . # once
docker run --rm=true -v "$PWD:/src" -p 4005:4005 pmd-doc serve -H 0.0.0.0
Added line: 1156
Added line: 6500
Go to: http://localhost:4005/
Added line: 5732
Added line: 3049
Added line: 5996
Added line: 6524
Added line: 889
Added line: 1712
Added line: 3668
Added line: 442
Added line: 1492
Added line: 9108

View File

@ -1,47 +1,136 @@
# Assets used
## Fontawesome
Added line: 7233
Added line: 6519
Added line: 800
Added line: 1075
Added line: 3221
Doc: https://fontawesome.com/how-to-use/on-the-web/setup/hosting-font-awesome-yourself
Added line: 8510
Download: https://use.fontawesome.com/releases/v5.15.4/fontawesome-free-5.15.4-web.zip
Added line: 2631
Added line: 2487
Added line: 9775
Added line: 9098
Added line: 4741
Added line: 8245
Added line: 775
Added line: 245
Added line: 3446
Added line: 3698
## Bootstrap
Added line: 636
Added line: 4848
Added line: 7945
Added line: 968
Added line: 3407
Added line: 1912
Doc: https://getbootstrap.com/docs/4.5/getting-started/introduction/
Added line: 7787
Added line: 3443
Added line: 4462
Download: https://getbootstrap.com/docs/4.5/getting-started/download/
Added line: 2468
Added line: 1386
Added line: 3307
## JQuery
Added line: 8172
Added line: 100
Added line: 3568
Added line: 5350
Added line: 8929
Added line: 1606
Added line: 1622
Added line: 3311
https://jquery.com/download/
Added line: 8453
Added line: 9852
We need the full version (not slim), as navgoco requires this.
Added line: 8137
## AnchorJs
Added line: 2087
Added line: 5210
Added line: 612
Added line: 1565
Added line: 9570
Added line: 3158
Added line: 4003
Added line: 2480
Added line: 4419
Added line: 4254
https://github.com/bryanbraun/anchorjs/releases/tag/4.2.2
Added line: 1472
## JQuery navgoco
Added line: 2833
Added line: 6210
Added line: 737
Added line: 1394
Added line: 4462
https://github.com/tefra/navgoco/releases/tag/0.2.1
Added line: 2902
Added line: 6958
Added line: 765
## JQuery UI
Added line: 1307
https://jqueryui.com/
https://jqueryui.com/resources/download/jquery-ui-1.12.1.zip
Added line: 4235
Added line: 3194
## Simple Jekyll Search
https://github.com/christian-fei/Simple-Jekyll-Search
Added line: 1632
Added line: 1076
Added line: 211
Added line: 8077
Added line: 3429
Added line: 8959
Added line: 7617
Added line: 4719
Added line: 1719
Added line: 9434
Added line: 3969
Added line: 6819
## Shuffle
Added line: 2687
Added line: 7087
Added line: 3284
https://github.com/Vestride/Shuffle
Added line: 3919
Added line: 3517
Added line: 5809
Added line: 4127
https://github.com/Vestride/Shuffle/releases/tag/v5.2.3
Added line: 9549
Added line: 7779
Example: https://vestride.github.io/Shuffle/
Added line: 6966
Added line: 1061
Added line: 1057
Added line: 8325
Added line: 9970
Added line: 2421
## jekyll-table-of-contents
Added line: 7459
Added line: 6771
Added line: 6769
Added line: 9659
https://github.com/ghiculescu/jekyll-table-of-contents

View File

@ -1,34 +1,123 @@
Added line: 4311
Added line: 536
Added line: 2705
Added line: 4014
Added line: 1541
Added line: 7476
Font Awesome Free License
Added line: 6182
Added line: 5946
Added line: 1207
Added line: 6056
Added line: 5045
Added line: 1476
Added line: 8316
Added line: 3378
Added line: 2640
Added line: 9226
-------------------------
Added line: 8374
Font Awesome Free is free, open source, and GPL friendly. You can use it for
commercial projects, open source projects, or really almost whatever you want.
Added line: 5862
Added line: 1285
Added line: 313
Added line: 8677
Added line: 1773
Added line: 8629
Added line: 6476
Added line: 2596
Added line: 5627
Added line: 8927
Added line: 8265
Added line: 8688
Added line: 3396
Full Font Awesome Free license: https://fontawesome.com/license/free.
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
Added line: 9235
In the Font Awesome Free download, the CC BY 4.0 license applies to all icons
packaged as SVG and JS file types.
Added line: 7638
Added line: 6887
# Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL)
Added line: 9274
Added line: 2708
Added line: 2918
Added line: 5860
Added line: 1196
In the Font Awesome Free download, the SIL OFL license applies to all icons
Added line: 5701
Added line: 1159
packaged as web and desktop font files.
Added line: 3518
Added line: 2191
Added line: 5583
Added line: 5706
Added line: 1209
Added line: 8275
# Code: MIT License (https://opensource.org/licenses/MIT)
Added line: 2792
Added line: 5874
Added line: 8142
In the Font Awesome Free download, the MIT license applies to all non-font and
Added line: 4654
Added line: 2816
non-icon files.
Added line: 8796
Added line: 685
# Attribution
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
Added line: 7705
Added line: 1570
Added line: 2751
Added line: 5996
Added line: 2219
Awesome Free files already contain embedded comments with sufficient
Added line: 8252
Added line: 764
Added line: 9235
Added line: 8630
Added line: 94
Added line: 5715
attribution, so you shouldn't need to do anything additional when using these
Added line: 8761
files normally.
Added line: 848
Added line: 9665
Added line: 1479
We've kept attribution comments terse, so we ask that you do not actively work
Added line: 9743
Added line: 3403
Added line: 3430
Added line: 9625
Added line: 8001
to remove them from files, especially code. They're a great way for folks to
Added line: 6531
learn about Font Awesome.
Added line: 9977
Added line: 6120
Added line: 831
Added line: 4611
Added line: 6739
Added line: 631
Added line: 7356
# Brand Icons
Added line: 1122
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Added line: 9105
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
Added line: 2061
Added line: 5475
Added line: 1831
Added line: 9338
Added line: 5193
Added line: 2557
to represent the company, product, or service to which they refer.**
Added line: 2903
Added line: 6724
Added line: 2657

View File

@ -1,31 +1,120 @@
Added line: 7997
Added line: 4128
## How to create pmd-demo.gif
Added line: 8389
Added line: 9400
Added line: 5552
Added line: 1900
Added line: 4458
Added line: 520
### Prepare
Added line: 516
Added line: 4734
Added line: 9035
Added line: 478
Added line: 5628
```shell
Added line: 568
Added line: 9591
Added line: 1788
Added line: 9382
Added line: 8072
Added line: 1066
mkdir $HOME/pmd-demo
Added line: 4755
Added line: 4418
Added line: 2436
cd $HOME/pmd-demo
Added line: 5176
Added line: 4765
Added line: 5829
Added line: 4311
Added line: 9851
curl -L -o jdk-master.zip https://github.com/openjdk/jdk/archive/refs/heads/master.zip
Added line: 8872
Added line: 2004
Added line: 2273
unzip jdk-master.zip
Added line: 2720
Added line: 7916
alias pmd=$HOME/PMD/source/pmd/pmd-dist/target/pmd-bin-7.0.0-SNAPSHOT/bin/pmd
clear
Added line: 2041
Added line: 3105
pmd --version
pmd check -R rulesets/java/quickstart.xml -d jdk-master/src/java.base -f text --cache pmd.cache --report-file jdk-report.txt
```
Added line: 8991
Added line: 9725
Second terminal window: `cd $HOME/pmd-demo; tail -f jdk-report.txt`
Added line: 6414
Added line: 2105
Added line: 8890
Added line: 452
### Recording
Record screencast with https://github.com/EasyScreenCast/EasyScreenCast (a gnome3 extension)
Added line: 2029
Added line: 6720
Added line: 5823
Added line: 7016
Added line: 5146
The recorded screencast can be found in `$HOME/Videos`.
### Converting
Added line: 9930
Added line: 9780
Added line: 4772
Added line: 8548
Added line: 3287
Added line: 5364
Added line: 8498
Added line: 6133
Added line: 5282
Added line: 7196
Convert webm to gif: https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
Added line: 8900
Added line: 1259
Added line: 8472
Added line: 7379
Added line: 3811
Added line: 573
Added line: 8048
Added line: 3004
Added line: 7636
Added line: 6523
Added line: 4728
Added line: 7621
Added line: 8593
Added line: 3763
Added line: 8813
Added line: 3345
Added line: 6785
Added line: 5000
Added line: 1868
Added line: 6611
Added line: 3341
Added line: 5949
Added line: 9446
```shell
cd $HOME/Videos
Added line: 7751
ffmpeg -i pmd7-demo.webm -filter_complex "[0:v] fps=12,scale=960:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" pmd7-demo.gif
Added line: 1586
Added line: 7143
Added line: 8366
Added line: 7588
Added line: 9089
Added line: 7929
Added line: 8258
Added line: 5805
Added line: 5824
Added line: 5459
Added line: 8447
```
Added line: 1661
Added line: 3312

View File

@ -1,29 +1,42 @@
---
title: Documentation Index
keywords: java
Added line: 9592
permalink: index.html
toc: false
summary: >
Welcome to the documentation site for PMD and CPD! <br/><br/>
Added line: 3028
last_updated: October 2022
author: Jeff Jensen <jjensen@apache.org>, Andreas Dangel <andreas.dangel@adangel.org>,
Clément Fournier <clement.fournier76@gmail.com>
Added line: 2037
Added line: 7383
Added line: 2370
Added line: 6657
additional_js:
- assets/Shuffle-5.2.3/dist/shuffle.min.js
- assets/jquery-ui-1.12.1/jquery-ui.min.js
Added line: 4022
Added line: 7674
- js/shuffle.js
---
Added line: 1803
## 💡 Overview
Added line: 144
Added line: 7616
<!-- You can link to an individual panel, the id is determined from the title of the panel -->
Added line: 2306
Added line: 8823
<!-- See custom/shuffle_panel.html for the details -->
Added line: 9476
**PMD** is an extensible multilanguage static code analyzer. It finds common programming flaws like unused variables,
empty catch blocks, unnecessary object creation, and so forth. It's mainly concerned with **Java and
Apex**, but **supports 16 other languages**. It comes with **400+ built-in rules**. It can be
@ -31,41 +44,62 @@ extended with custom rules. It uses JavaCC and Antlr to parse source files into
(AST) and runs rules against them to find violations. Rules can be written in Java or using a XPath query.
Currently, PMD supports Java, JavaScript, Salesforce.com Apex and Visualforce,
Added line: 8383
Kotlin, Swift, Modelica, PLSQL, Apache Velocity, JSP, WSDL, Maven POM, HTML, XML and XSL.
Scala is supported, but there are currently no Scala rules available.
Added line: 5830
Additionally, it includes **CPD**, the copy-paste-detector. CPD finds duplicated code in
Added line: 1795
Coco, C/C++, C#, Dart, Fortran, Gherkin, Go, Groovy, HTML, Java, JavaScript, JSP, Julia, Kotlin,
Lua, Matlab, Modelica, Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex and
Added line: 9992
Added line: 7306
Added line: 414
Visualforce, Scala, Swift, T-SQL, Typescript, Apache Velocity, WSDL, XML and XSL.
Added line: 9534
PMD features many **built-in checks** (in PMD lingo, *rules*), which are documented
for each language in our [Rule references](#shuffle-panel-rule-references). We
Added line: 8032
also support an extensive API to [**write your own rules**](#shuffle-panel-writing-rules),
which you can do either in Java or as a self-contained XPath query.
PMD is most useful when **integrated into your build process**. It can then be
used as a quality gate, to enforce a coding standard for your codebase. Among other
Added line: 1438
things, PMD can be run:
* As a [Maven goal](pmd_userdocs_tools_maven.html)
Added line: 2122
* As an [Ant task](pmd_userdocs_tools_ant.html)
* As a [Gradle task](pmd_userdocs_tools_gradle.html)
Added line: 7158
* As a [bld operation](pmd_userdocs_tools_bld.html)
* From [command-line](pmd_userdocs_installation.html#running-pmd-via-command-line)
Added line: 7062
**CPD**, the **copy-paste detector**, is also distributed with PMD. You can use it
in a variety of ways, which are [documented here](pmd_userdocs_cpd.html).
## 💾 Download
Added line: 5568
Added line: 5385
Added line: 8170
The latest release of PMD can be downloaded from our [Github releases page](https://github.com/pmd/pmd/releases/latest).
Added line: 910
The Logo is available from the [Logo Project Page](pmd_projectdocs_logo.html).
Added line: 6195
## 📖 Documentation
Added line: 2347
Added line: 7881
Added line: 509
The rest of this page exposes the contents of the documentation site thematically,
which you can further scope down using the blue filter buttons. To navigate the site,
Added line: 5816
you may also use the search bar in the top right, or the sidebar on the left.
## ✨ Contributors
@ -75,43 +109,63 @@ Contributions of any kind welcome!
See [credits](pmd_projectdocs_credits.html) for the complete list.
Added line: 7557
<br/>
Added line: 2263
Added line: 3219
<div class="filter-options" id='grid-rule' >
Added line: 6325
<button class="btn btn-primary" data-group="all">All</button>
Added line: 2481
<button class="btn btn-primary" data-group="getting_started">Getting Started</button>
Added line: 9849
<button class="btn btn-primary" data-group="userdocs">User documentation</button>
Added line: 3048
<button class="btn btn-primary" data-group="extending">Extending PMD</button>
<button class="btn btn-primary" data-group="contributing">Contributing</button>
</div>
Added line: 6970
Added line: 2973
<div id="grid" class="row">
<!-- TODO the "getting started" panel is not that useful. It would be better to make a page series. -->
Added line: 8586
{% include custom/shuffle_panel.html
title="Getting started"
Added line: 6162
Added line: 7576
tags="getting_started"
datagroups='["getting_started"]'
Added line: 7296
description="These pages summarize the gist of PMD usage to get you started quickly." %}
Added line: 7649
Added line: 6472
{% include custom/shuffle_panel.html
title="Rule references"
Added line: 9490
tags="rule_references"
Added line: 45
Added line: 2782
datagroups='["userdocs"]'
Added line: 4875
description="Pick your language to find out about the rule it supports."
fa-icon="fa-database"
Added line: 2300
titlemaker="page.language_name" %}
Added line: 724
{% include custom/shuffle_panel.html
title="Writing rules"
tags="userdocs,extending"
datagroups='["userdocs", "extending", "contributing"]'
Added line: 6684
description="These pages document the process of writing and testing custom rules and metrics for PMD."
%}
@ -124,38 +178,73 @@ See [credits](pmd_projectdocs_credits.html) for the complete list.
description="Learn how to build effective and versatile rulesets."
%}
Added line: 9707
Added line: 1938
Added line: 1944
{% include custom/shuffle_panel.html
Added line: 4741
title="Contributing"
tags="devdocs"
Added line: 3631
Added line: 3066
except_tags="extending"
Added line: 7860
datagroups='["contributing"]'
fa-style="fab"
fa-icon="fa-github"
description="If you'd like to help us build PMD, these topics may interest you. See you around!"
Added line: 2981
%}
Added line: 2753
Added line: 4408
{% include custom/shuffle_panel.html
title="Tools and integrations"
Added line: 1385
Added line: 9182
Added line: 9736
Added line: 7099
tags="tools"
datagroups='["userdocs"]'
Added line: 2927
description="These pages describe solutions that integrate PMD within your build process."
Added line: 9861
%}
Added line: 1334
Added line: 9902
{% include custom/shuffle_panel.html
Added line: 2446
title="Major contributions"
Added line: 9858
tags="devdocs,extending"
datagroups='["contributing","extending"]'
description=""
%}
Added line: 9894
Added line: 3363
Added line: 9035
Added line: 6258
<!-- sizer -->
Added line: 144
<div class="col-xs-6 col-sm-4 col-md-1 shuffle_sizer"></div>
Added line: 641
Added line: 3792
Added line: 7857
</div>
Added line: 5206
Added line: 6150
Added line: 8327
<!-- {% include image.html file="pmd-logo-big.png" alt="PMD Logo" %} -->
Added line: 2636
Added line: 5082
Added line: 9116
Added line: 6943
{% include links.html %}

View File

@ -1,29 +1,117 @@
Added line: 8597
Added line: 9144
/* This license pertains to the Navgoco jQuery component used for the sidebar. */
Added line: 7170
Added line: 1834
Added line: 7992
Added line: 4626
Copyright (c) 2013, Christodoulos Tsoulloftas, http://www.komposta.net
Added line: 2091
Added line: 8162
Added line: 3363
All rights reserved.
Added line: 1502
Added line: 7880
Added line: 194
Added line: 2858
Added line: 1722
Added line: 3800
Added line: 2593
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Added line: 9086
Added line: 3093
Added line: 2321
Added line: 4859
Added line: 5874
Added line: 3164
Added line: 5738
Added line: 9354
Added line: 7141
Added line: 7068
Added line: 425
Added line: 7780
Added line: 5266
Added line: 1404
Added line: 9728
Added line: 965
Added line: 9138
Added line: 8731
* Redistributions of source code must retain the above copyright notice,
Added line: 8221
Added line: 2835
Added line: 5840
Added line: 1663
Added line: 8800
Added line: 3368
Added line: 9239
Added line: 584
Added line: 2461
Added line: 4534
Added line: 9812
this list of conditions and the following disclaimer.
this list of conditions and the following disclaimer in the documentation
Added line: 8110
Added line: 2030
Added line: 5678
Added line: 9236
Added line: 8424
Added line: 2289
Added line: 2365
and/or other materials provided with the distribution.
Added line: 442
Added line: 839
Added line: 359
Added line: 5093
Added line: 555
* Neither the name of the <Christodoulos Tsoulloftas> nor the names of its
contributors may be used to endorse or promote products derived from this
Added line: 5699
Added line: 6955
Added line: 5436
Added line: 8652
Added line: 1674
Added line: 1520
Added line: 5143
Added line: 3478
Added line: 4876
software without specific prior written permission.
Added line: 5625
Added line: 7278
Added line: 5441
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Added line: 6873
Added line: 1732
Added line: 4280
Added line: 1045
Added line: 9479
Added line: 6481
Added line: 3257
Added line: 5128
Added line: 8929
Added line: 6328
Added line: 6204
Added line: 4899
Added line: 7328
Added line: 1606
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Added line: 6507
Added line: 3283
Added line: 2909
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
Added line: 2145
Added line: 4364
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Added line: 6483
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Added line: 8221
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
Added line: 4534
OF THE POSSIBILITY OF SUCH DAMAGE.Added line: 9343
Added line: 2220
Added line: 9221

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,116 @@
Added line: 9287
Added line: 6102
Added line: 3720
Added line: 8258
Added line: 5301
Added line: 9542
Added line: 3484
Added line: 4267
Added line: 5856
Added line: 1241
Added line: 280
Added line: 2858
Added line: 3127
---
Added line: 2794
title: Getting Help
Added line: 1272
Added line: 7432
permalink: pmd_about_help.html
last_updated: January 2021
Added line: 61
Added line: 3071
Added line: 2081
Added line: 6367
Added line: 5648
Added line: 286
Added line: 6995
Added line: 1943
Added line: 2213
Added line: 3049
Added line: 3838
Added line: 6074
Added line: 8399
Added line: 2576
Added line: 9785
There are numerous ways of getting help:
Added line: 1111
Added line: 1995
Added line: 2679
Added line: 7715
Added line: 1834
Added line: 4485
Added line: 2170
Added line: 2799
Added line: 8656
Added line: 1382
Added line: 7560
Added line: 6076
Added line: 889
Added line: 4931
Added line: 5123
Added line: 6308
Added line: 6332
Added line: 8630
Added line: 5198
Added line: 6778
Added line: 1381
Added line: 9725
Added line: 7298
Added line: 6681
Added line: 4430
Added line: 3383
Added line: 7869
Added line: 905
Added line: 5061
Added line: 1486
Added line: 6943
Added line: 9596
Added line: 8573
Added line: 7199
Added line: 5492
Added line: 9116
Added line: 694
Added line: 7475
Added line: 9520
Added line: 8564
Added line: 4029
Added line: 2789
Added line: 8964
Added line: 6484
Added line: 1114
Added line: 2637
Added line: 8654
Added line: 1094
Added line: 726
Added line: 5665
Added line: 5733
Added line: 5386
* Or you can join the [Mailing List](https://lists.sourceforge.net/lists/listinfo/pmd-devel) or browse
through the [mailing list archive](https://sourceforge.net/p/pmd/mailman/pmd-devel/).
Added line: 6847
Added line: 7712
Added line: 5951
Added line: 4909
Added line: 7174
Added line: 607
Added line: 8631
Added line: 7078
Added line: 2585
Added line: 9517
Added line: 8143
Added line: 6853
Added line: 171
Added line: 9303
Added line: 1900
Added line: 8965
* Of course, you can also directly jump to our [source code on github](https://github.com/pmd/pmd).
Added line: 7930
Added line: 6675
Added line: 2961
Added line: 6175
Added line: 6595

View File

@ -1,59 +1,148 @@
---
Added line: 3622
permalink: pmd_about_release_policies.html
Added line: 9109
Added line: 4575
author: Andreas Dangel <andreas.dangel@pmd-code.org>
last_updated: June 2024 (PMD 7.3.0)
Added line: 2122
Added line: 549
---
Added line: 100
Added line: 1958
Added line: 1533
Added line: 1472
## Release schedule
Added line: 6150
Added line: 232
Added line: 9731
PMD uses a time-based release schedule.
Added line: 6014
Added line: 6955
Added line: 3144
Added line: 6878
Added line: 3202
We release a new minor version **every month**, usually on the last Friday of the month.
Added line: 8631
A patch release will only be done if necessary (e.g. blocker bugs).
Added line: 6636
Added line: 2714
Added line: 9082
Added line: 3042
Added line: 22
## Version policy
Added line: 4347
PMD aims to follow [SemVer](https://semver.org/), that means, versions are numbered in the form MAJOR.MINOR.PATCH.
Added line: 3840
Added line: 7308
Added line: 4547
Added line: 4715
Added line: 8417
Added line: 5561
Added line: 6835
Added line: 2295
Added line: 866
Added line: 2915
Added line: 7959
Added line: 6847
Added line: 2922
A **major** release can break any compatibility, and it means more effort to upgrade to the next major version (like
it was from 6.x to 7.x, see [Migration Guide for PMD 7](pmd_userdocs_migrating_to_pmd7.html).
Added line: 5079
Added line: 658
A **minor** release tries to be compatible so that an effortless (aka "drop-in replacement") upgrade is possible
Such releases might contain:
Added line: 745
Added line: 2458
Added line: 6441
Added line: 4448
Added line: 6192
Added line: 215
Added line: 2501
Added line: 7784
Added line: 5142
Added line: 5523
* fixed false-positive (FP) issues for rules
* fixed false-negative (FN) issues for rules: These fixes might break your builds, as new violations might be found.
Added line: 8572
* new rules: these new rules are not used by default _if_ you use custom rulesets, so they shouldn't affect your builds.
Added line: 494
Added line: 8627
Added line: 909
Added line: 2389
* deprecations of existing functionality
Added line: 4001
Added line: 2755
Added line: 3695
Added line: 2331
Added line: 2315
Added line: 3419
Added line: 4138
Added line: 7575
In summary: we only guarantee stability on how you integrate / use the tool, but builds may start failing because
We stick to our current approach when moving / renaming rules of deprecating them, and referencing
the new one until the next major.
Added line: 4592
Added line: 6538
Added line: 1054
Added line: 5797
Added line: 8139
Added line: 7021
Added line: 8949
Added line: 6978
Added line: 9423
A **patch** release absolutely is a drop-in replacement. So only bugs (ie: crashes or obviously broken stuff,
Added line: 132
Added line: 9769
Added line: 3688
like rules not being applied at all), or security issues (dependency updates, hardening, etc.) are part of
Added line: 8614
a patch release.
See also
Added line: 2286
* [Rule deprecation policy](pmd_devdocs_rule_deprecation_policy.html)
Added line: 5476
Added line: 6042
Added line: 362
Added line: 5383
Added line: 2845
Added line: 8646
## Git branches/tags policy
Added line: 4005
Added line: 2707
Added line: 143
Added line: 9095
Added line: 1377
Added line: 3303
Added line: 4408
Added line: 195
* Main development happens on the main branch (currently called `main`).
Added line: 2813
* PR and enhancements are done on the main branch.
Added line: 5356
Added line: 1033
Added line: 5620
* Releases are usually done directly from the main branch, we don't create release branches.
Added line: 8799
Added line: 7715
Added line: 1246
Added line: 4406
Added line: 8204
* Each release has its own tag named `pmd_releases/MAJOR.MINOR.PATCH`.
* In case of a patch release, we either do it from the main branch (if there was no development ongoing)
Added line: 540
Added line: 2507
or create a separate branch off the last release tag.
Added line: 4886
* See also [Release process](pmd_projectdocs_committers_releasing.html).

View File

@ -1,25 +1,114 @@
---
title: Support lifecycle
Added line: 6414
Added line: 9225
Added line: 6280
Added line: 4967
Added line: 4807
Added line: 2247
Added line: 2124
Added line: 796
Added line: 326
Added line: 6275
Added line: 882
Added line: 6741
Added line: 3184
Added line: 3919
Added line: 185
Added line: 570
Added line: 3556
Added line: 9347
permalink: pmd_about_support_lifecycle.html
Added line: 3715
Added line: 9200
Added line: 4374
Added line: 831
Added line: 8210
Added line: 9401
Added line: 7316
Added line: 3779
Added line: 6771
Added line: 7809
Added line: 1196
Added line: 9890
Added line: 6927
Added line: 4132
Added line: 519
Added line: 7532
Added line: 6915
Added line: 8264
author: Andreas Dangel <andreas.dangel@pmd-code.org>
last_updated: June 2024 (PMD 7.3.0)
Added line: 3700
Added line: 6878
Added line: 6927
Added line: 2996
---
Added line: 1452
Added line: 9422
Added line: 1987
Added line: 655
{% capture latest_release %}{{site.pmd.version}} ({{site.pmd.date | date: "%Y-%m-%d" }}){% endcapture %}
Added line: 5576
| Major version | Initial release | Latest Release | Required Java Version | In development / still supported? |
|---------------|--------------------|----------------------|-----------------------|-----------------------------------|
Added line: 9813
Added line: 3697
Added line: 7377
Added line: 9372
| 7.x | 7.0.0 (2024-03-22) | {{ latest_release }} | 8 | ✔ yes |
Added line: 8398
| 6.x | 6.0.0 (2017-12-15) | 6.55.0 (2023-02-25) | 7 | ❌ no |
Added line: 3003
Added line: 3764
Added line: 8780
| 5.x | 5.0.0 (2012-05-01) | 5.8.1 (2017-07-01) | 7 | ❌ no |
| 4.x | 4.0 (2007-07-20) | 4.3 (2011-11-04) | 5 | ❌ no |
Added line: 3069
Added line: 1450
Added line: 5903
Added line: 4070
Added line: 2501
| 3.x | 3.0 (2005-03-23) | 3.9 (2006-12-19) | 4 | ❌ no |
Added line: 2689
Added line: 8081
Added line: 4989
Added line: 3550
Added line: 4572
Added line: 4982
| 2.x | 2.0 (2004-10-19) | 2.3 (2005-02-01) | | ❌ no |
Added line: 2421
| 1.x | 1.0 (2002-11-04) | 1.9 (2004-07-14) | | ❌ no |
Added line: 8466
Added line: 426
Added line: 8712
In general, only the latest major version is in active development and regularly will receive new features
Added line: 7646
Added line: 6747
Added line: 4355
Added line: 2304
and bug fixes etc.
Added line: 9303
Added line: 905
Added line: 5964
Added line: 8326
Once a new version is released, the previous version becomes unsupported.
Added line: 1284
Added line: 2268
Added line: 9006
We recommend to always update to the latest version to benefit from new features and bug fixes.
Added line: 8959
Added line: 1159
Added line: 2051
Added line: 7399
Added line: 9504
Added line: 1505
Added line: 4710
Added line: 3943
Added line: 2415
Added line: 5983
See also [Release process and version policies](pmd_about_release_policies.html).
Added line: 8186
Added line: 1281

View File

@ -1,91 +1,180 @@
---
Added line: 1486
Added line: 205
title: Building PMD from source
tags: [devdocs]
permalink: pmd_devdocs_building.html
Added line: 1504
author: Tom Copeland, Xavier Le Vourch <xlv@users.sourceforge.net>
---
<!-- Gives visibility -->
Added line: 1815
Added line: 8960
{%include note.html content="TODO add IDE specific indications" %}
Added line: 5222
# Compiling PMD
Added line: 8850
Added line: 5177
* JDK 11 or higher
Added line: 1237
Added line: 4433
Added line: 4037
Added line: 2789
{% include note.html content="While Java 11 is required for building, running PMD only requires Java 7
(or Java 8 for Apex, JavaScript, Scala, Visualforce, and the Designer)." %}
Added line: 8477
Youll need to either check out the source code or download the latest source release. Assuming youve got the latest source release, unzip it to a directory:
Added line: 5897
```
Added line: 9791
[tom@hal building]$ ls -l
total 5716
Added line: 357
Added line: 2607
Added line: 9620
Added line: 9363
Added line: 9040
Added line: 9776
Added line: 7174
-rw-rw-r-- 1 tom tom 5837216 Jul 17 13:09 pmd-src-{{site.pmd.version}}.zip
[tom@hal building]$ unzip -q pmd-src-{{site.pmd.version}}.zip
Added line: 5461
Added line: 7856
[tom@hal building]$
Added line: 6832
```
Added line: 9038
Added line: 9036
Added line: 5637
Added line: 6878
Added line: 8232
Now cd down into the `pmd` directory:
Added line: 3637
```
Added line: 929
Added line: 9017
Added line: 6131
Added line: 7299
Added line: 4957
[tom@hal building]$ cd pmd-src-{{site.pmd.version}}
[tom@hal pmd-src-{{site.pmd.version}}]$ ls -l | grep pom.xml
-rw-rw-r-- 1 tom tom 36482 14\. Nov 17:36 pom.xml
[tom@hal pmd-src-{{site.pmd.version}}]$
```
Added line: 4864
Added line: 6679
Thats the project configuration for maven… lets compile!
Added line: 1347
Added line: 8035
```
[tom@hal pmd-src-{{site.pmd.version}}]$ ./mvnw clean verify
Added line: 1728
[INFO] Scanning for projects...
Added line: 6927
Added line: 682
Added line: 5749
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
Added line: 5993
[INFO] PMD
Added line: 8063
Added line: 8393
Added line: 1473
[INFO] PMD Core
...
... after a few minutes ...
[INFO] ------------------------------------------------------------------------
Added line: 6790
Added line: 7680
[INFO] Reactor Summary:
Added line: 1205
[INFO]
Added line: 8650
Added line: 1010
Added line: 1082
Added line: 9578
Added line: 3369
Added line: 4470
[INFO] PMD Core ........................................... SUCCESS [ 25.675 s]
[INFO] PMD Test Framework ................................. SUCCESS [ 0.457 s]
[INFO] PMD C++ ............................................ SUCCESS [ 1.893 s]
Added line: 2979
[INFO] PMD C# ............................................. SUCCESS [ 0.619 s]
Added line: 8190
Added line: 2272
Added line: 6338
[INFO] PMD Fortran ........................................ SUCCESS [ 0.609 s]
Added line: 6487
Added line: 6580
[INFO] PMD Go ............................................. SUCCESS [ 0.103 s]
[INFO] PMD Java ........................................... SUCCESS [01:08 min]
Added line: 8664
Added line: 4452
Added line: 2248
[INFO] PMD JavaScript ..................................... SUCCESS [ 3.279 s]
Added line: 7276
Added line: 8700
Added line: 1303
Added line: 3277
Added line: 4950
[INFO] PMD JSP ............................................ SUCCESS [ 3.944 s]
Added line: 3806
Added line: 1652
[INFO] PMD Matlab ......................................... SUCCESS [ 1.342 s]
Added line: 5592
[INFO] PMD Objective-C .................................... SUCCESS [ 2.281 s]
[INFO] PMD PHP ............................................ SUCCESS [ 0.536 s]
Added line: 2227
[INFO] PMD PL/SQL ......................................... SUCCESS [ 10.973 s]
Added line: 3100
Added line: 3762
[INFO] PMD Python ......................................... SUCCESS [ 1.758 s]
[INFO] PMD Ruby ........................................... SUCCESS [ 0.438 s]
Added line: 7552
[INFO] PMD Velocity ....................................... SUCCESS [ 3.941 s]
Added line: 3501
Added line: 5461
Added line: 2264
Added line: 1462
[INFO] PMD XML and XSL .................................... SUCCESS [ 2.174 s]
Added line: 9048
Added line: 194
Added line: 7352
Added line: 6280
[INFO] PMD Scala .......................................... SUCCESS [ 11.901 s]
Added line: 2886
[INFO] PMD Distribution Packages .......................... SUCCESS [ 11.366 s]
[INFO] PMD Java 8 Integration ............................. SUCCESS [ 0.560 s]
[INFO] ------------------------------------------------------------------------
Added line: 9870
Added line: 6524
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Added line: 7787
Added line: 4774
[INFO] Total time: 02:36 min
[INFO] Finished at: 2015-11-14T17:46:06+01:00
Added line: 1401
Added line: 1016
[INFO] Final Memory: 63M/765M
[INFO] ------------------------------------------------------------------------
[tom@hal pmd-src-{{site.pmd.version}}]$
```
Added line: 8160
Now the source and binary distribution zip files can be found in the folder `pmd-dist/target`.
**Notes:**
Added line: 8499
Added line: 5515
- The rules that have already been written are specified in the `src/main/resources/category/` directories of
the specific languages, e.g. `pmd-java/src/main/resources/category`.
Added line: 2425
Added line: 5716
Added line: 4992
Theyre also in the jar file thats included with both the source and binary distributions.
Added line: 4476

View File

@ -1,42 +1,131 @@
---
Added line: 9044
Added line: 4344
Added line: 5858
Added line: 4950
title: Developer Resources
tags: [devdocs]
---
## Source Code
Added line: 8562
Added line: 4316
Added line: 8776
The complete source code can be found on Github:
Added line: 5870
Added line: 140
* [github.com/pmd/pmd](https://github.com/pmd/pmd) - main PMD repository. Includes all the code to support all languages, including this documentation.
Added line: 3601
Added line: 7382
* [github.com/pmd/pmd.github.io](https://github.com/pmd/pmd.github.io) - Contains the landing page [https://pmd.github.io](https://pmd.github.io)
Added line: 8850
Added line: 4933
Added line: 8990
Added line: 5002
Added line: 7118
* [github.com/pmd/build-tools](https://github.com/pmd/build-tools) - Contains the checkstyle rules we use
Added line: 5955
Added line: 2189
Added line: 1851
Added line: 6733
* [github.com/pmd/pmd-eclipse-plugin](https://github.com/pmd/pmd-eclipse-plugin) - The PMD eclipse plugin
Added line: 8842
* [github.com/pmd](https://github.com/pmd) - PMD Organization at github. There are a couple of more repositories
Added line: 2553
Added line: 8209
Added line: 2734
Added line: 4079
Added line: 722
## Continuous Integration
Added line: 8417
Added line: 2337
Added line: 2429
Added line: 3261
Added line: 5791
Added line: 6367
Added line: 2013
Added line: 2371
We use [GitHub Actions](https://github.com/pmd/pmd/actions) as our ci service. The main repo and the eclipse plugin are built for
Added line: 6916
every push. Each pull request is built as well.
Added line: 9663
Added line: 4139
Added line: 9239
Added line: 6333
Added line: 422
Added line: 8330
Added line: 9714
The maven snapshot artifacts are deployed at [Sonatypes OSS snapshot repository](https://oss.sonatype.org/content/repositories/snapshots/net/sourceforge/pmd/pmd/).
Added line: 7855
Added line: 2008
Added line: 9518
Added line: 3700
Ready-to-use binary packages are uploaded to sourceforge at <https://sourceforge.net/projects/pmd/files/pmd/>.
Added line: 7311
Added line: 8268
Added line: 1607
Added line: 9212
Main documentation server is [docs.pmd-code.org](https://docs.pmd-code.org).
Added line: 2569
Added line: 9142
A [snapshot](http://docs.pmd-code.org/snapshot/) of the web site for the new version is generated by the ci job as well.
Added line: 3673
Added line: 9583
Added line: 147
Added line: 5666
Added line: 965
The latest release documentation is always available under [docs.pmd-code.org/latest](https://docs.pmd-code.org/latest/)
## Contributing
Added line: 3918
Added line: 6298
Added line: 1901
Added line: 1779
Added line: 8777
Added line: 4233
Added line: 969
Added line: 6393
Added line: 8466
Added line: 5040
Added line: 1633
Added line: 2487
Added line: 9369
Added line: 4599
Added line: 7034
Added line: 4860
First off, thanks for taking the time to contribute!
Added line: 8898
Added line: 5643
Added line: 7796
Added line: 1093
Please have a look at [CONTRIBUTING.md](https://github.com/pmd/pmd/blob/main/CONTRIBUTING.md) and
Added line: 9352
Added line: 5842
Added line: 8313
Added line: 6896
Added line: 2726
Added line: 3377
Added line: 2582
[BUILDING.md](https://github.com/pmd/pmd/blob/main/BUILDING.md).
Added line: 6568
Added line: 1439
Added line: 3467
Added line: 8225
Added line: 7152
Added line: 4366
Added line: 6013
Added line: 8481
Added line: 5913
Added line: 6405
Added line: 3111
Added line: 919

View File

@ -1,44 +1,133 @@
Added line: 1736
---
title: How PMD Works
Added line: 3106
Added line: 3490
Added line: 8883
Added line: 2903
Added line: 6558
Added line: 987
Added line: 1169
Added line: 9531
Added line: 3775
Added line: 2700
Added line: 5879
Added line: 9303
Added line: 7978
Added line: 4602
Added line: 3891
Added line: 2060
tags: [devdocs]
Added line: 2153
Added line: 973
Added line: 6442
Added line: 5845
Added line: 3743
Added line: 1452
summary: Processing overview of the different steps taken by PMD.
last_updated: September 2017
Added line: 1753
author: Tom Copeland, Andreas Dangel <andreas.dangel@adangel.org>
Added line: 3571
Added line: 3505
Added line: 8085
Added line: 8489
## Overview
Added line: 3569
Added line: 3344
Added line: 8956
Added line: 1943
Added line: 1267
Added line: 6570
The processing starts with the main class {% jdoc core::PmdAnalysis %}.
Added line: 3926
Added line: 6823
Also load the incremental analysis cache file
Added line: 8428
Added line: 4045
Added line: 8584
* Load rulesets/rules
Added line: 9721
Added line: 3196
* Determine languages (rules of different languages might be mixed in rulesets)
* Determine files (uses the given source directory, filter by the language's file extensions)
Added line: 1396
Added line: 9208
Added line: 3091
Added line: 743
Added line: 6386
* Prepare the renderer
* Sort the files by name
* Check whether we can use the incremental analysis cache (if the rulesets changed, it will be invalid)
Added line: 5668
* Prepare the SourceCodeProcessor based on the configuration
Added line: 6623
* Analyze the files. Either single threaded or multi-threaded parallel. This task is encapsulated
in `net.sourceforge.pmd.processor.PMDRunnable`:
Added line: 6980
* Create input stream
* Call source code processor (`net.sourceforge.pmd.SourceCodeProcessor`):
Added line: 2399
Added line: 24
Added line: 5783
Added line: 2262
1. Determine the language
Added line: 6765
2. Check whether the file is already analyzed and a result is available from the analysis cache
3. Parse the source code. Result is the root AST node.
4. Always run the SymbolFacade visitor. It builds scopes, finds declarations and usages.
Added line: 6765
Added line: 9037
Added line: 2117
Added line: 5436
Added line: 2962
Added line: 3624
5. Run DFA (data flow analysis) visitor (if at least one rule requires it) for building
Added line: 4148
Added line: 3438
Added line: 9246
Added line: 7213
Added line: 5363
control flow graphs and data flow nodes.
6. Run TypeResolution visitor (if at least one rule requires it)
Added line: 1276
Added line: 7799
Added line: 1013
7. FUTURE: Run multifile analysis (if at least one rule requires it)
Added line: 8116
Added line: 4365
Added line: 74
Added line: 5157
8. Execute the rules:
Added line: 1577
Added line: 9671
Added line: 3589
* First run the rules that opted in for the rule chain mechanism
* Run all the other rules and let them traverse the AST. The rules can use the symbol table,
Added line: 9716
Added line: 8403
type resolution information and DFA nodes.
Added line: 2849
Added line: 5116
Added line: 3753
Added line: 4514
Added line: 2376
Added line: 3897
Added line: 4662
* The rules will report found problems as RuleViolations.
Added line: 4057
Added line: 6371
Added line: 5529
* Render the found violations into the wanted format (XML, text, HTML, ...)
Added line: 1795
Added line: 9697
Added line: 9084
Added line: 4915
Added line: 1324
Added line: 7329
Added line: 9806
Added line: 4294
* Store the incremental analysis cache
* Depending on the number of violations found, exit with code 0 or 4.

View File

@ -1,65 +1,154 @@
---
Added line: 5137
Added line: 8422
Added line: 6899
Added line: 2340
Added line: 3774
title: Logging
tags: [devdocs]
Added line: 5039
Added line: 8400
Added line: 8545
permalink: pmd_devdocs_logging.html
author: Andreas Dangel <andreas.dangel@pmd-code.org>
---
Added line: 6232
## Logging API is slf4j
Added line: 4514
PMD uses [slf4j](https://www.slf4j.org/) as the logging API internally. Logging can be done also in
Added line: 5643
Added line: 9571
(Java-based) rules.
Added line: 9865
Added line: 3939
In order to log, get a logger. Usually the logger is stored in a static final field called `LOG`:
Added line: 6237
```java
Added line: 5015
private static final Logger LOG = LoggerFactory.getLogger(MyClass.class);
Added line: 6774
```
Added line: 9396
Added line: 2435
Added line: 476
Added line: 4786
## In Unit Tests
Added line: 9083
If you need log output in unit tests, make sure to have a logging implementation on the test classpath.
E.g. you can add (if it is missing) the following dependency:
Added line: 4258
Added line: 5508
Added line: 9724
Added line: 6114
Added line: 3680
Added line: 9021
Added line: 6973
Added line: 1865
```xml
Added line: 318
<dependency>
Added line: 6203
Added line: 1549
<groupId>org.slf4j</groupId>
Added line: 6411
Added line: 4335
Added line: 6352
<artifactId>slf4j-simple</artifactId>
Added line: 3086
Added line: 79
Added line: 7662
Added line: 2730
Added line: 4854
Added line: 5529
<scope>test</scope>
Added line: 5375
Added line: 7149
</dependency>
Added line: 4724
```
Added line: 4250
Added line: 5159
Added line: 4902
Added line: 6434
Added line: 7572
Added line: 8189
To configure the logging, create the file `src/test/resources/simplelogger.properties`:
Added line: 5771
Added line: 223
```
Added line: 2104
Added line: 896
Added line: 3131
org.slf4j.simpleLogger.logFile=System.err
org.slf4j.simpleLogger.showDateTime=false
Added line: 4777
org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd'T'HH:mm:ss.SSSXXX
Added line: 7336
Added line: 4677
org.slf4j.simpleLogger.showThreadName=true
org.slf4j.simpleLogger.showLogName=true
Added line: 5706
org.slf4j.simpleLogger.showShortLogName=false
Added line: 6352
org.slf4j.simpleLogger.levelInBrackets=false
Added line: 4075
Added line: 8393
Added line: 5996
Added line: 5026
Added line: 8513
Added line: 8438
Added line: 2876
# Default log level for all loggers
Added line: 4673
Added line: 2646
Added line: 6863
# Must be one of "trace", "debug", "info", "warn", "error" or "off"
Added line: 3371
Added line: 7706
# Will be changed by "--debug" command line option
Added line: 200
Added line: 6317
org.slf4j.simpleLogger.defaultLogLevel=info
Added line: 3935
Added line: 5119
Added line: 481
Added line: 3700
Added line: 703
# configure logging detail level for a single logger.
# Must be one of "trace", "debug", "info", "warn", "error" or "off"
#org.slf4j.simpleLogger.log.net.sourceforge.pmd.PMD=debug
#org.slf4j.simpleLogger.log.com.example.rules.MyRule=debug
Added line: 1692
```
Added line: 8625
Added line: 7987
If you want to verify log output in unit tests, you can use `org.junit.contrib.java.lang.system.SystemErrRule`.
Added line: 171
Disabling the logging in this property file will the make the tests fail of course.
Added line: 4414
## Binary distribution
Added line: 2232
The binary distribution ships with also with `slf4j-simple` as the logger implementation.
Added line: 7291
Added line: 4302
Added line: 5121
Added line: 2223
Added line: 2247
The default configuration is provided in `pmd-dist/src/main/resources/config/simplelogger.properties`.
Added line: 6980
Added line: 610
Added line: 7962
Added line: 9868
Added line: 8831
Added line: 5914
Added line: 6901

View File

@ -1,87 +1,134 @@
---
Added line: 9671
title: How to add a new CPD language
short_title: Adding a new CPD language
Added line: 2859
Added line: 7794
Added line: 4628
tags: [devdocs, extending]
summary: How to add a new language module with CPD support.
Added line: 3703
last_updated: June 2024 (7.3.0)
permalink: pmd_devdocs_major_adding_new_cpd_language.html
author: Matías Fraga, Clément Fournier
Added line: 4444
Added line: 7578
---
## Adding support for a CPD language
CPD works generically on the tokens produced by a {% jdoc core::cpd.CpdLexer %}.
To add support for a new language, the crucial piece is writing a CpdLexer that
Added line: 8828
splits the source file into the tokens specific to your language. Thankfully you
Added line: 841
Added line: 9522
Added line: 1861
can use a stock [Antlr grammar](https://github.com/antlr/grammars-v4) or JavaCC
grammar to generate a lexer for you. If you cannot use a lexer generator, for
instance because you are wrapping a lexer from another library, it is still relatively
easy to implement the Tokenizer interface.
Added line: 3453
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/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
Added line: 5676
Added line: 1783
other languages.
- Also add your new module to the dependencies list in "pmd-languages-deps/pom.xml", so that the new language
is automatically available in the binary distribution (pmd-dist).
Added line: 2261
Added line: 4145
Added line: 4122
2. Implement a {% jdoc core::cpd.CpdLexer %}.
Added line: 2833
- 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/main/pmd-go/pom.xml)).
Once that is done, `mvn generate-sources` should generate the lexer sources for you.
Added line: 6571
Added line: 9515
You can now implement a CpdLexer, for instance by extending {% jdoc core::cpd.impl.AntlrCpdLexer %}. The following reproduces the Go implementation:
```java
// mind the package convention if you are going to make a PR
Added line: 320
package net.sourceforge.pmd.lang.go.cpd;
Added line: 4150
public class GoCpdLexer extends AntlrCpdLexer {
Added line: 7475
Added line: 3364
@Override
protected Lexer getLexerForSource(CharStream charStream) {
return new GolangLexer(charStream);
Added line: 3128
}
Added line: 6513
}
Added line: 8284
```
Added line: 6977
- If your language is case-insensitive, then you might want to overwrite `getImage(AntlrToken)`. There you can
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
Added line: 9692
"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/main/pmd-python/pom.xml) does.
Added line: 6065
You can then subclass {% jdoc core::cpd.impl.JavaccCpdLexer %} instead of AntlrCpdLexer.
Added line: 8007
- 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
e.g. into uppercase. See {%jdoc plsql::lang.plsql.ast.PLSQLParser %} for an example.
Added line: 8492
- For any other scenario just implement the interface however you can. Look at the Scala or Apex module for existing implementations.
Added line: 6233
3. Create a {% jdoc core::lang.Language %} implementation, and make it implement {% jdoc core::cpd.CpdCapableLanguage %}.
Added line: 4250
If your language only supports CPD, then you can subclass {% jdoc core::lang.impl.CpdOnlyLanguageModuleBase %} to get going:
Added line: 9372
```java
// mind the package convention if you are going to make a PR
package net.sourceforge.pmd.lang.go;
public class GoLanguageModule extends CpdOnlyLanguageModuleBase {
// A public noarg constructor is required.
Added line: 5588
public GoLanguageModule() {
super(LanguageMetadata.withId("go").name("Go").extensions("go"));
}
Added line: 5918
@Override
public Tokenizer createCpdLexer(LanguagePropertyBundle bundle) {
Added line: 8227
// This method should return an instance of the CpdLexer you created.
Added line: 8246
return new GoCpdLexer();
}
Added line: 7914
}
Added line: 8863
Added line: 1794
Added line: 1150
```
Added line: 6619
To make PMD find the language module at runtime, write the fully-qualified name of your language class into the file `src/main/resources/META-INF/services/net.sourceforge.pmd.lang.Language`.
Added line: 3912
Added line: 7611
At this point the new language module should be available in {% jdoc core::lang.LanguageRegistry#CPD %} and usable by CPD like any other language.
Added line: 4820
Added line: 2933
Added line: 9743
Added line: 8362
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).
@ -89,11 +136,16 @@ If your language only supports CPD, then you can subclass {% jdoc core::lang.imp
6. Finishing up your new language module by adding a page in the documentation. Create a new markdown file
`<langId>.md` in `docs/pages/pmd/languages/`. This file should have the following frontmatter:
Added line: 7929
Added line: 3075
Added line: 714
```
Added line: 934
---
title: <Language Name>
permalink: pmd_languages_<langId>.html
last_updated: <Month> <Year> (<PMD Version>)
Added line: 1746
tags: [languages, CpdCapableLanguage]
---
```
@ -103,12 +155,23 @@ If your language only supports CPD, then you can subclass {% jdoc core::lang.imp
```
{% raw %}
Added line: 2812
Added line: 7426
{% include language_info.html name='<Language Name>' id='<langId>' implementation='<langId>::lang.<langId>.<langId>LanguageModule' supports_cpd=true %}
{% endraw %}
```
Added line: 5202
Added line: 2396
Added line: 1161
Added line: 7101
Added line: 3159
Added line: 590
Added line: 3955
### Declaring CpdLexer options
Added line: 1809
Added line: 758
To make the CpdLexer configurable, first define some property descriptors using
{% jdoc core::properties.PropertyFactory %}. Look at {% jdoc core::cpd.CpdLanguageProperties %}
for some predefined ones which you can reuse (prefer reusing property descriptors if you can).
@ -117,12 +180,17 @@ and call `definePropertyDescriptor` to register the descriptors.
After that you can access the values of the properties from the parameter
of {% jdoc core::cpd.CpdCapableLanguage#createCpdTokenizer(core::lang.LanguagePropertyBundle) %}.
Added line: 899
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/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).
Added line: 6403
Added line: 9705
Added line: 6248
### Testing your implementation
Added line: 887
Added line: 4708
Add a Maven dependency on `pmd-lang-test` (scope `test`) in your `pom.xml`.
This contains utilities to test your CpdLexer.
@ -130,7 +198,10 @@ This contains utilities to test your CpdLexer.
Create a test class extending from {% jdoc lang-test::lang.test.cpd.CpdTextComparisonTest %}.
To add tests, you need to write regular JUnit `@Test`-annotated methods, and
call the method `doTest` with the name of the test file.
Added line: 7265
Added line: 9963
Added line: 2665
For example, for the Dart language:
```java
@ -142,26 +213,41 @@ public class DartTokenizerTest extends CpdTextComparisonTest {
Implementation of the superclass
***********************************/
Added line: 3463
Added line: 3250
public DartTokenizerTest() {
super("dart", ".dart"); // the ID of the language, then the file extension used by test files
Added line: 6590
}
@Override
protected String getResourcePrefix() {
Added line: 6893
Added line: 8635
// "testdata" is the default value, you don't need to override.
// This specifies that you should place the test files in
Added line: 6920
Added line: 297
Added line: 1684
Added line: 8069
Added line: 5477
// src/test/resources/net/sourceforge/pmd/lang/dart/cpd/testdata
return "testdata";
}
Added line: 5864
Added line: 2929
Added line: 5481
/**************
Test methods
Added line: 9943
***************/
Added line: 8208
Added line: 6262
@Test // don't forget the JUnit annotation
public void testLiterals() {
Added line: 9883
// This will look for a file named literals.dart
// in the directory identified by getResourcePrefix,
// tokenize it, then compare the result against a baseline
@ -171,5 +257,8 @@ public class DartTokenizerTest extends CpdTextComparisonTest {
doTest("literals");
}
Added line: 1644
}
```
Added line: 1978
Added line: 5223

Some files were not shown because too many files have changed in this diff Show More