Skip to content

Commit 4d9b041

Browse files
authored
Merge pull request #41 from DripEmail/implement-rubocop
Implement rubocop
2 parents d5d54fb + ec1ac9a commit 4d9b041

10 files changed

Lines changed: 129 additions & 145 deletions

File tree

.rubocop.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
inherit_from: .rubocop_todo.yml
22

33
AllCops:
4+
TargetRubyVersion: '2.1'
45
Exclude:
56
- 'test/fixtures/**/*'
67

@@ -14,4 +15,16 @@ Layout/DotPosition:
1415
EnforcedStyle: trailing
1516

1617
Style/BracesAroundHashParameters:
17-
Enabled: false
18+
Enabled: false
19+
20+
Layout/AccessModifierIndentation:
21+
EnforcedStyle: outdent
22+
23+
Metrics/LineLength:
24+
Enabled: false
25+
26+
Layout/MultilineOperationIndentation:
27+
EnforcedStyle: 'indented'
28+
29+
Layout/MultilineMethodCallIndentation:
30+
EnforcedStyle: 'indented'

.rubocop_todo.yml

Lines changed: 51 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,100 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2017-12-22 12:38:29 -0600 using RuboCop version 0.49.1.
3+
# on 2018-05-24 10:21:33 -0500 using RuboCop version 0.56.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

99
# Offense count: 2
1010
# Cop supports --auto-correct.
11-
# Configuration parameters: SupportedStyles, IndentationWidth.
12-
# SupportedStyles: outdent, indent
13-
Layout/AccessModifierIndentation:
14-
EnforcedStyle: outdent
15-
16-
# Offense count: 1
17-
# Cop supports --auto-correct.
18-
Layout/ElseAlignment:
11+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
12+
Lint/UnusedMethodArgument:
1913
Exclude:
20-
- 'lib/drip/response.rb'
14+
- 'lib/drip/client.rb'
15+
- 'lib/drip/collection.rb'
2116

2217
# Offense count: 1
23-
# Cop supports --auto-correct.
24-
Layout/EmptyLineAfterMagicComment:
25-
Exclude:
26-
- 'drip-ruby.gemspec'
18+
Metrics/AbcSize:
19+
Max: 26
2720

28-
# Offense count: 2
29-
# Cop supports --auto-correct.
30-
# Configuration parameters: SupportedStyles, IndentationWidth.
31-
# SupportedStyles: special_inside_parentheses, consistent, align_braces
32-
Layout/IndentHash:
33-
EnforcedStyle: consistent
21+
# Offense count: 5
22+
# Configuration parameters: CountComments, ExcludedMethods.
23+
Metrics/BlockLength:
24+
Max: 46
25+
26+
# Offense count: 3
27+
# Configuration parameters: CountComments.
28+
Metrics/ClassLength:
29+
Max: 173
30+
31+
# Offense count: 4
32+
# Configuration parameters: CountComments.
33+
Metrics/MethodLength:
34+
Max: 26
3435

3536
# Offense count: 1
37+
Metrics/PerceivedComplexity:
38+
Max: 8
39+
40+
# Offense count: 4
3641
# Cop supports --auto-correct.
37-
# Configuration parameters: Width, IgnoredPatterns.
38-
Layout/IndentationWidth:
42+
Performance/InefficientHashSearch:
3943
Exclude:
44+
- 'lib/drip/resource.rb'
4045
- 'lib/drip/response.rb'
4146

42-
# Offense count: 1
47+
# Offense count: 23
4348
# Cop supports --auto-correct.
44-
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
45-
# SupportedStyles: aligned, indented, indented_relative_to_receiver
46-
Layout/MultilineMethodCallIndentation:
47-
Exclude:
48-
- 'lib/drip/collection.rb'
49+
# Configuration parameters: AutoCorrect, EnforcedStyle.
50+
# SupportedStyles: nested, compact
51+
Style/ClassAndModuleChildren:
52+
Enabled: false
53+
54+
# Offense count: 45
55+
Style/Documentation:
56+
Enabled: false
4957

5058
# Offense count: 1
5159
# Cop supports --auto-correct.
52-
# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect.
53-
# SupportedStylesAlignWith: keyword, variable, start_of_line
54-
Lint/EndAlignment:
60+
Style/Encoding:
5561
Exclude:
56-
- 'lib/drip/response.rb'
62+
- 'drip-ruby.gemspec'
5763

58-
# Offense count: 1
59-
Lint/ScriptPermission:
64+
# Offense count: 2
65+
# Cop supports --auto-correct.
66+
Style/ExpandPathArguments:
6067
Exclude:
61-
- 'Rakefile'
68+
- 'drip-ruby.gemspec'
69+
- 'test/test_helper.rb'
6270

6371
# Offense count: 1
64-
# Cop supports --auto-correct.
65-
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
66-
Lint/UnusedBlockArgument:
72+
# Configuration parameters: MinBodyLength.
73+
Style/GuardClause:
6774
Exclude:
68-
- 'lib/drip/response.rb'
75+
- 'lib/drip/client.rb'
6976

7077
# Offense count: 2
7178
# Cop supports --auto-correct.
72-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
73-
Lint/UnusedMethodArgument:
79+
Style/IfUnlessModifier:
7480
Exclude:
7581
- 'lib/drip/client.rb'
76-
- 'lib/drip/collection.rb'
77-
78-
# Offense count: 7
79-
# Configuration parameters: CountComments, ExcludedMethods.
80-
Metrics/BlockLength:
81-
Max: 48
8282

8383
# Offense count: 2
84-
# Configuration parameters: CountComments.
85-
Metrics/ClassLength:
86-
Max: 189
87-
88-
# Offense count: 78
89-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
90-
# URISchemes: http, https
91-
Metrics/LineLength:
92-
Max: 108
93-
94-
# Offense count: 4
95-
# Configuration parameters: CountComments.
96-
Metrics/MethodLength:
97-
Max: 16
98-
99-
# Offense count: 22
100-
# Configuration parameters: EnforcedStyle, SupportedStyles.
101-
# SupportedStyles: nested, compact
102-
Style/ClassAndModuleChildren:
103-
Enabled: false
104-
105-
# Offense count: 42
106-
Style/Documentation:
107-
Enabled: false
108-
109-
# Offense count: 2
110-
Style/MethodMissing:
84+
Style/MissingRespondToMissing:
11185
Exclude:
11286
- 'lib/drip/resource.rb'
11387
- 'lib/drip/response.rb'
11488

115-
# Offense count: 9
89+
# Offense count: 10
11690
# Cop supports --auto-correct.
11791
# Configuration parameters: Strict.
11892
Style/NumericLiterals:
11993
MinDigits: 8
12094

121-
# Offense count: 494
95+
# Offense count: 605
12296
# Cop supports --auto-correct.
123-
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
97+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
12498
# SupportedStyles: single_quotes, double_quotes
12599
Style/StringLiterals:
126100
Enabled: false
127-
128-
# Offense count: 1
129-
# Cop supports --auto-correct.
130-
# Configuration parameters: EnforcedStyle, SupportedStyles.
131-
# SupportedStyles: single_quotes, double_quotes
132-
Style/StringLiteralsInInterpolation:
133-
Exclude:
134-
- 'test/drip/client_test.rb'

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ language: ruby
22
sudo: false
33
rvm:
44
- 2.3.4
5+
- 2.1
56
- jruby-19mode

Rakefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
#!/usr/bin/env rake
21
require "bundler/gem_tasks"
32
require "rake/testtask"
43

4+
require "rubocop/rake_task"
5+
RuboCop::RakeTask.new
6+
57
Rake::TestTask.new do |t|
68
t.libs << "lib"
79
t.pattern = "test/**/*_test.rb"
810
t.verbose = true
911
end
1012

1113
desc "Run tests"
12-
task default: :test
14+
task default: %i[rubocop test]

drip-ruby.gemspec

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# coding: utf-8
2+
23
lib = File.expand_path('../lib', __FILE__)
34
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
45
require 'drip/version'
@@ -18,12 +19,13 @@ Gem::Specification.new do |spec|
1819
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
1920
spec.require_paths = ["lib"]
2021

21-
spec.required_ruby_version = '>= 1.9.3'
22+
spec.required_ruby_version = '>= 2.1'
2223

2324
spec.add_development_dependency "bundler", "~> 1.6"
25+
spec.add_development_dependency "minitest", "~> 5.0"
26+
spec.add_development_dependency "mocha", "~> 1.1"
2427
spec.add_development_dependency "rake", "~> 10.0"
28+
spec.add_development_dependency "rubocop", "~> 0.56.0"
2529
spec.add_development_dependency "shoulda-context", "~> 1.0"
26-
spec.add_development_dependency "mocha", "~> 1.1"
27-
spec.add_development_dependency "minitest", "~> 5.0"
2830
spec.add_development_dependency "webmock", "~> 3.4"
2931
end

lib/drip/client/orders.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def create_or_update_orders(orders)
2727
# Public: Create or update a refund.
2828
#
2929
# options - Required. A Hash of refund properties
30-
# amount - Required. The amount of the refund.
30+
# amount - Required. The amount of the refund.
3131
# provider - Required. The provider for the Order being refunded.
3232
# order_upstream_id - Required. The upstream_id for the Order being refunded.
33-
# upstream_id - The unique id of refund in the order management system.
34-
# note - A note about the refund.
35-
# processed_at - The String time at which the refund was processed in
33+
# upstream_id - The unique id of refund in the order management system.
34+
# note - A note about the refund.
35+
# processed_at - The String time at which the refund was processed in
3636
# ISO-8601 format.
3737
#
3838
# Returns a Drip::Response.

lib/drip/response.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ def parse_members
5151
if body.is_a?(Hash)
5252
body.each do |key, value|
5353
klass = if value.is_a?(Array)
54-
Drip::Collections.find_class(key)
55-
else
56-
Drip::Resources.find_class(key)
57-
end
54+
Drip::Collections.find_class(key)
55+
else
56+
Drip::Resources.find_class(key)
57+
end
5858

5959
members[key] = klass.new(value)
6060
end
@@ -65,7 +65,7 @@ def parse_members
6565

6666
def member_map
6767
@member_map ||= {}.tap do |map|
68-
members.each { |key, value| map[key.to_sym] = key }
68+
members.each { |key, _value| map[key.to_sym] = key }
6969
end
7070
end
7171
end

test/drip/client/accounts_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def setup
1010
@response_status = 200
1111
@response_body = "stub"
1212

13-
stub_request(:get, "https://api.getdrip.com/v2/accounts").
14-
to_return(status: @response_status, body: @response_body, headers: {})
13+
stub_request(:get, "https://api.getdrip.com/v2/accounts").
14+
to_return(status: @response_status, body: @response_body, headers: {})
1515
end
1616

1717
should "send the right request" do

0 commit comments

Comments
 (0)