Skip to content

Commit 34ffbb3

Browse files
authored
PLAT-2788: Re-enable Rubocop (#78)
* update renamed cops * autocorrect frozen_string_literal, indentation, minor styling * auto-correct RSpec/BeEq * call super in ApiError * address Lint/DuplicateMethods * enable NewCops and auto-correct correctable changes * run rubocop --auto-gen-config --autocorrect-all * disable suggested extensions and add rubocop to ci * Seperate Rubocop into seperate CI job
1 parent 5cb218c commit 34ffbb3

28 files changed

+180
-108
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,19 @@ jobs:
2121

2222
- name: Run tests
2323
run: bundle exec rake spec
24+
25+
rubocop:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Ruby
33+
uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: .ruby-version
36+
bundler-cache: true
37+
38+
- name: Run RuboCop
39+
run: bundle exec rubocop

.rubocop.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
require: rubocop-rspec
1+
plugins: rubocop-rspec
22

33
inherit_from: .rubocop_todo.yml
44

5+
AllCops:
6+
NewCops: enable
7+
SuggestExtensions: false
58
RSpec/DescribedClass:
69
EnforcedStyle: explicit
710
Style/StringLiterals:
811
Enabled: false
912
Style/Documentation:
1013
Enabled: false
11-
Metrics/LineLength:
14+
Layout/LineLength:
1215
Max: 120

.rubocop_todo.yml

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,42 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2019-10-01 16:24:59 -0400 using RuboCop version 0.64.0.
3+
# on 2025-07-18 18:25:48 UTC using RuboCop version 1.78.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: 6
10-
# Cop supports --auto-correct.
11-
# Configuration parameters: EnforcedStyle, IndentationWidth.
12-
# SupportedStyles: with_first_parameter, with_fixed_indentation
13-
Layout/AlignParameters:
10+
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
11+
# SupportedStyles: Gemfile, gems.rb, gemspec
12+
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
13+
Gemspec/DevelopmentDependencies:
1414
Exclude:
15-
- 'lib/marqeta.rb'
15+
- 'marqeta.gemspec'
1616

1717
# Offense count: 1
18-
# Cop supports --auto-correct.
18+
# This cop supports safe autocorrection (--autocorrect).
1919
Layout/EmptyLineAfterGuardClause:
2020
Exclude:
2121
- 'lib/marqeta/user.rb'
2222

2323
# Offense count: 1
24-
# Cop supports --auto-correct.
25-
Layout/LeadingBlankLines:
26-
Exclude:
27-
- 'marqeta.gemspec'
28-
29-
# Offense count: 20
30-
# Configuration parameters: CountComments, ExcludedMethods.
31-
# ExcludedMethods: refine
32-
Metrics/BlockLength:
33-
Max: 442
24+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
25+
Metrics/AbcSize:
26+
Max: 21
3427

3528
# Offense count: 1
36-
# Configuration parameters: CountComments.
29+
# Configuration parameters: CountComments, CountAsOne.
3730
Metrics/ClassLength:
3831
Max: 110
3932

40-
# Offense count: 1
41-
# Configuration parameters: CountComments, ExcludedMethods.
33+
# Offense count: 2
34+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
4235
Metrics/MethodLength:
4336
Max: 15
4437

4538
# Offense count: 1
39+
# This cop supports unsafe autocorrection (--autocorrect-all).
4640
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
4741
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
4842
Naming/MemoizedInstanceVariableName:
@@ -51,64 +45,76 @@ Naming/MemoizedInstanceVariableName:
5145

5246
# Offense count: 2
5347
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
54-
# AllowedNames: io, id, to, by, on, in, at, ip, db
55-
Naming/UncommunicativeMethodParamName:
48+
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
49+
Naming/MethodParameterName:
5650
Exclude:
5751
- 'lib/marqeta/api_caller.rb'
5852

5953
# Offense count: 11
6054
RSpec/AnyInstance:
6155
Exclude:
62-
- 'spec/marqeta/api_caller_spec.rb'
6356
- 'spec/marqeta/api_object_spec.rb'
6457
- 'spec/marqeta/card_spec.rb'
6558
- 'spec/marqeta/transaction_spec.rb'
6659

6760
# Offense count: 1
68-
# Configuration parameters: Prefixes.
61+
# Configuration parameters: Prefixes, AllowedPatterns.
6962
# Prefixes: when, with, without
7063
RSpec/ContextWording:
7164
Exclude:
7265
- 'spec/marqeta/api_caller_spec.rb'
7366

74-
# Offense count: 4
75-
# Configuration parameters: Max.
67+
# Offense count: 5
68+
# Configuration parameters: CountAsOne.
7669
RSpec/ExampleLength:
77-
Exclude:
78-
- 'spec/marqeta/api_object_spec.rb'
79-
- 'spec/marqeta/transaction_spec.rb'
80-
- 'spec/marqeta/user_spec.rb'
70+
Max: 11
8171

8272
# Offense count: 1
83-
# Cop supports --auto-correct.
73+
# This cop supports safe autocorrection (--autocorrect).
8474
# Configuration parameters: EnforcedStyle.
8575
# SupportedStyles: implicit, each, example
8676
RSpec/HookArgument:
8777
Exclude:
8878
- 'spec/marqeta/transaction_spec.rb'
8979

90-
# Offense count: 32
80+
# Offense count: 12
81+
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
82+
RSpec/IndexedLet:
83+
Exclude:
84+
- 'spec/marqeta/api_object_spec.rb'
85+
86+
# Offense count: 35
9187
# Configuration parameters: .
9288
# SupportedStyles: have_received, receive
9389
RSpec/MessageSpies:
9490
EnforcedStyle: receive
9591

96-
# Offense count: 8
97-
# Configuration parameters: AggregateFailuresByDefault.
92+
# Offense count: 9
9893
RSpec/MultipleExpectations:
9994
Max: 8
10095

96+
# Offense count: 55
97+
# Configuration parameters: AllowSubject.
98+
RSpec/MultipleMemoizedHelpers:
99+
Max: 13
100+
101101
# Offense count: 36
102+
# Configuration parameters: AllowedGroups.
102103
RSpec/NestedGroups:
103104
Max: 4
104105

106+
# Offense count: 1
107+
RSpec/StubbedMock:
108+
Exclude:
109+
- 'spec/marqeta/card_spec.rb'
110+
105111
# Offense count: 1
106112
RSpec/SubjectStub:
107113
Exclude:
108114
- 'spec/marqeta/api_object_spec.rb'
109115

110116
# Offense count: 1
111-
# Cop supports --auto-correct.
117+
# This cop supports safe autocorrection (--autocorrect).
112118
Style/ExpandPathArguments:
113119
Exclude:
114120
- 'marqeta.gemspec'

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source "https://rubygems.org"
24

35
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "bundler/gem_tasks"
24
require "rspec/core/rake_task"
35
require "rubocop/rake_task"

bin/console

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

34
require "bundler/setup"
45
require "marqeta"

lib/marqeta.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'marqeta/card'
24
require 'marqeta/client_access'
35
require 'marqeta/gateway_response_codes'
@@ -11,13 +13,13 @@
1113
module Marqeta
1214
class Configuration
1315
attr_accessor :username,
14-
:password,
15-
:base_url,
16-
:dashboard_base_url,
17-
:logger,
18-
:webhook_endpoint,
19-
:webhook_username,
20-
:webhook_password
16+
:password,
17+
:base_url,
18+
:dashboard_base_url,
19+
:logger,
20+
:webhook_endpoint,
21+
:webhook_username,
22+
:webhook_password
2123
end
2224

2325
class << self
@@ -27,7 +29,7 @@ def configure
2729
end
2830

2931
def configuration
30-
@_configuration ||= Configuration.new
32+
@configuration ||= Configuration.new
3133
end
3234
end
3335
end

lib/marqeta/api_caller.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'json'
24
require 'faraday'
35
require 'marqeta/errors'
@@ -39,17 +41,14 @@ def put(payload)
3941
private
4042

4143
attr_reader :endpoint
42-
attr_reader :connection
4344

4445
def perform_action
45-
begin
46-
response = yield
47-
handle_successful_response response
48-
rescue Faraday::ClientError => e
49-
handle_exception_with_response(e)
50-
rescue *HttpError::ERROR_LIST => e
51-
handle_http_error e
52-
end
46+
response = yield
47+
handle_successful_response response
48+
rescue Faraday::ClientError => e
49+
handle_exception_with_response(e)
50+
rescue *HttpError::ERROR_LIST => e
51+
handle_http_error e
5352
end
5453

5554
def connection

lib/marqeta/api_object.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'marqeta/api_caller'
24
require 'time'
35

@@ -45,7 +47,7 @@ def self.object_list(klass, endpoint)
4547
results.map { |data_hash| klass.new(data_hash) }
4648
end
4749

48-
def method_missing(method_name, *args, &block)
50+
def method_missing(method_name, *args, &)
4951
if respond_to_missing?(method_name)
5052
attribute_value(method_name)
5153
else
@@ -70,9 +72,8 @@ def accessible_time_attributes
7072
end
7173

7274
def symbolized_attributes_hash
73-
new_array = []
74-
attributes_hash.each{ |k, v| new_array << [k.to_sym, v] }
75-
Hash[new_array]
75+
new_array = attributes_hash.map { |k, v| [k.to_sym, v] }
76+
new_array.to_h
7677
end
7778

7879
def attribute_value(attribute)

lib/marqeta/card.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# frozen_string_literal: true
2+
13
require 'marqeta/api_object'
24
require 'marqeta/client_access'
35
require 'marqeta/card_transition'
46

57
module Marqeta
68
class Card < ApiObject
7-
ACTIVE_STATE = 'ACTIVE'.freeze
9+
ACTIVE_STATE = 'ACTIVE'
810

911
def self.endpoint
1012
'cards'

0 commit comments

Comments
 (0)