Skip to content

Commit 5426ed9

Browse files
committed
🏕 Add linting with rubocop / gh actions
1 parent a87fafe commit 5426ed9

File tree

9 files changed

+163
-7
lines changed

9 files changed

+163
-7
lines changed

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint
2+
on: [push]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
ruby:
9+
- '2.5'
10+
- '2.7'
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v1
14+
- name: Setup Ruby
15+
uses: actions/setup-ruby@v1
16+
with:
17+
ruby-version: ${{ matrix.ruby }}
18+
- name: Bundle
19+
run: |
20+
./bin/setup
21+
- name: Rubocop
22+
run: |
23+
./bin/bundle exec rubocop --parallel

.rubocop.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
inherit_from: .rubocop_todo.yml
2+
3+
AllCops:
4+
Exclude:
5+
- "test/**/*"
6+
- "bin/**/*"
7+
- "*.gemspec"
8+
- Rakefile
9+
10+
Style/Documentation:
11+
Enabled: false
12+
13+
Style/FrozenStringLiteralComment: # PENDING: [Ruby3.x] Remove this, autofix, test, conform.
14+
Enabled: false
15+
16+
Layout/EmptyLinesAroundAttributeAccessor:
17+
Enabled: true
18+
19+
Layout/EmptyLinesAroundClassBody:
20+
Enabled: false
21+
22+
Layout/EmptyLinesAroundModuleBody:
23+
Enabled: false
24+
25+
Layout/SpaceAroundMethodCallOperator:
26+
Enabled: true
27+
28+
Lint/DeprecatedOpenSSLConstant:
29+
Enabled: true
30+
31+
Lint/DuplicateElsifCondition:
32+
Enabled: true
33+
34+
Lint/MixedRegexpCaptureTypes:
35+
Enabled: true
36+
37+
Lint/RaiseException:
38+
Enabled: true
39+
40+
Lint/StructNewOverride:
41+
Enabled: true
42+
43+
Style/AccessorGrouping:
44+
Enabled: true
45+
46+
Style/ArrayCoercion:
47+
Enabled: true
48+
49+
Style/BisectedAttrAccessor:
50+
Enabled: true
51+
52+
Style/CaseLikeIf:
53+
Enabled: true
54+
55+
Style/ExponentialNotation:
56+
Enabled: true
57+
58+
Style/HashAsLastArrayItem:
59+
Enabled: true
60+
61+
Style/HashEachMethods:
62+
Enabled: true
63+
64+
Style/HashLikeCase:
65+
Enabled: true
66+
67+
Style/HashTransformKeys:
68+
Enabled: true
69+
70+
Style/HashTransformValues:
71+
Enabled: true
72+
73+
Style/RedundantAssignment:
74+
Enabled: true
75+
76+
Style/RedundantFetchBlock:
77+
Enabled: true
78+
79+
Style/RedundantFileExtensionInRequire:
80+
Enabled: true
81+
82+
Style/RedundantRegexpCharacterClass:
83+
Enabled: true
84+
85+
Style/RedundantRegexpEscape:
86+
Enabled: true
87+
88+
Style/SlicingWithRange:
89+
Enabled: true

.rubocop_todo.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2020-07-30 18:19:25 UTC using RuboCop version 0.88.0.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 1
10+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
11+
Metrics/MethodLength:
12+
Max: 15
13+
14+
# Offense count: 1
15+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
16+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
17+
Naming/FileName:
18+
Exclude:
19+
- 'lib/aws-embedded-metrics-customink.rb'

Gemfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
source "https://rubygems.org"
1+
source 'https://rubygems.org'
22
gemspec
33

4-
gem 'rake'
54
gem 'minitest'
5+
gem 'rake'
6+
gem 'rubocop'
67

78
group :test do
89
gem 'mocha'

Gemfile.lock

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,34 @@ PATH
66
GEM
77
remote: https://rubygems.org/
88
specs:
9+
ast (2.4.1)
910
coderay (1.1.3)
1011
method_source (1.0.0)
1112
minitest (5.14.1)
1213
mocha (1.11.2)
14+
parallel (1.19.2)
15+
parser (2.7.1.4)
16+
ast (~> 2.4.1)
1317
pry (0.13.1)
1418
coderay (~> 1.1)
1519
method_source (~> 1.0)
20+
rainbow (3.0.0)
1621
rake (13.0.1)
22+
regexp_parser (1.7.1)
23+
rexml (3.2.3)
24+
rubocop (0.88.0)
25+
parallel (~> 1.10)
26+
parser (>= 2.7.1.1)
27+
rainbow (>= 2.2.2, < 4.0)
28+
regexp_parser (>= 1.7)
29+
rexml
30+
rubocop-ast (>= 0.1.0, < 1.0)
31+
ruby-progressbar (~> 1.7)
32+
unicode-display_width (>= 1.4.0, < 2.0)
33+
rubocop-ast (0.2.0)
34+
parser (>= 2.7.0.1)
35+
ruby-progressbar (1.10.1)
36+
unicode-display_width (1.7.0)
1737

1838
PLATFORMS
1939
ruby
@@ -24,6 +44,7 @@ DEPENDENCIES
2444
mocha
2545
pry
2646
rake
47+
rubocop
2748

2849
BUNDLED WITH
2950
2.1.2

bin/bundle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env ruby
2+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3+
load Gem.bin_path('bundler', 'bundle')

lib/aws-embedded-metrics-customink.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def logger
2727
end
2828
end
2929

30-
extend self
30+
module_function :config, :configure, :reconfigure, :logger
3131

3232
end
3333
end

lib/aws-embedded-metrics-customink/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def config
1818
@config ||= Configuration.new
1919
end
2020

21-
extend self
21+
module_function :configure, :reconfigure, :config
2222

2323
class Configuration
2424

lib/aws-embedded-metrics-customink/logger.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def put_dimension(name, value)
2727
end
2828

2929
def put_metric(name, value, unit = nil)
30-
@metrics << { 'Name' => name }.tap { |m|
30+
@metrics << { 'Name' => name }.tap do |m|
3131
m['Unit'] = unit if unit
32-
}
32+
end
3333
set_property name, value
3434
end
3535

@@ -39,7 +39,7 @@ def set_property(name, value)
3939
end
4040

4141
def empty?
42-
[@dimensions, @metrics, @properties].all? { |x| x.empty? }
42+
[@dimensions, @metrics, @properties].all?(&:empty?)
4343
end
4444

4545
def message

0 commit comments

Comments
 (0)