Skip to content

Commit 0afd61c

Browse files
kkejakolehm
authored andcommitted
Add Rubocop (k8s-ruby#49)
1 parent 6e9a7ba commit 0afd61c

26 files changed

+527
-256
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
/pkg/
77
/spec/reports/
88
/tmp/
9+
Gemfile.lock
10+
.ruby-version
911

1012
# rspec failure tracking
1113
.rspec_status
14+
.rspec-local
15+

.rubocop.relaxed.yml

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Relaxed.Ruby.Style
2+
## Version 2.2
3+
4+
Style/Alias:
5+
Enabled: false
6+
StyleGuide: http://relaxed.ruby.style/#stylealias
7+
8+
Style/AsciiComments:
9+
Enabled: false
10+
StyleGuide: http://relaxed.ruby.style/#styleasciicomments
11+
12+
Style/BeginBlock:
13+
Enabled: false
14+
StyleGuide: http://relaxed.ruby.style/#stylebeginblock
15+
16+
Style/BlockDelimiters:
17+
Enabled: false
18+
StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
19+
20+
Style/CommentAnnotation:
21+
Enabled: false
22+
StyleGuide: http://relaxed.ruby.style/#stylecommentannotation
23+
24+
Style/Documentation:
25+
Enabled: false
26+
StyleGuide: http://relaxed.ruby.style/#styledocumentation
27+
28+
Layout/DotPosition:
29+
Enabled: false
30+
StyleGuide: http://relaxed.ruby.style/#layoutdotposition
31+
32+
Style/DoubleNegation:
33+
Enabled: false
34+
StyleGuide: http://relaxed.ruby.style/#styledoublenegation
35+
36+
Style/EndBlock:
37+
Enabled: false
38+
StyleGuide: http://relaxed.ruby.style/#styleendblock
39+
40+
Style/FormatString:
41+
Enabled: false
42+
StyleGuide: http://relaxed.ruby.style/#styleformatstring
43+
44+
Style/IfUnlessModifier:
45+
Enabled: false
46+
StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
47+
48+
Style/Lambda:
49+
Enabled: false
50+
StyleGuide: http://relaxed.ruby.style/#stylelambda
51+
52+
Style/ModuleFunction:
53+
Enabled: false
54+
StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
55+
56+
Style/MultilineBlockChain:
57+
Enabled: false
58+
StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
59+
60+
Style/NegatedIf:
61+
Enabled: false
62+
StyleGuide: http://relaxed.ruby.style/#stylenegatedif
63+
64+
Style/NegatedWhile:
65+
Enabled: false
66+
StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
67+
68+
Style/ParallelAssignment:
69+
Enabled: false
70+
StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
71+
72+
Style/PercentLiteralDelimiters:
73+
Enabled: false
74+
StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
75+
76+
Style/PerlBackrefs:
77+
Enabled: false
78+
StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
79+
80+
Style/Semicolon:
81+
Enabled: false
82+
StyleGuide: http://relaxed.ruby.style/#stylesemicolon
83+
84+
Style/SignalException:
85+
Enabled: false
86+
StyleGuide: http://relaxed.ruby.style/#stylesignalexception
87+
88+
Style/SingleLineBlockParams:
89+
Enabled: false
90+
StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
91+
92+
Style/SingleLineMethods:
93+
Enabled: false
94+
StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
95+
96+
Layout/SpaceBeforeBlockBraces:
97+
Enabled: false
98+
StyleGuide: http://relaxed.ruby.style/#layoutspacebeforeblockbraces
99+
100+
Layout/SpaceInsideParens:
101+
Enabled: false
102+
StyleGuide: http://relaxed.ruby.style/#layoutspaceinsideparens
103+
104+
Style/SpecialGlobalVars:
105+
Enabled: false
106+
StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
107+
108+
Style/StringLiterals:
109+
Enabled: false
110+
StyleGuide: http://relaxed.ruby.style/#stylestringliterals
111+
112+
# Style/TrailingCommaInArguments:
113+
# Enabled: false
114+
# StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarguments
115+
#
116+
# Style/TrailingCommaInArrayLiteral:
117+
# Enabled: false
118+
# StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarrayliteral
119+
#
120+
# Style/TrailingCommaInHashLiteral:
121+
# Enabled: false
122+
# StyleGuide: http://relaxed.ruby.style/#styletrailingcommainhashliteral
123+
124+
Style/WhileUntilModifier:
125+
Enabled: false
126+
StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
127+
128+
Style/WordArray:
129+
Enabled: false
130+
StyleGuide: http://relaxed.ruby.style/#stylewordarray
131+
132+
Lint/AmbiguousRegexpLiteral:
133+
Enabled: false
134+
StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
135+
136+
Lint/AssignmentInCondition:
137+
Enabled: false
138+
StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
139+
140+
Metrics/AbcSize:
141+
Enabled: false
142+
143+
Metrics/BlockNesting:
144+
Enabled: false
145+
146+
Metrics/ClassLength:
147+
Enabled: false
148+
149+
Metrics/ModuleLength:
150+
Enabled: false
151+
152+
Metrics/CyclomaticComplexity:
153+
Enabled: false
154+
155+
Metrics/LineLength:
156+
Enabled: false
157+
158+
Metrics/MethodLength:
159+
Enabled: false
160+
161+
Metrics/ParameterLists:
162+
Enabled: false
163+
164+
Metrics/PerceivedComplexity:
165+
Enabled: false
166+
167+
Naming/VariableName: # disabled because camelCased params are used in kube api/yamls
168+
Enabled: false
169+
170+
Naming/UncommunicativeMethodParamName: # disabled because camelCased params are used in kube api/yamls
171+
Enabled: false
172+
173+
Naming/FileName:
174+
Enabled: true
175+
Exclude:
176+
- lib/k8s-client.rb # ignored because gem name is k8s-client, so 'require k8s-client' and gem 'k8s-client' in Gemfile work

.rubocop.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
inherit_from: .rubocop.relaxed.yml
2+
3+
AllCops:
4+
Exclude:
5+
- spec/**/*
6+
- Gemfile
7+
- "*.gemspec"
8+
- bundler/**/*
9+
TargetRubyVersion: 2.4
10+
11+
Style/PercentLiteralDelimiters:
12+
PreferredDelimiters:
13+
default: ()
14+
'%i': '()'
15+
'%I': '()'
16+
'%r': '{}'
17+
'%w': '()'
18+
'%W': '()'
19+
20+
Style/FormatString:
21+
EnforcedStyle: percent
22+
23+
Style/FrozenStringLiteralComment:
24+
EnforcedStyle: always
25+
26+
Style/WordArray:
27+
Enabled: true
28+
MinSize: 3
29+
30+
Style/SymbolArray:
31+
Enabled: true
32+
MinSize: 3
33+
34+
Gemspec/OrderedDependencies:
35+
Enabled: false
36+
37+
Style/PerlBackrefs:
38+
Enabled: true
39+
40+
Layout/SpaceInsideParens:
41+
Enabled: true
42+
43+
Style/SpecialGlobalVars:
44+
Enabled: true
45+
46+
Style/Alias:
47+
Enabled: true
48+
49+
Style/BeginBlock:
50+
Enabled: true
51+
52+
Naming/UncommunicativeMethodParamName:
53+
AllowedNames:
54+
- cn
55+
56+
Metrics/BlockLength:
57+
Enabled: false

Rakefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
# frozen_string_literal: true
2+
13
require "bundler/gem_tasks"
24
require "rspec/core/rake_task"
5+
require 'rubocop/rake_task'
36

47
RSpec::Core::RakeTask.new(:spec)
58

6-
task :default => :spec
9+
RuboCop::RakeTask.new(:rubocop).tap do |task|
10+
task.options = %w(--fail-level A -S --format c)
11+
if RUBY_ENGINE == 'ruby' && RbConfig::CONFIG['host_os'] !~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
12+
task.options << '--parallel'
13+
end
14+
end
15+
16+
task default: [:spec, :rubocop]

0 commit comments

Comments
 (0)