File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ To specify a custom ruleset, simply pass the argument to the hook:
4949
5050``` yaml
5151 - id : pmd
52- args : ["-R", " my_ruleset.xml"]
52+ args : ["-R= my_ruleset.xml"]
5353` ` `
5454
5555Furthermore, the default language version passed to PMD is ` java-17`, which can be tweaked using the `--use-version` argument.
@@ -64,7 +64,7 @@ To change it, simply pass the argument to the hook:
6464
6565` ` ` yaml
6666 - id: cpd
67- args: ["--minimum-tokens", " 50"]
67+ args: ["--minimum-tokens= 50"]
6868` ` `
6969
7070Other [CLI](https://pmd.github.io/latest/pmd_userdocs_cpd.html#cli-usage) arguments are also supported.
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- # find the index of the first parameter with a Java file path
4- idx=1
3+ # extract parameters and files
4+ cpd_args=" "
5+ rm -f /tmp/list
56for (( i= 1 ; i <= "$# "; i++ )) ; do
6- if [[ ${! i} == * .java ]]; then
7- idx=${i}
8- break
7+ if [[ ${! i} =~ --? [^= ]+= .* || ${! i} =~ --? [^= ]+ ]]; then
8+ cpd_args=" $cpd_args ${! i} "
9+ else
10+ echo " ${! i} " >> /tmp/list
911 fi
1012done
1113
1214# add default minimum tokens if not specified
13- cpd_args=" ${*: 1: idx-1} "
14- if [[ ! $cpd_args == * " --minimum-tokens " * ]]; then
15- cpd_args=" $cpd_args --minimum-tokens 100"
15+ if [[ ! $cpd_args == * " --minimum-tokens=" * ]]; then
16+ cpd_args=" $cpd_args --minimum-tokens=100"
1617fi
1718
18- # populate list of files to analise
19- files= " ${ *: idx} "
20- eol= $' \n '
21- echo " ${files // / $eol } " > /tmp/list
19+ # add default language if not specified
20+ if [[ ! $cpd_args == * " --language= " * && ! $cpd_args == * " -l= " * ]] ; then
21+ cpd_args= " $cpd_args --language=java "
22+ fi
2223
2324# shellcheck disable=SC2086
24- /opt/pmd/bin/pmd cpd --format text --language java $cpd_args --file-list /tmp/list
25+ /opt/pmd/bin/pmd cpd --format= text $cpd_args --file-list= /tmp/list
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- # find the index of the first parameter with a Java file path
4- idx=1
3+ # extract parameters and files
4+ pc_args=" "
5+ rm -f /tmp/list
56for (( i= 1 ; i <= "$# "; i++ )) ; do
6- if [[ ${! i} == * .java ]]; then
7- idx=${i}
8- break
7+ if [[ ${! i} =~ --? [^= ]+= .* || ${! i} =~ --? [^= ]+ ]]; then
8+ pc_args=" $pc_args ${! i} "
9+ else
10+ echo " ${! i} " >> /tmp/list
911 fi
1012done
1113
1214# add default version if not specified
13- pc_args=" ${*: 1: idx-1} "
14- if [[ ! $pc_args == * " --use-version " * ]]; then
15- pc_args=" $pc_args --use-version java-17"
15+ if [[ ! $pc_args == * " --use-version=" * ]]; then
16+ pc_args=" $pc_args --use-version=java-17"
1617fi
1718
1819# add default ruleset if not specified
19- if [[ ! $pc_args == * " -R " * ]]; then
20- pc_args=" $pc_args -R /opt/ruleset.xml"
20+ if [[ ! $pc_args == * " -R= " * && ! $pc_args == * " --rulesets= " * ]]; then
21+ pc_args=" $pc_args -R= /opt/ruleset.xml"
2122fi
2223
23- # populate list of files to analise
24- files=" ${*: idx} "
25- eol=$' \n '
26- echo " ${files// / $eol } " > /tmp/list
27-
2824# shellcheck disable=SC2086
29- /opt/pmd/bin/pmd check --no-progress -f textcolor --file-list /tmp/list $pc_args
25+ /opt/pmd/bin/pmd check --no-progress -f= textcolor --file-list= /tmp/list $pc_args
You can’t perform that action at this time.
0 commit comments