Skip to content

Commit f525893

Browse files
authored
Rubocop-fixes (#358)
1 parent 0ff229b commit f525893

38 files changed

+1809
-1863
lines changed

.rubocop.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,17 @@ AllCops:
99
Exclude:
1010
- ruby-units.gemspec
1111
- bin/*
12-
Style/CaseEquality:
13-
Enabled: true
12+
Style/StringLiterals:
13+
EnforcedStyle: double_quotes
1414
Layout/LineLength:
1515
Enabled: false
16-
Style/SingleLineBlockParams:
17-
Enabled: false
1816
Naming/FileName:
1917
Exclude:
2018
- 'lib/ruby-units.rb'
2119
Naming/MethodParameterName:
2220
Enabled: false
2321
Style/FormatString:
2422
Enabled: false
25-
Style/DateTime:
26-
Enabled: false
2723
Metrics/ClassLength:
2824
Enabled: false
2925
Metrics/MethodLength:

.rubocop_todo.yml

Lines changed: 0 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,11 @@
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-
10-
# Offense count: 2
11-
# This cop supports safe autocorrection (--autocorrect).
12-
Layout/SpaceAfterComma:
13-
Exclude:
14-
- 'spec/benchmarks/bigdecimal.rb'
15-
- 'spec/ruby_units/complex_spec.rb'
16-
17-
# Offense count: 1
18-
# This cop supports safe autocorrection (--autocorrect).
19-
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
20-
# SupportedStyles: space, no_space
21-
# SupportedStylesForEmptyBraces: space, no_space
22-
Layout/SpaceBeforeBlockBraces:
23-
Exclude:
24-
- 'spec/benchmarks/bigdecimal.rb'
25-
26-
# Offense count: 3
27-
# This cop supports safe autocorrection (--autocorrect).
28-
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
29-
# SupportedStyles: space, no_space
30-
# SupportedStylesForEmptyBraces: space, no_space
31-
Layout/SpaceInsideBlockBraces:
32-
Exclude:
33-
- 'spec/benchmarks/bigdecimal.rb'
34-
- 'spec/ruby_units/unit_spec.rb'
35-
36-
# Offense count: 1
37-
# This cop supports safe autocorrection (--autocorrect).
38-
Lint/AmbiguousOperator:
39-
Exclude:
40-
- 'spec/ruby_units/unit_spec.rb'
41-
42-
# Offense count: 1
43-
# This cop supports safe autocorrection (--autocorrect).
44-
Lint/AmbiguousOperatorPrecedence:
45-
Exclude:
46-
- 'lib/ruby_units/unit_definitions/standard.rb'
47-
489
# Offense count: 2
4910
Lint/BinaryOperatorWithIdenticalOperands:
5011
Exclude:
5112
- 'spec/ruby_units/unit_spec.rb'
5213

53-
# Offense count: 2
54-
# This cop supports safe autocorrection (--autocorrect).
55-
Lint/UselessNumericOperation:
56-
Exclude:
57-
- 'spec/ruby_units/unit_spec.rb'
58-
59-
# Offense count: 1
60-
# This cop supports safe autocorrection (--autocorrect).
61-
# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects.
62-
Lint/Void:
63-
Exclude:
64-
- 'lib/ruby_units/definition.rb'
65-
6614
# Offense count: 2
6715
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
6816
# SupportedStyles: snake_case, normalcase, non_integer
@@ -85,21 +33,6 @@ RSpec/BeforeAfterAll:
8533
- '**/spec/support/**/*.rb'
8634
- 'spec/ruby_units/temperature_spec.rb'
8735

88-
# Offense count: 3
89-
# This cop supports safe autocorrection (--autocorrect).
90-
# Configuration parameters: EnforcedStyle.
91-
# SupportedStyles: be_a, be_kind_of
92-
RSpec/ClassCheck:
93-
Exclude:
94-
- 'spec/ruby_units/math_spec.rb'
95-
- 'spec/ruby_units/unit_spec.rb'
96-
97-
# Offense count: 16
98-
# This cop supports safe autocorrection (--autocorrect).
99-
RSpec/ContextMethod:
100-
Exclude:
101-
- 'spec/ruby_units/unit_spec.rb'
102-
10336
# Offense count: 95
10437
# Configuration parameters: Prefixes, AllowedPatterns.
10538
# Prefixes: when, with, without
@@ -137,56 +70,11 @@ RSpec/DescribedClass:
13770
- 'spec/ruby_units/complex_spec.rb'
13871
- 'spec/ruby_units/unit_spec.rb'
13972

140-
# Offense count: 9
141-
# This cop supports safe autocorrection (--autocorrect).
142-
# Configuration parameters: AllowConsecutiveOneLiners.
143-
RSpec/EmptyLineAfterExample:
144-
Exclude:
145-
- 'spec/ruby_units/unit_spec.rb'
146-
147-
# Offense count: 20
148-
# This cop supports safe autocorrection (--autocorrect).
149-
RSpec/EmptyLineAfterExampleGroup:
150-
Exclude:
151-
- 'spec/ruby_units/temperature_spec.rb'
152-
- 'spec/ruby_units/unit_spec.rb'
153-
154-
# Offense count: 1
155-
# This cop supports safe autocorrection (--autocorrect).
156-
RSpec/EmptyLineAfterFinalLet:
157-
Exclude:
158-
- 'spec/ruby_units/unit_spec.rb'
159-
160-
# Offense count: 114
161-
# This cop supports safe autocorrection (--autocorrect).
162-
RSpec/EmptyLineAfterSubject:
163-
Exclude:
164-
- 'spec/ruby_units/temperature_spec.rb'
165-
- 'spec/ruby_units/unit_spec.rb'
166-
16773
# Offense count: 8
16874
# Configuration parameters: CountAsOne.
16975
RSpec/ExampleLength:
17076
Max: 7
17177

172-
# Offense count: 11
173-
# This cop supports safe autocorrection (--autocorrect).
174-
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
175-
# DisallowedExamples: works
176-
RSpec/ExampleWording:
177-
Exclude:
178-
- 'spec/ruby_units/bugs_spec.rb'
179-
- 'spec/ruby_units/unit_spec.rb'
180-
- 'spec/ruby_units/utf-8/unit_spec.rb'
181-
182-
# Offense count: 8
183-
# This cop supports safe autocorrection (--autocorrect).
184-
# Configuration parameters: EnforcedStyle.
185-
# SupportedStyles: implicit, each, example
186-
RSpec/HookArgument:
187-
Exclude:
188-
- 'spec/ruby_units/unit_spec.rb'
189-
19078
# Offense count: 2
19179
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
19280
RSpec/IndexedLet:
@@ -199,12 +87,6 @@ RSpec/InstanceVariable:
19987
Exclude:
20088
- 'spec/ruby_units/unit_spec.rb'
20189

202-
# Offense count: 1
203-
# This cop supports safe autocorrection (--autocorrect).
204-
RSpec/LeadingSubject:
205-
Exclude:
206-
- 'spec/ruby_units/unit_spec.rb'
207-
20890
# Offense count: 1
20991
RSpec/MultipleDescribes:
21092
Exclude:
@@ -228,14 +110,6 @@ RSpec/NamedSubject:
228110
RSpec/NestedGroups:
229111
Max: 5
230112

231-
# Offense count: 2
232-
# This cop supports safe autocorrection (--autocorrect).
233-
# Configuration parameters: EnforcedStyle.
234-
# SupportedStyles: not_to, to_not
235-
RSpec/NotToNot:
236-
Exclude:
237-
- 'spec/ruby_units/unit_spec.rb'
238-
239113
# Offense count: 6
240114
# This cop supports unsafe autocorrection (--autocorrect-all).
241115
# Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers.
@@ -267,15 +141,6 @@ RSpec/SpecFilePathFormat:
267141
- '**/spec/routing/**/*'
268142
- 'spec/ruby_units/utf-8/unit_spec.rb'
269143

270-
# Offense count: 27
271-
# This cop supports safe autocorrection (--autocorrect).
272-
# Configuration parameters: AllowOnConstant, AllowOnSelfClass.
273-
Style/CaseEquality:
274-
Exclude:
275-
- 'lib/ruby_units/unit.rb'
276-
- 'spec/ruby_units/complex_spec.rb'
277-
- 'spec/ruby_units/unit_spec.rb'
278-
279144
# Offense count: 1
280145
# This cop supports unsafe autocorrection (--autocorrect-all).
281146
# Configuration parameters: EnforcedStyle.
@@ -284,16 +149,6 @@ Style/ClassAndModuleChildren:
284149
Exclude:
285150
- 'lib/ruby_units/definition.rb'
286151

287-
# Offense count: 3
288-
# This cop supports safe autocorrection (--autocorrect).
289-
# Configuration parameters: Keywords, RequireColon.
290-
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE
291-
Style/CommentAnnotation:
292-
Exclude:
293-
- 'Guardfile'
294-
- 'spec/ruby_units/temperature_spec.rb'
295-
- 'spec/ruby_units/unit_spec.rb'
296-
297152
# Offense count: 1
298153
# Configuration parameters: AllowedConstants.
299154
Style/Documentation:
@@ -309,12 +164,6 @@ Style/GlobalStdStream:
309164
- 'spec/benchmarks/bigdecimal.rb'
310165
- 'spec/ruby_units/unit_spec.rb'
311166

312-
# Offense count: 2
313-
# This cop supports safe autocorrection (--autocorrect).
314-
# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns.
315-
Style/NumericLiterals:
316-
MinDigits: 10
317-
318167
# Offense count: 1
319168
Style/OpenStructUse:
320169
Exclude:
@@ -327,31 +176,6 @@ Style/OptionalBooleanParameter:
327176
Exclude:
328177
- 'lib/ruby_units/date.rb'
329178

330-
# Offense count: 4
331-
# This cop supports safe autocorrection (--autocorrect).
332-
Style/RedundantConstantBase:
333-
Exclude:
334-
- 'spec/ruby_units/date_spec.rb'
335-
336-
# Offense count: 2
337-
# This cop supports safe autocorrection (--autocorrect).
338-
Style/RedundantFreeze:
339-
Exclude:
340-
- 'lib/ruby_units/unit.rb'
341-
- 'lib/ruby_units/version.rb'
342-
343-
# Offense count: 1
344-
# This cop supports safe autocorrection (--autocorrect).
345-
Style/RedundantParentheses:
346-
Exclude:
347-
- 'lib/ruby_units/definition.rb'
348-
349-
# Offense count: 1
350-
# This cop supports safe autocorrection (--autocorrect).
351-
Style/RedundantRegexpEscape:
352-
Exclude:
353-
- 'spec/ruby_units/unit_spec.rb'
354-
355179
# Offense count: 1
356180
# This cop supports unsafe autocorrection (--autocorrect-all).
357181
# Configuration parameters: AllowSend.
@@ -367,19 +191,3 @@ Style/StringConcatenation:
367191
- 'spec/ruby_units/bugs_spec.rb'
368192
- 'spec/ruby_units/unit_spec.rb'
369193
- 'spec/ruby_units/utf-8/unit_spec.rb'
370-
371-
# Offense count: 20
372-
# This cop supports safe autocorrection (--autocorrect).
373-
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
374-
# SupportedStyles: single_quotes, double_quotes
375-
Style/StringLiterals:
376-
Exclude:
377-
- 'spec/benchmarks/bigdecimal.rb'
378-
- 'spec/ruby_units/unit_spec.rb'
379-
380-
# Offense count: 4
381-
# This cop supports safe autocorrection (--autocorrect).
382-
Style/SuperArguments:
383-
Exclude:
384-
- 'lib/ruby_units/math.rb'
385-
- 'lib/ruby_units/time.rb'

Gemfile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
# frozen_string_literal: true
22

3-
source 'https://rubygems.org'
3+
source "https://rubygems.org"
44

55
# These are gems that are only used for local development and don't need to be included at runtime or for running tests.
66
# The CI process will not install them.
77
group :optional do
8-
gem 'debug', '>= 1.0.0', platform: :mri
9-
gem 'guard-rspec'
10-
gem 'pry'
11-
gem 'redcarpet', platform: :mri # redcarpet doesn't support jruby
12-
gem 'rubocop'
13-
gem 'rubocop-rake'
14-
gem 'rubocop-rspec'
15-
gem 'ruby-maven', platform: :jruby
16-
gem 'ruby-prof', platform: :mri
17-
gem 'simplecov-html'
18-
gem 'solargraph'
19-
gem 'terminal-notifier'
20-
gem 'terminal-notifier-guard'
21-
gem 'webrick'
8+
gem "debug", ">= 1.0.0", platform: :mri
9+
gem "guard-rspec"
10+
gem "pry"
11+
gem "redcarpet", platform: :mri # redcarpet doesn't support jruby
12+
gem "rubocop"
13+
gem "rubocop-rake"
14+
gem "rubocop-rspec"
15+
gem "ruby-maven", platform: :jruby
16+
gem "ruby-prof", platform: :mri
17+
gem "simplecov-html"
18+
gem "solargraph"
19+
gem "terminal-notifier"
20+
gem "terminal-notifier-guard"
21+
gem "webrick"
2222
end
2323

24-
gem 'simplecov'
25-
gem 'yard'
24+
gem "simplecov"
25+
gem "yard"
2626

2727
gemspec

Guardfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ directories %w[lib spec]
99
## Uncomment to clear the screen before every task
1010
clearing :on
1111

12-
# Note: The cmd option is now required due to the increasing number of ways
12+
# NOTE: The cmd option is now required due to the increasing number of ways
1313
# rspec may be run, below are examples of the most common uses.
1414
# * bundler: 'bundle exec rspec'
1515
# * bundler binstubs: 'bin/rspec'
@@ -18,14 +18,14 @@ clearing :on
1818
# * zeus: 'zeus rspec' (requires the server to be started separately)
1919
# * 'just' rspec: 'rspec'
2020

21-
guard :rspec, cmd: 'bundle exec rspec' do
22-
require 'ostruct'
21+
guard :rspec, cmd: "bundle exec rspec" do
22+
require "ostruct"
2323

2424
# Generic Ruby apps
2525
rspec = OpenStruct.new
2626
rspec.spec = ->(m) { "spec/#{m}_spec.rb" }
27-
rspec.spec_dir = 'spec'
28-
rspec.spec_helper = 'spec/spec_helper.rb'
27+
rspec.spec_dir = "spec"
28+
rspec.spec_helper = "spec/spec_helper.rb"
2929

3030
watch(%r{^spec/.+_spec\.rb$})
3131
watch(%r{^lib/(.+)\.rb$}) { |m| rspec.spec.call(m[1]) }

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

3-
require 'bundler/gem_tasks'
4-
require 'rspec/core/rake_task'
3+
require "bundler/gem_tasks"
4+
require "rspec/core/rake_task"
55

66
RSpec::Core::RakeTask.new(:spec)
77

lib/ruby-units.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# frozen_string_literal: true
22

3-
require_relative 'ruby_units/namespaced'
3+
require_relative "ruby_units/namespaced"
44
Unit = RubyUnits::Unit

lib/ruby_units/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def initialize
5454
def separator=(value)
5555
raise ArgumentError, "configuration 'separator' may only be true or false" unless [true, false].include?(value)
5656

57-
@separator = value ? ' ' : nil
57+
@separator = value ? " " : nil
5858
end
5959

6060
# Set the format to use when generating output.

0 commit comments

Comments
 (0)