Skip to content

Commit d10e25c

Browse files
committed
Merge pull request #91 from adangel:filter-baseline
Filter baseline based on patch config #91
2 parents 537cb0a + 03d76da commit d10e25c

File tree

12 files changed

+116
-17
lines changed

12 files changed

+116
-17
lines changed

History.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Fixed Issues
88

99
* [#89](https://github.com/pmd/pmd-regression-tester/pull/89): Make it possible to select a subpath of cloned directory
10+
* [#91](https://github.com/pmd/pmd-regression-tester/pull/91): Filter baseline based on patch config
1011

1112
## External Contributions
1213

README.rdoc

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,30 @@ on a list of standard projects(Spring Framework, Hibernate, Solr, etc.)
2020
== SYNOPSIS:
2121

2222
=== Options:
23-
-r, --local-git-repo path to the local PMD repository
24-
-b, --base-branch name of the base branch in local PMD repository
25-
-p, --patch-branch name of the patch branch in local PMD repository
26-
-bc, --base-config path to the base PMD configuration file default:PMDTESTER_INSTALLED_DIR/config/all-java.xml
27-
-pc, --patch-config path to the patch PMD configuration file default:PMDTESTER_INSTALLED_DIR/config/all-java.xml
28-
-c, --config path to the base and patch PMD configuration file
29-
-l, --list-of-project path to the file which contains the list of standard projects default:PMDTESTER_INSTALLED_DIR/config/project-list.xml
30-
-m, --mode the mode of the tool: 'local', 'online' or 'single'
23+
-r, --local-git-repo path to the local PMD repository
24+
-b, --base-branch name of the base branch in local PMD repository
25+
-p, --patch-branch name of the patch branch in local PMD repository
26+
-bc, --base-config path to the base PMD configuration file
27+
-pc, --patch-config path to the patch PMD configuration file
28+
-c, --config path to the base and patch PMD configuration file
29+
-l, --list-of-project path to the file which contains the list of standard projects
30+
-m, --mode the mode of the tool: 'local', 'online' or 'single'
3131
single: Set this option to 'single' if your patch branch contains changes
3232
for any option that can't work on master/base branch
3333
online: Set this option to 'online' if you want to download
3434
the PMD report of master/base branch rather than generating it locally
3535
local: Default option is 'local', PMD reports for the base and patch branches are generated locally.
3636

37-
-t, --threads Sets the number of threads used by PMD. Set threads to 0 to disable multi-threading processing. default:1
38-
-f, --html-flag whether to not generate the html diff report in single mode
39-
-a, --auto-gen-config whether to generate configurations automatically based on branch differences,this option only works in online and local mode
40-
--keep-reports whether to keep old reports and skip running PMD again if possible
41-
-d, --debug whether change log level to DEBUG to see more information
42-
--error-recovery enable error recovery mode when executing PMD. Might help to analyze errors.
43-
--baseline-download-url download url prefix from where to download the baseline in online mode default:https://sourceforge.net/projects/pmd/files/pmd-regression-tester/
44-
-v, --version
45-
-h, --help
37+
-t, --threads Sets the number of threads used by PMD. Set threads to 0 to disable multi-threading processing.
38+
-f, --html-flag whether to not generate the html diff report in single mode
39+
-a, --auto-gen-config whether to generate configurations automatically based on branch differences,this option only works in online and local mode
40+
--filter-with-patch-config whether to use patch config to filter baseline result as if --auto-gen-config has been used. This option only works in online mode.
41+
--keep-reports whether to keep old reports and skip running PMD again if possible
42+
-d, --debug whether change log level to DEBUG to see more information
43+
--error-recovery enable error recovery mode when executing PMD. Might help to analyze errors.
44+
--baseline-download-url download url prefix from where to download the baseline in online mode
45+
-v, --version
46+
-h, --help
4647

4748
=== Quick start
4849

lib/pmdtester/builders/rule_set_builder.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def build
3333
rule_refs
3434
end
3535

36+
def calculate_filter_set
37+
output_filter_set(ALL_CATEGORIES)
38+
end
39+
3640
def output_filter_set(rule_refs)
3741
if rule_refs == ALL_CATEGORIES
3842
if @options.mode == Options::ONLINE

lib/pmdtester/parsers/options.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Options
2929
attr_reader :threads
3030
attr_reader :html_flag
3131
attr_reader :auto_config_flag
32+
attr_reader :filter_with_patch_config
3233
attr_reader :debug_flag
3334
attr_accessor :filter_set
3435
attr_reader :keep_reports
@@ -48,6 +49,7 @@ def initialize(argv)
4849
@threads = options[:t]
4950
@html_flag = options[:f]
5051
@auto_config_flag = options[:a]
52+
@filter_with_patch_config = options.filter_with_patch_config?
5153
@debug_flag = options[:d]
5254
@filter_set = nil
5355
@keep_reports = options.keep_reports?
@@ -100,6 +102,9 @@ def parse(argv)
100102
o.bool '-a', '--auto-gen-config',
101103
'whether to generate configurations automatically based on branch differences,' \
102104
'this option only works in online and local mode'
105+
o.bool '--filter-with-patch-config',
106+
'whether to use patch config to filter baseline result as if --auto-gen-config ' \
107+
'has been used. This option only works in online mode.'
103108
o.bool '--keep-reports',
104109
'whether to keep old reports and skip running PMD again if possible'
105110
o.bool '-d', '--debug',

lib/pmdtester/runner.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def run_online_mode
5959
@options.patch_config = "#{baseline_path}/config.xml"
6060
else
6161
logger.info "Using config #{@options.patch_config} which might differ from baseline"
62+
RuleSetBuilder.new(@options).calculate_filter_set if @options.filter_with_patch_config
6263
end
6364

6465
patch_branch_details = create_pmd_report(config: @options.patch_config, branch: @options.patch_branch)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd" name="Dynamic PmdTester Ruleset">
3+
<description>The ruleset generated by PmdTester dynamically</description>
4+
<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/>
5+
</ruleset>
4.14 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd" name="Dynamic PmdTester Ruleset">
3+
<description>The ruleset generated by PmdTester dynamically</description>
4+
<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/>
5+
</ruleset>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<pmd xmlns="http://pmd.sourceforge.net/report/2.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://pmd.sourceforge.net/report/2.0.0 http://pmd.sourceforge.net/report_2_0_0.xsd"
5+
version="6.3.0-SNAPSHOT" timestamp="2018-04-16T22:41:45.065">
6+
<file name="Base1.java">
7+
<violation beginline="51" endline="51" begincolumn="9" endcolumn="46" rule="ConsecutiveLiteralAppends" ruleset="Performance" package="org.springframework.aop" class="Pointcut" variable="TRUE" externalInfoUrl="http://pmd.sourceforge.net/snapshot/pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass" priority="3">
8+
This stays in the report.
9+
</violation>
10+
<violation beginline="151" endline="151" begincolumn="9" endcolumn="46" rule="ConsecutiveLiteralAppends" ruleset="Performance" package="org.springframework.aop" class="Pointcut" variable="TRUE" externalInfoUrl="http://pmd.sourceforge.net/snapshot/pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass" priority="3">
11+
This is a new violation.
12+
</violation>
13+
</file>
14+
</pmd>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
3+
<projectlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="projectlist_1_1_0.xsd">
5+
<description>Standard Projects</description>
6+
7+
<project>
8+
<name>checkstyle</name>
9+
<type>git</type>
10+
<connection>https://github.com/checkstyle/checkstyle</connection>
11+
<exclude-pattern>**/src/test/resources-noncompilable/**/*</exclude-pattern>
12+
<exclude-pattern>**/src/test/resources/**/*</exclude-pattern>
13+
<build-command></build-command>
14+
<auxclasspath-command>echo -n "$(pwd)/target/classes:"</auxclasspath-command>
15+
</project>
16+
17+
</projectlist>

0 commit comments

Comments
 (0)