Skip to content

Commit 63d3793

Browse files
committed
preparing for release of pmdtester-1.0.0.beta3
1 parent bfe46f7 commit 63d3793

File tree

6 files changed

+34
-28
lines changed

6 files changed

+34
-28
lines changed

.rubocop.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ AllCops:
88

99
Metrics/LineLength:
1010
Max: 100
11+
12+
Metrics/MethodLength:
13+
Exclude:
14+
- 'lib/pmdtester/parsers/options.rb'
15+
16+
Metrics/BlockLength:
17+
Exclude:
18+
- 'lib/pmdtester/parsers/options.rb'

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ hoe = Hoe.spec 'pmdtester' do
2828
['rubocop', '~> 0.56.0'],
2929
['test-unit', '~> 3.2.3']
3030
]
31+
self.spec_extras[:required_rubygems_version] = '>= 2.4.1'
3132

3233
license 'BSD-2-Clause'
3334
end

lib/pmdtester/builders/pmd_report_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def generate_pmd_reports
9797

9898
sum_time = 0
9999
@projects.each do |project|
100-
logger.info "Generating #{project.name}'s PMD report'"
100+
logger.info "Generating #{project.name}'s PMD report"
101101
execution_time, end_time =
102102
generate_pmd_report(project.local_source_path,
103103
project.get_pmd_report_path(@pmd_branch_name))

lib/pmdtester/parsers/options.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class Options
1414
LOCAL = 'local'
1515
ONLINE = 'online'
1616
SINGLE = 'single'
17+
DEFAULT_CONFIG_PATH = ResourceLocator.locate('config/all-java.xml')
18+
DEFAULT_LIST_PATH = ResourceLocator.locate('config/project-list.xml')
1719

1820
attr_reader :local_git_repo
1921
attr_reader :base_branch
@@ -68,11 +70,14 @@ def parse(argv)
6870
o.string '-b', '--base-branch', 'name of the base branch in local PMD repository'
6971
o.string '-p', '--patch-branch',
7072
'name of the patch branch in local PMD repository'
71-
o.string '-bc', '--base-config', 'path to the base PMD configuration file'
72-
o.string '-pc', '--patch-config', 'path to the patch PMD configuration file'
73+
o.string '-bc', '--base-config', 'path to the base PMD configuration file',
74+
default: DEFAULT_CONFIG_PATH
75+
o.string '-pc', '--patch-config', 'path to the patch PMD configuration file',
76+
default: DEFAULT_CONFIG_PATH
7377
o.string '-c', '--config', 'path to the base and patch PMD configuration file'
7478
o.string '-l', '--list-of-project',
75-
'path to the file which contains the list of standard projects'
79+
'path to the file which contains the list of standard projects',
80+
default: DEFAULT_LIST_PATH
7681
o.string '-m', '--mode', mode_message, default: 'local'
7782
o.bool '-f', '--html-flag',
7883
'whether to not generate the html diff report in single mode'
@@ -111,20 +116,17 @@ def check_options
111116
def check_local_options
112117
check_option(LOCAL, 'base branch name', @base_branch)
113118
check_option(LOCAL, 'base branch config path', @base_config) unless @auto_config_flag
114-
check_option(LOCAL, 'patch branch name', @patch_branch)
115119
check_option(LOCAL, 'patch branch config path', @patch_config) unless @auto_config_flag
116120
check_option(LOCAL, 'list of projects file path', @project_list)
117121
end
118122

119123
def check_single_options
120-
check_option(SINGLE, 'patch branch name', @patch_branch)
121124
check_option(SINGLE, 'patch branch config path', @patch_config)
122125
check_option(SINGLE, 'list of projects file path', @project_list)
123126
end
124127

125128
def check_online_options
126129
check_option(ONLINE, 'base branch name', @base_branch)
127-
check_option(ONLINE, 'patch branch name', @patch_branch)
128130
end
129131

130132
def check_common_options

lib/pmdtester/runner.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def run
1818
when Options::SINGLE
1919
run_single_mode
2020
end
21+
introduce_new_pmd_error?
2122
end
2223

2324
def run_local_mode
@@ -116,5 +117,12 @@ def build_diff_html_reports
116117
def get_projects(file_path)
117118
@projects = ProjectsParser.new.parse(file_path)
118119
end
120+
121+
def introduce_new_pmd_error?
122+
@projects.each do |project|
123+
return true if project.introduce_new_errors?
124+
end
125+
false
126+
end
119127
end
120128
end

test/test_options.rb

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ def test_long_option
3030
assert_equal('config/project_list.txt', opts.project_list)
3131
end
3232

33+
def test_default_value
34+
command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master]
35+
opts = Options.new(command_line)
36+
assert_equal(Options::DEFAULT_CONFIG_PATH, opts.base_config)
37+
assert_equal(Options::DEFAULT_CONFIG_PATH, opts.patch_config)
38+
assert_equal(Options::DEFAULT_LIST_PATH, opts.project_list)
39+
end
40+
3341
def test_single_mode
3442
command_line =
3543
%w[-r /path/to/repo -p master -pc config.xml -l list.xml -f -m single]
@@ -62,27 +70,6 @@ def test_local_miss_base_name
6270
parse_and_assert_error_messages(argv, expect)
6371
end
6472

65-
def test_local_miss_base_config
66-
argv = %w[-r target/repositories/pmd -b master
67-
-p pmd_releases/6.1.0 -pc config/design.xml -l test/resources/project-test.xml]
68-
expect = 'base branch config path is required in local mode.'
69-
parse_and_assert_error_messages(argv, expect)
70-
end
71-
72-
def test_local_miss_patch_config
73-
argv = %w[-r target/repositories/pmd -bc config/design.xml
74-
-p pmd_releases/6.1.0 -l test/resources/project-test.xml]
75-
expect = 'base branch name is required in local mode.'
76-
parse_and_assert_error_messages(argv, expect)
77-
end
78-
79-
def test_single_miss_patch_config
80-
argv = %w[-r target/repositories/pmd -m single
81-
-p pmd_releases/6.1.0 -l test/resources/project-test.xml]
82-
expect = 'patch branch config path is required in single mode.'
83-
parse_and_assert_error_messages(argv, expect)
84-
end
85-
8673
def test_online_miss_base_name
8774
argv = %w[-r target/repositories/pmd -p pmd_releases/6.1.0 -m online]
8875
expect = 'base branch name is required in online mode.'

0 commit comments

Comments
 (0)