Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/upgrade rubocop #36

Merged
merged 8 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: run tests
command: |
mkdir /tmp/test-results
bundle exec rubocop --format progress -r $(bundle info --path rubocop-junit-formatter)/lib/rubocop/formatter/junit_formatter.rb --format RuboCop::Formatter::JUnitFormatter --out /tmp/test-results/rubocop.xml
bundle exec rubocop --format progress --format junit --out /tmp/test-results/rubocop.xml
bundle exec rspec --format progress \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
Expand All @@ -32,10 +32,6 @@ jobs:
- store_artifacts:
path: /tmp/test-results
destination: test-results
ruby-23:
<<: *build
docker:
- image: circleci/ruby:2.3
ruby-24:
<<: *build
docker:
Expand All @@ -56,7 +52,6 @@ workflows:
version: 2
ruby-multi-build:
jobs:
- ruby-23
- ruby-24
- ruby-25
- ruby-26
Expand Down
161 changes: 153 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ require:
AllCops:
TargetRubyVersion: 2.4

Metrics/LineLength:
Max: 120

Metrics/ClassLength:
Max: 300

Expand All @@ -29,7 +26,10 @@ Style/CollectionMethods:
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: no_comma

Style/TrailingCommaInLiteral:
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma

Style/Documentation:
Expand All @@ -38,15 +38,15 @@ Style/Documentation:
Style/RedundantSelf:
Enabled: false

Layout/LineLength:
Max: 120

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Layout/IndentHash:
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

Style/BracesAroundHashParameters:
Enabled: false

RSpec/NestedGroups:
Max: 5

Expand All @@ -65,3 +65,148 @@ RSpec/MessageSpies:
RSpec/AnyInstance:
Exclude:
- 'spec/scnnr/connection_spec.rb'

RSpec/ContextWording:
Prefixes:
- when
- with
- without
- and

RSpec/MultipleMemoizedHelpers:
Max: 7
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we use a lot of let in this project, I chose 7 to avoid most of our use cases (default is 5) and applied code changes to the rest.

For more details about this change by Rubocop-Rspec:
- rubocop/rubocop-rspec#863
- rubocop/rubocop-rspec#862
- https://thoughtbot.com/blog/lets-not


Layout/EmptyLinesAroundAttributeAccessor: # (new in 0.83)
Enabled: true

Layout/SpaceAroundMethodCallOperator: # (new in 0.82)
Enabled: true

Lint/BinaryOperatorWithIdenticalOperands: # (new in 0.89)
Enabled: true

Lint/DeprecatedOpenSSLConstant: # (new in 0.84)
Enabled: true

Lint/DuplicateElsifCondition: # (new in 0.88)
Enabled: true

Lint/DuplicateRequire: # (new in 0.90)
Enabled: true

Lint/DuplicateRescueException: # (new in 0.89)
Enabled: true

Lint/EmptyConditionalBody: # (new in 0.89)
Enabled: true

Lint/EmptyFile: # (new in 0.90)
Enabled: true

Lint/FloatComparison: # (new in 0.89)
Enabled: true

Lint/MissingSuper: # (new in 0.89)
Enabled: true

Lint/MixedRegexpCaptureTypes: # (new in 0.85)
Enabled: true

Lint/OutOfRangeRegexpRef: # (new in 0.89)
Enabled: true

Lint/RaiseException: # (new in 0.81)
Enabled: true

Lint/SelfAssignment: # (new in 0.89)
Enabled: true

Lint/StructNewOverride: # (new in 0.81)
Enabled: true

Lint/TopLevelReturnWithArgument: # (new in 0.89)
Enabled: true

Lint/TrailingCommaInAttributeDeclaration: # (new in 0.90)
Enabled: true

Lint/UnreachableLoop: # (new in 0.89)
Enabled: true

Lint/UselessMethodDefinition: # (new in 0.90)
Enabled: true

Style/AccessorGrouping: # (new in 0.87)
Enabled: true

Style/ArrayCoercion: # (new in 0.88)
Enabled: true

Style/BisectedAttrAccessor: # (new in 0.87)
Enabled: true

Style/CaseLikeIf: # (new in 0.88)
Enabled: true

Style/CombinableLoops: # (new in 0.90)
Enabled: true

Style/ExplicitBlockArgument: # (new in 0.89)
Enabled: true

Style/ExponentialNotation: # (new in 0.82)
Enabled: true

Style/GlobalStdStream: # (new in 0.89)
Enabled: true

Style/HashAsLastArrayItem: # (new in 0.88)
Enabled: true

Style/HashEachMethods: # (new in 0.80)
Enabled: true

Style/HashLikeCase: # (new in 0.88)
Enabled: true

Style/HashTransformKeys: # (new in 0.80)
Enabled: true

Style/HashTransformValues: # (new in 0.80)
Enabled: true

Style/KeywordParametersOrder: # (new in 0.90)
Enabled: true

Style/OptionalBooleanParameter: # (new in 0.89)
Enabled: true

Style/RedundantAssignment: # (new in 0.87)
Enabled: true

Style/RedundantFetchBlock: # (new in 0.86)
Enabled: true

Style/RedundantFileExtensionInRequire: # (new in 0.88)
Enabled: true

Style/RedundantRegexpCharacterClass: # (new in 0.85)
Enabled: true

Style/RedundantRegexpEscape: # (new in 0.85)
Enabled: true

Style/RedundantSelfAssignment: # (new in 0.90)
Enabled: true

Style/SingleArgumentDig: # (new in 0.89)
Enabled: true

Style/SlicingWithRange: # (new in 0.83)
Enabled: true

Style/SoleNestedConditional: # (new in 0.89)
Enabled: true

Style/StringConcatenation: # (new in 0.89)
Enabled: true
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ group :test do
gem 'rspec', '~> 3.5'
gem 'rspec_junit_formatter', '~> 0.3'

gem 'rubocop', '~> 0.49.0'
gem 'rubocop-junit-formatter', '~> 0.1'
gem 'rubocop-rspec', '~> 1.15.0'
gem 'rubocop', '~> 0.90.0'
gem 'rubocop-rspec', '~> 1.43.2'

gem 'webmock', '~> 3.0'
end
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [API Documentation](https://api.scnnr.cubki.jp/v1/docs)

## Supported Ruby versions
- Ruby 2.3+
- Ruby 2.4+

## Installation

Expand Down
1 change: 1 addition & 0 deletions lib/scnnr/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def recognize_url(url, options = {})
def fetch(recognition_id, options = {})
options = merge_options options
return request(recognition_id, options) if options.delete(:polling) == false

PollingManager.new(options.delete(:timeout)).polling(self, recognition_id, options)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/scnnr/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Scnnr
Configuration = Struct.new(:api_key, :api_version, :timeout, :logger) do
require 'logger'

DEFAULT_LOGGER = Logger.new(STDOUT, level: :info)
DEFAULT_LOGGER = Logger.new($stdout, level: :info)

def initialize
super(nil, 'v1', 0, DEFAULT_LOGGER)
Expand Down
1 change: 1 addition & 0 deletions lib/scnnr/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Response

def initialize(response)
raise UnexpectedError, response if response.content_type != SUPPORTED_CONTENT_TYPE

@response = response
end

Expand Down
5 changes: 3 additions & 2 deletions lib/scnnr/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ def queries
end

def path
'/' + [self.path_prefix, @path]
"/#{[self.path_prefix, @path]
.map { |value| value.sub(%r{\A/}, '').sub(%r{/\z}, '') }
.join('/')
.join('/')}"
end

private

def query_string
params = self.queries
return if params.empty?

params
.map { |pair| pair.map { |val| URI.encode_www_form_component val }.join('=') }
.join('&')
Expand Down
5 changes: 3 additions & 2 deletions scnnr.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# coding: utf-8
# frozen_string_literal: true

lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'scnnr/version'

Expand All @@ -24,4 +23,6 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler', '~> 2.1'

spec.required_ruby_version = '>= 2.4'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this constraint :)

end
Loading