Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from customink/drinks/lint
Browse files Browse the repository at this point in the history
🏕 Add linting with rubocop / gh actions
  • Loading branch information
drinks committed Jul 31, 2020
2 parents a87fafe + 5426ed9 commit 455ba26
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 7 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint
on: [push]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby:
- '2.5'
- '2.7'
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Bundle
run: |
./bin/setup
- name: Rubocop
run: |
./bin/bundle exec rubocop --parallel
89 changes: 89 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
inherit_from: .rubocop_todo.yml

AllCops:
Exclude:
- "test/**/*"
- "bin/**/*"
- "*.gemspec"
- Rakefile

Style/Documentation:
Enabled: false

Style/FrozenStringLiteralComment: # PENDING: [Ruby3.x] Remove this, autofix, test, conform.
Enabled: false

Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true

Layout/EmptyLinesAroundClassBody:
Enabled: false

Layout/EmptyLinesAroundModuleBody:
Enabled: false

Layout/SpaceAroundMethodCallOperator:
Enabled: true

Lint/DeprecatedOpenSSLConstant:
Enabled: true

Lint/DuplicateElsifCondition:
Enabled: true

Lint/MixedRegexpCaptureTypes:
Enabled: true

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

Style/AccessorGrouping:
Enabled: true

Style/ArrayCoercion:
Enabled: true

Style/BisectedAttrAccessor:
Enabled: true

Style/CaseLikeIf:
Enabled: true

Style/ExponentialNotation:
Enabled: true

Style/HashAsLastArrayItem:
Enabled: true

Style/HashEachMethods:
Enabled: true

Style/HashLikeCase:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

Style/RedundantAssignment:
Enabled: true

Style/RedundantFetchBlock:
Enabled: true

Style/RedundantFileExtensionInRequire:
Enabled: true

Style/RedundantRegexpCharacterClass:
Enabled: true

Style/RedundantRegexpEscape:
Enabled: true

Style/SlicingWithRange:
Enabled: true
19 changes: 19 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-07-30 18:19:25 UTC using RuboCop version 0.88.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
Metrics/MethodLength:
Max: 15

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# 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
Naming/FileName:
Exclude:
- 'lib/aws-embedded-metrics-customink.rb'
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
source "https://rubygems.org"
source 'https://rubygems.org'
gemspec

gem 'rake'
gem 'minitest'
gem 'rake'
gem 'rubocop'

group :test do
gem 'mocha'
Expand Down
21 changes: 21 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,34 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.1)
coderay (1.1.3)
method_source (1.0.0)
minitest (5.14.1)
mocha (1.11.2)
parallel (1.19.2)
parser (2.7.1.4)
ast (~> 2.4.1)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
rainbow (3.0.0)
rake (13.0.1)
regexp_parser (1.7.1)
rexml (3.2.3)
rubocop (0.88.0)
parallel (~> 1.10)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.1.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.2.0)
parser (>= 2.7.0.1)
ruby-progressbar (1.10.1)
unicode-display_width (1.7.0)

PLATFORMS
ruby
Expand All @@ -24,6 +44,7 @@ DEPENDENCIES
mocha
pry
rake
rubocop

BUNDLED WITH
2.1.2
3 changes: 3 additions & 0 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
2 changes: 1 addition & 1 deletion lib/aws-embedded-metrics-customink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def logger
end
end

extend self
module_function :config, :configure, :reconfigure, :logger

end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/aws-embedded-metrics-customink/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def config
@config ||= Configuration.new
end

extend self
module_function :configure, :reconfigure, :config

class Configuration

Expand Down
6 changes: 3 additions & 3 deletions lib/aws-embedded-metrics-customink/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def put_dimension(name, value)
end

def put_metric(name, value, unit = nil)
@metrics << { 'Name' => name }.tap { |m|
@metrics << { 'Name' => name }.tap do |m|
m['Unit'] = unit if unit
}
end
set_property name, value
end

Expand All @@ -39,7 +39,7 @@ def set_property(name, value)
end

def empty?
[@dimensions, @metrics, @properties].all? { |x| x.empty? }
[@dimensions, @metrics, @properties].all?(&:empty?)
end

def message
Expand Down

0 comments on commit 455ba26

Please sign in to comment.