Skip to content

Commit 0e5ba3e

Browse files
committed
Fix up Rubocop.
1 parent c6087fb commit 0e5ba3e

File tree

5 files changed

+63
-20
lines changed

5 files changed

+63
-20
lines changed

.rubocop.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
AllCops:
2+
NewCops: enable
23
Exclude:
34
- vendor/**/*
45

56
inherit_from: .rubocop_todo.yml
7+
8+
require:
9+
- rubocop-rake
10+
- rubocop-rspec

.rubocop_todo.yml

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,63 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2017-09-13 14:18:39 -0400 using RuboCop version 0.33.0.
3+
# on 2026-01-02 19:41:49 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: 20
10-
# Configuration parameters: AllowURI, URISchemes.
11-
Metrics/LineLength:
12-
Max: 118
13-
9+
# Offense count: 1
10+
# Configuration parameters: Include.
11+
# Include: **/*.gemspec
1412
Gemspec/RequiredRubyVersion:
1513
Exclude:
1614
- 'mongoid-compatibility.gemspec'
1715

18-
Metrics/BlockLength:
16+
# Offense count: 1
17+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
18+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
19+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
20+
Naming/FileName:
1921
Exclude:
20-
- 'spec/**/*'
21-
- 'test/**/*'
22+
- 'lib/mongoid-compatibility.rb'
2223

23-
# Offense count: 4
24-
Style/Documentation:
24+
# Offense count: 1
25+
# Configuration parameters: Prefixes, AllowedPatterns.
26+
# Prefixes: when, with, without
27+
RSpec/ContextWording:
2528
Exclude:
26-
- 'lib/mongoid/compatibility/object_id.rb'
27-
- 'lib/mongoid/compatibility/self.rb'
28-
- 'lib/mongoid/compatibility/version.rb'
29+
- 'spec/mongoid/compatibility/version_spec.rb'
30+
31+
# Offense count: 18
32+
# This cop supports unsafe autocorrection (--autocorrect-all).
33+
# Configuration parameters: SkipBlocks, EnforcedStyle.
34+
# SupportedStyles: described_class, explicit
35+
RSpec/DescribedClass:
36+
Exclude:
37+
- 'spec/mongoid/compatibility/object_id_spec.rb'
38+
- 'spec/mongoid/compatibility/version_spec.rb'
39+
40+
# Offense count: 1
41+
# Configuration parameters: CountAsOne.
42+
RSpec/ExampleLength:
43+
Max: 13
2944

3045
# Offense count: 1
31-
Style/DoubleNegation:
46+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
47+
# Include: **/*_spec*rb*, **/spec/**/*
48+
RSpec/FilePath:
3249
Exclude:
33-
- 'lib/mongoid/compatibility/version.rb'
50+
- 'spec/mongoid/compatibility/self_spec.rb'
3451

3552
# Offense count: 1
36-
# Configuration parameters: Exclude.
37-
Style/FileName:
53+
RSpec/MultipleExpectations:
54+
Max: 5
55+
56+
# Offense count: 3
57+
# Configuration parameters: AllowedConstants.
58+
Style/Documentation:
3859
Exclude:
39-
- 'lib/mongoid-compatibility.rb'
60+
- 'spec/**/*'
61+
- 'test/**/*'
62+
- 'lib/mongoid/compatibility/object_id.rb'
63+
- 'lib/mongoid/compatibility/version.rb'

mongoid-compatibility.gemspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ Gem::Specification.new do |s|
1919
s.add_dependency 'mongoid', '>= 2.0'
2020

2121
s.add_development_dependency 'appraisal', '~> 2.0'
22-
s.add_development_dependency 'rake', '< 12'
22+
s.add_development_dependency 'ostruct'
23+
s.add_development_dependency 'rake'
2324
s.add_development_dependency 'rspec'
2425
s.add_development_dependency 'rubocop', '~> 1.36.0'
26+
s.add_development_dependency 'rubocop-rake'
27+
s.add_development_dependency 'rubocop-rspec'
28+
s.metadata['rubygems_mfa_required'] = 'true'
2529
end

spec/mongoid/compatibility/object_id_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
it 'valid' do
77
expect(Mongoid::Compatibility::ObjectId.legal?('4e4d66343b39b68407000001')).to be true
88
end
9+
910
it 'invalid' do
1011
expect(Mongoid::Compatibility::ObjectId.legal?('asadsf')).to be false
1112
end

spec/mongoid/compatibility/version_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
Mongoid::Compatibility::Version.send("mongoid#{v}?")
1010
end).to be true
1111
end
12+
1213
context "current version #{Mongoid::VERSION}" do
1314
let(:version) { Mongoid::VERSION.split('.').first.to_i }
15+
1416
it 'mongoidX?' do
1517
expect(Mongoid::Compatibility::Version.send("mongoid#{version}?")).to be true
1618
end
19+
1720
it 'mongoidX?_or_newer?' do
1821
expect(Mongoid::Compatibility::Version.send("mongoid#{version}_or_newer?")).to be true
1922
if Mongoid::Compatibility::Version.respond_to?("mongoid#{version - 1}_or_newer?")
@@ -29,25 +32,31 @@
2932
expect(Mongoid::Compatibility::Version.send("mongoid#{version + 1}_or_newer?")).to be false
3033
end
3134
end
35+
3236
it 'mongoidX?_or_older?' do
3337
expect(Mongoid::Compatibility::Version.send("mongoid#{version}_or_older?")).to be true
3438
end
3539
end
40+
3641
(2..9).each do |v|
3742
context "mongoid #{v}" do
3843
before do
3944
stub_const('::Mongoid::VERSION', v.to_s)
4045
stub_const("::Mongoid::Compatibility::Version::ClassMethods::V#{v}", 1)
4146
end
47+
4248
it "responds to mongoid#{v}?" do
4349
expect(Mongoid::Compatibility::Version).to respond_to("mongoid#{v}?")
4450
end
51+
4552
it "mongoid#{v}?" do
4653
expect(Mongoid::Compatibility::Version.send("mongoid#{v}?")).to be true
4754
end
55+
4856
it "mongoid#{v}_or_newer?" do
4957
expect(Mongoid::Compatibility::Version.send("mongoid#{v}_or_newer?")).to be true
5058
end
59+
5160
it "mongoid#{v}_or_older?" do
5261
expect(Mongoid::Compatibility::Version.send("mongoid#{v}_or_older?")).to be true
5362
end

0 commit comments

Comments
 (0)