Skip to content

Commit e88e4af

Browse files
committed
1 parent 3c6f4ea commit e88e4af

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

.rubocop.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
AllCops:
2+
TargetRubyVersion: 2.2
3+
14
Metrics/ModuleLength:
25
Exclude:
36
- 'spec/**/*'

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source 'https://rubygems.org'
22

33
gem "activesupport", require: false
4-
gem "rubocop", require: false
4+
gem "rubocop", "~> 0.36.0", require: false
55
gem "rubocop-rspec", require: false
66
gem "safe_yaml"
77
gem "pry", require: false

Gemfile.lock

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,47 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (4.2.4)
4+
activesupport (4.2.5.1)
55
i18n (~> 0.7)
66
json (~> 1.7, >= 1.7.7)
77
minitest (~> 5.1)
88
thread_safe (~> 0.3, >= 0.3.4)
99
tzinfo (~> 1.1)
1010
ansi (1.5.0)
1111
ast (2.2.0)
12-
astrolabe (1.3.1)
13-
parser (~> 2.2)
1412
builder (3.2.2)
1513
coderay (1.1.0)
1614
i18n (0.7.0)
1715
json (1.8.3)
1816
metaclass (0.0.4)
1917
method_source (0.8.2)
20-
minitest (5.8.0)
21-
minitest-reporters (1.0.20)
18+
minitest (5.8.4)
19+
minitest-reporters (1.1.7)
2220
ansi
2321
builder
2422
minitest (>= 5.0)
2523
ruby-progressbar
2624
mocha (1.1.0)
2725
metaclass (~> 0.0.1)
28-
parser (2.2.3.0)
29-
ast (>= 1.1, < 3.0)
26+
parser (2.3.0.2)
27+
ast (~> 2.2)
3028
powerpack (0.1.1)
31-
pry (0.10.1)
29+
pry (0.10.3)
3230
coderay (~> 1.1.0)
3331
method_source (~> 0.8.1)
3432
slop (~> 3.4)
35-
rainbow (2.0.0)
36-
rake (10.4.2)
37-
rubocop (0.35.1)
38-
astrolabe (~> 1.3)
39-
parser (>= 2.2.3.0, < 3.0)
33+
rainbow (2.1.0)
34+
rake (10.5.0)
35+
rubocop (0.36.0)
36+
parser (>= 2.3.0.0, < 3.0)
4037
powerpack (~> 0.1)
4138
rainbow (>= 1.99.1, < 3.0)
4239
ruby-progressbar (~> 1.7)
43-
tins (<= 1.6.0)
44-
rubocop-rspec (1.3.0)
40+
rubocop-rspec (1.3.1)
4541
ruby-progressbar (1.7.5)
4642
safe_yaml (1.0.4)
4743
slop (3.6.0)
4844
thread_safe (0.3.5)
49-
tins (1.6.0)
5045
tzinfo (1.2.2)
5146
thread_safe (~> 0.1)
5247

@@ -60,6 +55,9 @@ DEPENDENCIES
6055
mocha
6156
pry
6257
rake
63-
rubocop
58+
rubocop (~> 0.36.0)
6459
rubocop-rspec
6560
safe_yaml
61+
62+
BUNDLED WITH
63+
1.11.2

lib/cc/engine/rubocop.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def category(cop_name)
4343
end
4444

4545
def inspect_file(path)
46-
parsed = RuboCop::ProcessedSource.from_file(path)
46+
parsed = RuboCop::ProcessedSource.from_file(path, target_ruby_version(path))
4747
rubocop_team_for_path(path).inspect_file(parsed).each do |violation|
4848
next if violation.disabled?
4949
decorated_violation = ViolationDecorator.new(violation)
@@ -74,6 +74,11 @@ def rubocop_team_for_path(path)
7474
RuboCop::Cop::Team.new(RuboCop::Cop::Cop.all, rubocop_config)
7575
end
7676

77+
def target_ruby_version(path)
78+
config_store = rubocop_config_store.for(path)
79+
config_store["AllCops"] && config_store["AllCops"]["TargetRubyVersion"]
80+
end
81+
7782
def violation_positions(location)
7883
if location.is_a?(RuboCop::Cop::Lint::Syntax::PseudoSourceRange)
7984
first_line = location.line

0 commit comments

Comments
 (0)