Skip to content

Commit f96c1c2

Browse files
committed
Merge pull request #17 from codeclimate/devon/update-rubocop-config-to-match-styleguide
Update Rubocop config to match CC styleguide
2 parents 7d1b766 + 77ed4af commit f96c1c2

File tree

6 files changed

+115
-27
lines changed

6 files changed

+115
-27
lines changed

Diff for: .codeclimate.yml

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
engines:
2+
bundler-audit:
3+
enabled: true
4+
duplication:
5+
enabled: true
6+
config:
7+
languages:
8+
- ruby
9+
exclude_paths:
10+
- spec/
11+
fixme:
12+
enabled: true
213
rubocop:
314
enabled: true
415
exclude_fingerprints:

Diff for: .rubocop.yml

+94-17
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,120 @@
1+
################################################################################
2+
# Ruby Version
3+
################################################################################
4+
15
AllCops:
26
TargetRubyVersion: 2.2
3-
Metrics/AbcSize:
4-
Enabled: false
7+
8+
################################################################################
9+
# Metrics
10+
################################################################################
511

612
Metrics/LineLength:
713
Enabled: false
814

9-
Rails/TimeZone:
15+
Metrics/AbcSize:
1016
Enabled: false
1117

12-
SignalException:
13-
Enabled: false
18+
################################################################################
19+
# Style
20+
################################################################################
1421

15-
Style/StringLiterals:
16-
Enabled: false
22+
# Executables are conventionally named bin/foo-bar
23+
Style/FileName:
24+
Exclude:
25+
- bin/**/*
1726

27+
# We don't (currently) document our code
1828
Style/Documentation:
1929
Enabled: false
2030

31+
# Always use double-quotes to keep things simple
32+
Style/StringLiterals:
33+
EnforcedStyle: double_quotes
34+
35+
# Use a trailing comma to keep diffs clean when elements are inserted or removed
2136
Style/TrailingCommaInLiteral:
22-
Enabled: false
37+
EnforcedStyleForMultiline: comma
2338

24-
Style/ClassAndModuleChildren:
25-
Exclude:
26-
- 'spec/**/*'
39+
# We avoid GuardClause because it can result in "suprise return"
40+
Style/GuardClause:
41+
Enabled: false
2742

43+
# We avoid IfUnlessModifier because it can result in "suprise if"
2844
Style/IfUnlessModifier:
2945
Enabled: false
3046

47+
# We don't care about the fail/raise distinction
48+
Style/SignalException:
49+
EnforcedStyle: only_raise
50+
3151
Style/DotPosition:
52+
EnforcedStyle: trailing
53+
54+
# Common globals we allow
55+
Style/GlobalVars:
56+
AllowedVariables:
57+
- "$statsd"
58+
- "$mongo"
59+
- "$rollout"
60+
61+
# Allow $! in config/initializers
62+
Style/SpecialGlobalVars:
63+
Exclude:
64+
- config/initializers/**/*
65+
66+
# We have common cases where has_ and have_ make sense
67+
Style/PredicateName:
68+
Enabled: true
69+
NamePrefixBlacklist:
70+
- is_
71+
72+
# We use %w[ ], not %w( ) because the former looks like an array
73+
Style/PercentLiteralDelimiters:
74+
PreferredDelimiters:
75+
"%w": []
76+
"%W": []
77+
78+
# Allow "trivial" accessors when defined as a predicate? method
79+
Style/TrivialAccessors:
80+
AllowPredicates: true
81+
82+
Style/Next:
3283
Enabled: false
3384

34-
Style/GuardClause:
85+
# We think it's OK to use the "extend self" module pattern
86+
Style/ModuleFunction:
3587
Enabled: false
3688

37-
Style/StringLiteralsInInterpolation:
89+
################################################################################
90+
# Rails - disable things because we're primarily non-rails
91+
################################################################################
92+
93+
Rails/Delegate:
3894
Enabled: false
3995

40-
Style/PercentLiteralDelimiters:
41-
PreferredDelimiters:
42-
'%w': []
43-
'%W': []
96+
Rails/Output:
97+
Enabled: false
98+
99+
Rails/TimeZone:
100+
Enabled: false
101+
102+
################################################################################
103+
# Specs - be more lenient on length checks and block styles
104+
################################################################################
105+
106+
Metrics/ModuleLength:
107+
Exclude:
108+
- spec/**/*
109+
110+
Metrics/MethodLength:
111+
Exclude:
112+
- spec/**/*
113+
114+
Style/ClassAndModuleChildren:
115+
Exclude:
116+
- spec/**/*
117+
118+
Style/BlockDelimiters:
119+
Exclude:
120+
- spec/**/*

Diff for: Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'rspec/core/rake_task'
1+
require "rspec/core/rake_task"
22
RSpec::Core::RakeTask.new(:spec)
33

44
task default: :spec

Diff for: bin/bundler-audit

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "../lib")))
44

5-
require 'cc/engine/bundler_audit'
5+
require "cc/engine/bundler_audit"
66

77
CC::Engine::BundlerAudit::Analyzer.new(directory: "/code").run

Diff for: lib/cc/engine/bundler_audit/issue.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Issue
66
SEVERITIES = {
77
high: "critical",
88
medium: "normal",
9-
low: "info"
9+
low: "info",
1010
}.freeze
1111

1212
def initialize(result, gemfile_lock_lines)
@@ -20,19 +20,19 @@ def to_json(*a)
2020
categories: %w[Security],
2121
check_name: "Insecure Dependency",
2222
content: {
23-
body: content_body
23+
body: content_body,
2424
},
2525
description: advisory.title,
2626
location: {
2727
path: "Gemfile.lock",
2828
lines: {
2929
begin: line_number,
30-
end: line_number
31-
}
30+
end: line_number,
31+
},
3232
},
3333
remediation_points: remediation_points,
3434
severity: severity,
35-
type: "Issue"
35+
type: "Issue",
3636
}.to_json(a)
3737
end
3838

@@ -45,7 +45,7 @@ def content_body
4545
"**Advisory**: #{identifier}",
4646
"**Criticality**: #{advisory.criticality.capitalize}",
4747
"**URL**: #{advisory.url}",
48-
"**Solution**: #{solution}"
48+
"**Solution**: #{solution}",
4949
].join("\n\n")
5050
end
5151

Diff for: spec/cc/engine/bundler_audit/analyzer_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module CC::Engine::BundlerAudit
77
directory = fixture_directory("no_gemfile_lock")
88
io = StringIO.new
99

10-
expect { Analyzer.new(directory: directory, io: io).run }
11-
.to raise_error(Analyzer::GemfileLockNotFound)
10+
expect { Analyzer.new(directory: directory, io: io).run }.
11+
to raise_error(Analyzer::GemfileLockNotFound)
1212
end
1313

1414
it "emits issues for Gemfile.lock problems" do

0 commit comments

Comments
 (0)