Skip to content

Commit f33079f

Browse files
committed
Use rubocop autocorrect and modify the code
1 parent 89df86c commit f33079f

20 files changed

+195
-381
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ jobs:
2525
ruby-version: ${{ matrix.ruby }}
2626
bundler-cache: true
2727
- run: bundle exec rspec
28+
29+
rubocop:
30+
runs-on: "ubuntu-latest"
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: "3.1"
36+
bundler-cache: true
37+
- run: bundle exec rubocop

.rubocop.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
# The behavior of RuboCop can be controlled via the .rubocop.yml
2-
# configuration file. It makes it possible to enable/disable
3-
# certain cops (checks) and to alter their behavior if they accept
4-
# any parameters. The file can be placed either in your home
5-
# directory or in some project directory.
6-
#
7-
# RuboCop will start looking for the configuration file in the directory
8-
# where the inspected file is and continue its way up to the root directory.
9-
#
10-
# See https://docs.rubocop.org/rubocop/configuration
11-
121
inherit_from: .rubocop_todo.yml
132

143
require:

.rubocop_todo.yml

Lines changed: 2 additions & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,23 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config --exclude-limit 99999`
3-
# on 2022-10-12 03:59:15 UTC using RuboCop version 1.36.0.
3+
# on 2022-10-12 04:57:08 UTC using RuboCop version 1.36.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

9-
# Offense count: 1
10-
# This cop supports safe autocorrection (--autocorrect).
11-
# Configuration parameters: Include.
12-
# Include: **/*.gemspec
13-
Gemspec/DeprecatedAttributeAssignment:
14-
Exclude:
15-
- 'ruboty-github.gemspec'
16-
17-
# Offense count: 3
18-
# This cop supports safe autocorrection (--autocorrect).
19-
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
20-
# Include: **/*.gemspec
21-
Gemspec/OrderedDependencies:
22-
Exclude:
23-
- 'ruboty-github.gemspec'
24-
25-
# Offense count: 1
26-
# This cop supports safe autocorrection (--autocorrect).
27-
# Configuration parameters: Include.
28-
# Include: **/*.gemspec
29-
Gemspec/RequireMFA:
30-
Exclude:
31-
- 'ruboty-github.gemspec'
32-
339
# Offense count: 1
3410
# Configuration parameters: Include.
3511
# Include: **/*.gemspec
3612
Gemspec/RequiredRubyVersion:
3713
Exclude:
3814
- 'ruboty-github.gemspec'
3915

40-
# Offense count: 6
41-
# This cop supports safe autocorrection (--autocorrect).
42-
# Configuration parameters: EnforcedStyle.
43-
# SupportedStyles: leading, trailing
44-
Layout/DotPosition:
45-
Exclude:
46-
- 'spec/ruboty/handlers/github_spec.rb'
47-
48-
# Offense count: 1
49-
# This cop supports safe autocorrection (--autocorrect).
50-
# Configuration parameters: Width, AllowedPatterns, IgnoredPatterns.
51-
Layout/IndentationWidth:
52-
Exclude:
53-
- 'lib/ruboty/github/actions/create_deploy_pull_request.rb'
54-
55-
# Offense count: 1
56-
# This cop supports safe autocorrection (--autocorrect).
57-
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
58-
# SupportedStyles: space, no_space
59-
# SupportedStylesForEmptyBraces: space, no_space
60-
Layout/SpaceInsideBlockBraces:
61-
Exclude:
62-
- 'lib/ruboty/github/actions/base.rb'
63-
64-
# Offense count: 1
65-
# This cop supports safe autocorrection (--autocorrect).
66-
# Configuration parameters: EnforcedStyle.
67-
# SupportedStyles: final_newline, final_blank_line
68-
Layout/TrailingEmptyLines:
69-
Exclude:
70-
- 'Rakefile'
71-
7216
# Offense count: 1
7317
Lint/UnreachableCode:
7418
Exclude:
7519
- 'lib/ruboty/github/actions/close_issue.rb'
7620

77-
# Offense count: 1
78-
# This cop supports safe autocorrection (--autocorrect).
79-
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
80-
Lint/UnusedBlockArgument:
81-
Exclude:
82-
- 'lib/ruboty/github/actions/base.rb'
83-
8421
# Offense count: 1
8522
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
8623
Metrics/AbcSize:
@@ -89,7 +26,7 @@ Metrics/AbcSize:
8926
# Offense count: 2
9027
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
9128
Metrics/MethodLength:
92-
Max: 15
29+
Max: 14
9330

9431
# Offense count: 2
9532
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
@@ -103,22 +40,6 @@ Naming/PredicateName:
10340
- 'lib/ruboty/github/actions/base.rb'
10441
- 'lib/ruboty/github/actions/close_issue.rb'
10542

106-
# Offense count: 4
107-
# This cop supports safe autocorrection (--autocorrect).
108-
# Configuration parameters: PreferredName.
109-
Naming/RescuedExceptionsVariableName:
110-
Exclude:
111-
- 'lib/ruboty/github/actions/close_issue.rb'
112-
- 'lib/ruboty/github/actions/create_issue.rb'
113-
- 'lib/ruboty/github/actions/create_pull_request.rb'
114-
- 'lib/ruboty/github/actions/search_issues.rb'
115-
116-
# Offense count: 2
117-
# This cop supports safe autocorrection (--autocorrect).
118-
Performance/ConstantRegexp:
119-
Exclude:
120-
- 'lib/ruboty/handlers/github.rb'
121-
12243
# Offense count: 3
12344
# Configuration parameters: .
12445
# SupportedStyles: have_received, receive
@@ -139,12 +60,6 @@ RSpec/NoExpectationExample:
13960
Exclude:
14061
- 'spec/ruboty/handlers/github_spec.rb'
14162

142-
# Offense count: 1
143-
# This cop supports unsafe autocorrection (--autocorrect-all).
144-
Style/CollectionCompact:
145-
Exclude:
146-
- 'lib/ruboty/github/actions/base.rb'
147-
14863
# Offense count: 9
14964
# Configuration parameters: AllowedConstants.
15065
Style/Documentation:
@@ -161,134 +76,6 @@ Style/Documentation:
16176
- 'lib/ruboty/github/actions/search_issues.rb'
16277
- 'lib/ruboty/handlers/github.rb'
16378

164-
# Offense count: 2
165-
# This cop supports safe autocorrection (--autocorrect).
166-
Style/EmptyCaseCondition:
167-
Exclude:
168-
- 'lib/ruboty/github/actions/base.rb'
169-
- 'lib/ruboty/github/actions/close_issue.rb'
170-
171-
# Offense count: 1
172-
# This cop supports safe autocorrection (--autocorrect).
173-
Style/ExpandPathArguments:
174-
Exclude:
175-
- 'ruboty-github.gemspec'
176-
177-
# Offense count: 4
178-
# This cop supports safe autocorrection (--autocorrect).
179-
# Configuration parameters: AllowedVars.
180-
Style/FetchEnvVar:
181-
Exclude:
182-
- 'lib/ruboty/github/actions/base.rb'
183-
184-
# Offense count: 16
185-
# This cop supports unsafe autocorrection (--autocorrect-all).
186-
# Configuration parameters: EnforcedStyle.
187-
# SupportedStyles: always, always_true, never
188-
Style/FrozenStringLiteralComment:
189-
Exclude:
190-
- 'Gemfile'
191-
- 'Rakefile'
192-
- 'lib/ruboty/github.rb'
193-
- 'lib/ruboty/github/actions/base.rb'
194-
- 'lib/ruboty/github/actions/close_issue.rb'
195-
- 'lib/ruboty/github/actions/create_deploy_pull_request.rb'
196-
- 'lib/ruboty/github/actions/create_issue.rb'
197-
- 'lib/ruboty/github/actions/create_pull_request.rb'
198-
- 'lib/ruboty/github/actions/merge_pull_request.rb'
199-
- 'lib/ruboty/github/actions/remember.rb'
200-
- 'lib/ruboty/github/actions/search_issues.rb'
201-
- 'lib/ruboty/github/version.rb'
202-
- 'lib/ruboty/handlers/github.rb'
203-
- 'ruboty-github.gemspec'
204-
- 'spec/ruboty/handlers/github_spec.rb'
205-
- 'spec/spec_helper.rb'
206-
207-
# Offense count: 1
208-
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
209-
Style/GuardClause:
210-
Exclude:
211-
- 'lib/ruboty/github/actions/create_deploy_pull_request.rb'
212-
213-
# Offense count: 1
214-
# This cop supports safe autocorrection (--autocorrect).
215-
Style/IfUnlessModifier:
216-
Exclude:
217-
- 'lib/ruboty/github/actions/create_deploy_pull_request.rb'
218-
219-
# Offense count: 3
220-
# This cop supports unsafe autocorrection (--autocorrect-all).
221-
# Configuration parameters: EnforcedStyle.
222-
# SupportedStyles: literals, strict
223-
Style/MutableConstant:
224-
Exclude:
225-
- 'lib/ruboty/github/actions/base.rb'
226-
- 'lib/ruboty/github/version.rb'
227-
- 'lib/ruboty/handlers/github.rb'
228-
229-
# Offense count: 3
230-
# This cop supports safe autocorrection (--autocorrect).
231-
# Configuration parameters: PreferredDelimiters.
232-
Style/PercentLiteralDelimiters:
233-
Exclude:
234-
- 'lib/ruboty/handlers/github.rb'
235-
- 'spec/ruboty/handlers/github_spec.rb'
236-
237-
# Offense count: 1
238-
# This cop supports safe autocorrection (--autocorrect).
239-
Style/PerlBackrefs:
240-
Exclude:
241-
- 'lib/ruboty/github/actions/create_deploy_pull_request.rb'
242-
243-
# Offense count: 4
244-
# This cop supports safe autocorrection (--autocorrect).
245-
# Configuration parameters: EnforcedStyle.
246-
# SupportedStyles: implicit, explicit
247-
Style/RescueStandardError:
248-
Exclude:
249-
- 'lib/ruboty/github/actions/close_issue.rb'
250-
- 'lib/ruboty/github/actions/create_issue.rb'
251-
- 'lib/ruboty/github/actions/create_pull_request.rb'
252-
- 'lib/ruboty/github/actions/search_issues.rb'
253-
254-
# Offense count: 109
255-
# This cop supports safe autocorrection (--autocorrect).
256-
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
257-
# SupportedStyles: single_quotes, double_quotes
258-
Style/StringLiterals:
259-
Exclude:
260-
- 'Rakefile'
261-
- 'lib/ruboty/github.rb'
262-
- 'lib/ruboty/github/actions/base.rb'
263-
- 'lib/ruboty/github/actions/close_issue.rb'
264-
- 'lib/ruboty/github/actions/create_deploy_pull_request.rb'
265-
- 'lib/ruboty/github/actions/create_issue.rb'
266-
- 'lib/ruboty/github/actions/create_pull_request.rb'
267-
- 'lib/ruboty/github/actions/search_issues.rb'
268-
- 'lib/ruboty/github/version.rb'
269-
- 'lib/ruboty/handlers/github.rb'
270-
- 'ruboty-github.gemspec'
271-
- 'spec/ruboty/handlers/github_spec.rb'
272-
- 'spec/spec_helper.rb'
273-
274-
# Offense count: 13
275-
# This cop supports safe autocorrection (--autocorrect).
276-
# Configuration parameters: EnforcedStyleForMultiline.
277-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
278-
Style/TrailingCommaInArguments:
279-
Exclude:
280-
- 'lib/ruboty/handlers/github.rb'
281-
- 'spec/ruboty/handlers/github_spec.rb'
282-
283-
# Offense count: 6
284-
# This cop supports safe autocorrection (--autocorrect).
285-
# Configuration parameters: EnforcedStyleForMultiline.
286-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
287-
Style/TrailingCommaInHashLiteral:
288-
Exclude:
289-
- 'lib/ruboty/github/actions/base.rb'
290-
- 'spec/ruboty/handlers/github_spec.rb'
291-
29279
# Offense count: 1
29380
# This cop supports safe autocorrection (--autocorrect).
29481
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- Add `search issues` command
33
- Support test on GitHub Actions
44
- Add rubocop, rubocop-rake, rubocop-performance, rubocop-rspec gems
5+
- Use rubocop autocorrect and modify the code
56

67
## 0.2.3
78
- Fix typo

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
# Specify your gem's dependencies in ruboty-github.gemspec

Rakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
require "bundler/gem_tasks"
1+
# frozen_string_literal: true
22

3+
require 'bundler/gem_tasks'

lib/ruboty/github.rb

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
require "active_support/core_ext/string/strip"
2-
require "octokit"
1+
# frozen_string_literal: true
32

4-
require "ruboty"
5-
require "ruboty/github/actions/base"
6-
require "ruboty/github/actions/close_issue"
7-
require "ruboty/github/actions/create_issue"
8-
require "ruboty/github/actions/create_pull_request"
9-
require "ruboty/github/actions/create_deploy_pull_request"
10-
require "ruboty/github/actions/merge_pull_request"
11-
require "ruboty/github/actions/remember"
12-
require "ruboty/github/actions/search_issues"
13-
require "ruboty/github/version"
14-
require "ruboty/handlers/github"
3+
require 'active_support/core_ext/string/strip'
4+
require 'octokit'
5+
6+
require 'ruboty'
7+
require 'ruboty/github/actions/base'
8+
require 'ruboty/github/actions/close_issue'
9+
require 'ruboty/github/actions/create_issue'
10+
require 'ruboty/github/actions/create_pull_request'
11+
require 'ruboty/github/actions/create_deploy_pull_request'
12+
require 'ruboty/github/actions/merge_pull_request'
13+
require 'ruboty/github/actions/remember'
14+
require 'ruboty/github/actions/search_issues'
15+
require 'ruboty/github/version'
16+
require 'ruboty/handlers/github'

lib/ruboty/github/actions/base.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# frozen_string_literal: true
2+
13
module Ruboty
24
module Github
35
module Actions
46
class Base
5-
NAMESPACE = "github"
7+
NAMESPACE = 'github'
68

79
attr_reader :message
810

@@ -17,7 +19,7 @@ def access_tokens
1719
end
1820

1921
def body
20-
message[:description] || ""
22+
message[:description] || ''
2123
end
2224

2325
def sender_name
@@ -45,14 +47,14 @@ def repository
4547
end
4648

4749
def client_options
48-
client_options_with_nil_value.reject {|key, value| value.nil? }
50+
client_options_with_nil_value.compact
4951
end
5052

5153
def client_options_with_nil_value
5254
{
5355
access_token: access_token,
5456
api_endpoint: api_endpoint,
55-
web_endpoint: web_endpoint,
57+
web_endpoint: web_endpoint
5658
}
5759
end
5860

@@ -66,11 +68,10 @@ def api_endpoint
6668

6769
# @note GITHUB_HOST will be deprecated on the next major version
6870
def github_base_url
69-
case
70-
when ENV["GITHUB_BASE_URL"]
71-
ENV["GITHUB_BASE_URL"]
72-
when ENV["GITHUB_HOST"]
73-
"https://#{ENV['GITHUB_HOST']}"
71+
if ENV.fetch('GITHUB_BASE_URL', nil)
72+
ENV.fetch('GITHUB_BASE_URL', nil)
73+
elsif ENV.fetch('GITHUB_HOST', nil)
74+
"https://#{ENV.fetch('GITHUB_HOST', nil)}"
7475
end
7576
end
7677
end

0 commit comments

Comments
 (0)