Skip to content

Commit 229cdd5

Browse files
committed
🚨 Linting cleanup
1 parent cab967f commit 229cdd5

File tree

11 files changed

+98
-32
lines changed

11 files changed

+98
-32
lines changed

.rubocop.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
inherit_from: .rubocop_todo.yml
2+
13
inherit_gem:
24
rubocop-lts: rubocop-lts.yml
35

46
require:
5-
- 'rubocop-md'
67
- 'rubocop-performance'
78
- 'rubocop-rake'
89
- 'rubocop-rspec'
@@ -19,5 +20,5 @@ Style/StringLiteralsInInterpolation:
1920
Enabled: true
2021
EnforcedStyle: double_quotes
2122

22-
Layout/LineLength:
23+
Metrics/LineLength:
2324
Max: 120

.rubocop_todo.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2022-09-23 18:38:21 -0500 using RuboCop version 0.68.1.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 1
10+
Metrics/AbcSize:
11+
Max: 31
12+
13+
# Offense count: 2
14+
# Configuration parameters: CountComments, ExcludedMethods.
15+
# ExcludedMethods: refine
16+
Metrics/BlockLength:
17+
Max: 94
18+
19+
# Offense count: 1
20+
Metrics/CyclomaticComplexity:
21+
Max: 9
22+
23+
# Offense count: 25
24+
# Cop supports --auto-correct.
25+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
26+
# URISchemes: http, https
27+
Metrics/LineLength:
28+
Max: 414
29+
30+
# Offense count: 2
31+
# Configuration parameters: CountComments, ExcludedMethods.
32+
Metrics/MethodLength:
33+
Max: 33
34+
35+
# Offense count: 1
36+
# Configuration parameters: Prefixes.
37+
# Prefixes: when, with, without
38+
RSpec/ContextWording:
39+
Exclude:
40+
- 'spec/shared_contexts/base_hash.rb'
41+
42+
# Offense count: 1
43+
RSpec/DescribeClass:
44+
Exclude:
45+
- 'spec/snaky_hash/bad_snake_spec.rb'
46+
47+
# Offense count: 5
48+
# Configuration parameters: Max.
49+
RSpec/ExampleLength:
50+
Exclude:
51+
- 'spec/shared_examples/a_snaked_hash.rb'
52+
53+
# Offense count: 1
54+
RSpec/LeakyConstantDeclaration:
55+
Exclude:
56+
- 'spec/snaky_hash/snake_spec.rb'
57+
58+
# Offense count: 12
59+
RSpec/MultipleExpectations:
60+
Max: 15
61+
62+
# Offense count: 5
63+
Style/Documentation:
64+
Exclude:
65+
- '**/*.md'
66+
- '**/*.markdown'
67+
- 'lib/snaky_hash/snake.rb'
68+
- 'lib/snaky_hash/string_keyed.rb'
69+
- 'lib/snaky_hash/symbol_keyed.rb'
70+
- 'spec/snaky_hash/snake_spec.rb'

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ gem "overcommit", "~> 0.58" if linting
2121

2222
platforms :mri do
2323
if linting
24-
gem "rubocop-md", require: false
24+
# Commented out rubocop-md because of the <--rubocop/md--> bug
25+
# gem "rubocop-md", require: false
2526
# Can be added once we reach rubocop-lts >= v10 (i.e. drop Ruby 2.2)
2627
# gem 'rubocop-packaging', require: false
2728
gem "rubocop-performance", require: false

Gemfile.lock

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ GEM
5555
unicode-display_width (>= 1.4.0, < 1.6)
5656
rubocop-lts (8.0.2)
5757
rubocop-ruby2_2 (~> 1.0.4)
58-
rubocop-md (0.4.1)
59-
rubocop (>= 0.60)
6058
rubocop-performance (1.3.0)
6159
rubocop (>= 0.68.0)
6260
rubocop-rake (0.5.1)
@@ -101,7 +99,6 @@ DEPENDENCIES
10199
rspec (~> 3.0)
102100
rspec-block_is_expected
103101
rubocop-lts (~> 8.0)
104-
rubocop-md
105102
rubocop-performance
106103
rubocop-rake
107104
rubocop-rspec

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class MySnakedHash < Hashie::Mash
2424
include SnakyHash::Snake.new(key_type: :string) # or :symbol
2525
end
2626

27-
snake = MySnakedHash.new(a: 'a', 'b' => 'b', 2 => 2, 'VeryFineHat' => 'Feathers')
27+
snake = MySnakedHash.new(a: "a", "b" => "b", 2 => 2, "VeryFineHat" => "Feathers")
2828
snake.a # => 'a'
2929
snake.b # => 'b'
3030
snake[2] # 2
3131
snake.very_fine_hat # => 'Feathers'
3232
snake[:very_fine_hat] # => 'Feathers'
33-
snake['very_fine_hat'] # => 'Feathers'
33+
snake["very_fine_hat"] # => 'Feathers'
3434
```
3535

3636
Note above that you can access the values via the string, or symbol.
@@ -45,17 +45,17 @@ You can still access the original un-snaked camel keys.
4545
And through them you can even use un-snaked camel methods.
4646

4747
```ruby
48-
snake.key?('VeryFineHat') # => true
49-
snake['VeryFineHat'] # => 'Feathers'
48+
snake.key?("VeryFineHat") # => true
49+
snake["VeryFineHat"] # => 'Feathers'
5050
snake.VeryFineHat # => 'Feathers', PLEASE don't do this!!!
51-
snake['VeryFineHat'] = 'pop' # Please don't do this... you'll get a warning, and it works (for now), but no guarantees.
51+
snake["VeryFineHat"] = "pop" # Please don't do this... you'll get a warning, and it works (for now), but no guarantees.
5252
# WARN -- : You are setting a key that conflicts with a built-in method MySnakedHash#VeryFineHat defined in MySnakedHash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
5353
# => "pop"
54-
snake.very_fine_hat = 'pop' # => 'pop', do this instead!!!
54+
snake.very_fine_hat = "pop" # => 'pop', do this instead!!!
5555
snake.very_fine_hat # => 'pop'
56-
snake[:very_fine_hat] = 'moose' # => 'moose', or do this instead!!!
56+
snake[:very_fine_hat] = "moose" # => 'moose', or do this instead!!!
5757
snake.very_fine_hat # => 'moose'
58-
snake['very_fine_hat'] = 'cheese' # => 'cheese', or do this instead!!!
58+
snake["very_fine_hat"] = "cheese" # => 'cheese', or do this instead!!!
5959
snake.very_fine_hat # => 'cheese'
6060
```
6161

Rakefile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
# encoding: utf-8
21
# frozen_string_literal: true
32

43
# !/usr/bin/env rake
54

6-
require 'bundler/gem_tasks'
5+
require "bundler/gem_tasks"
76

87
begin
9-
require 'rspec/core/rake_task'
8+
require "rspec/core/rake_task"
109
RSpec::Core::RakeTask.new(:spec)
1110
rescue LoadError
12-
desc 'spec task stub'
11+
desc "spec task stub"
1312
task :spec do
14-
warn 'rspec is disabled'
13+
warn "rspec is disabled"
1514
end
1615
end
17-
desc 'alias test task to spec'
16+
desc "alias test task to spec"
1817
task test: :spec
1918

2019
begin
21-
require 'rubocop/rake_task'
20+
require "rubocop/rake_task"
2221
RuboCop::RakeTask.new do |task|
23-
task.options = ['-D'] # Display the name of the failing cops
22+
task.options = ["-D"] # Display the name of the failing cops
2423
end
2524
rescue LoadError
26-
desc 'rubocop task stub'
25+
desc "rubocop task stub"
2726
task :rubocop do
28-
warn 'RuboCop is disabled'
27+
warn "RuboCop is disabled"
2928
end
3029
end
3130

snaky_hash.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ Gem::Specification.new do |spec|
4545

4646
spec.add_development_dependency "rake", ">= 12"
4747
spec.add_development_dependency "rspec", ">= 3"
48-
spec.add_development_dependency "rubocop-lts", "~> 8.0"
4948
spec.add_development_dependency "rspec-block_is_expected"
49+
spec.add_development_dependency "rubocop-lts", "~> 8.0"
5050
end

spec/shared_examples/a_snaked_hash.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@
114114
expect(subject.key?(:"4")).to be false
115115
expect(subject.key?(4)).to be true
116116
end
117-
end
117+
end

spec/snaky_hash/bad_snake_spec.rb

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

33
RSpec.describe "a bad one" do
4-
54
subject(:bad_snake) do
65
Class.new(Hashie::Mash) do
76
include SnakyHash::Snake.new(key_type: :slartibartfarst)

spec/snaky_hash/snake_spec.rb

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

33
RSpec.describe SnakyHash::Snake do
4-
54
class TheSnakedHash < Hashie::Mash
65
include SnakyHash::Snake.new(key_type: :string)
76
end
@@ -14,19 +13,19 @@ class TheSnakedHash < Hashie::Mash
1413

1514
it "returns a SnakyHash::Snake from a snake + snake merge" do
1615
a = TheSnakedHash.new("asd" => "asd")
17-
b = TheSnakedHash.new(:zxc => "zxc")
16+
b = TheSnakedHash.new(zxc: "zxc")
1817
expect(a.merge(b)).to be_a(TheSnakedHash)
1918
end
2019

2120
it "returns a SnakyHash::Snake from a snake + hash merge" do
2221
a = TheSnakedHash.new("asd" => "asd")
23-
b = Hash.new(:zxc => "zxc")
22+
b = Hash.new(zxc: "zxc")
2423
expect(a.merge(b)).to be_a(TheSnakedHash)
2524
end
2625

2726
it "returns a Hash from a hash + snake merge" do
2827
a = TheSnakedHash.new("asd" => "asd")
29-
b = Hash.new(:zxc => "zxc")
28+
b = Hash.new(zxc: "zxc")
3029
res = b.merge(a)
3130
expect(res).not_to be_a(TheSnakedHash)
3231
expect(res).to be_a(Hash)

0 commit comments

Comments
 (0)