-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rubocop config, upgrade, and autocorrect
- Loading branch information
Showing
9 changed files
with
175 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,138 @@ | ||
require: | ||
- rubocop-rspec | ||
|
||
AllCops: | ||
TargetRubyVersion: 2.6 | ||
TargetRubyVersion: 3.1 | ||
Exclude: | ||
- 'bin/*' | ||
- 'vendor/bundle/**/*' | ||
NewCops: enable | ||
SuggestExtensions: false | ||
|
||
Style/StringLiterals: | ||
Layout/FirstArrayElementIndentation: | ||
EnforcedStyle: consistent | ||
Enabled: true | ||
EnforcedStyle: double_quotes | ||
AutoCorrect: true | ||
|
||
Style/StringLiteralsInInterpolation: | ||
Layout/FirstHashElementIndentation: | ||
EnforcedStyle: consistent | ||
Enabled: true | ||
EnforcedStyle: double_quotes | ||
AutoCorrect: true | ||
|
||
# Indent based on the start of the line, not based on the preceeding line. Reduces line length. | ||
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutmultilinemethodcallindentation | ||
Layout/MultilineMethodCallIndentation: | ||
EnforcedStyle: indented | ||
|
||
# Indent based on the start of the line, not based on the preceeding line. Reduces line length. | ||
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutargumentalignment | ||
Layout/ArgumentAlignment: | ||
EnforcedStyle: with_fixed_indentation | ||
|
||
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutspaceinsidehashliteralbraces | ||
Layout/SpaceInsideHashLiteralBraces: | ||
EnforcedStyle: no_space | ||
|
||
# We have a mix of both and this one seems of limited value. | ||
# variable_1 and variable1 usages. | ||
# https://docs.rubocop.org/rubocop/cops_naming.html#namingvariablenumber | ||
Naming/VariableNumber: | ||
Enabled: false | ||
|
||
# When enabled this requires a documentation comment at the top of every class, which feels very anti-rails | ||
Style/Documentation: | ||
Enabled: false | ||
|
||
# This is default for rubocop because frozen literals were going to become the default in ruby 3.0 (unless disabled with the comment). | ||
# That did not come to pass however: https://bugs.ruby-lang.org/issues/11473#note-53 | ||
# Also it seems even if it did, there is not a huge performance benefit: https://bugs.ruby-lang.org/issues/11473#note-59 | ||
Style/FrozenStringLiteralComment: | ||
EnforcedStyle: never | ||
SafeAutoCorrect: true | ||
|
||
Style/TrailingCommaInArrayLiteral: | ||
EnforcedStyleForMultiline: consistent_comma | ||
|
||
Style/TrailingCommaInHashLiteral: | ||
EnforcedStyleForMultiline: consistent_comma | ||
|
||
Style/TrailingCommaInArguments: | ||
EnforcedStyleForMultiline: comma | ||
|
||
# This makes no sense in the context of RSpec where the whole spec is defined as a block | ||
Metrics/BlockLength: | ||
Exclude: | ||
- 'spec/**/*' | ||
|
||
Metrics/MethodLength: | ||
CountAsOne: ['array', 'hash', 'heredoc'] | ||
|
||
# We have a bunch of code that uses the nested style for definitions, but we only access classes using the fully qualified style in new | ||
# code to make things easier to grep for/tell at a glance which actual class is being used. Going forward it would be nice to fully | ||
# qualify the definitions as well for easier readability/grepability/refactorability | ||
Style/ClassAndModuleChildren: | ||
Enabled: false | ||
|
||
# We use this a lot and I could see no explicit benefit to the alternate form: expect { run }.to change(Foo, :bar) | ||
RSpec/ExpectChange: | ||
EnforcedStyle: block | ||
|
||
# Enforces that context strings start with when, with, without. | ||
# We have a lot of violations and vcr cassettes dependent on this. | ||
RSpec/ContextWording: | ||
Enabled: false | ||
|
||
# Enforces that example/it strings do not start with should or it. | ||
# We have a lot of violations and vcr cassettes dependent on this. | ||
RSpec/ExampleWording: | ||
Enabled: false | ||
|
||
# We prefer `describe '#method_name' do` in a unit test style similar to: | ||
# https://www.betterspecs.org/#describe | ||
# | ||
# Because of this we think that using `expect(subject).to eq(123)`: | ||
# - saves an extra mental lookup when compared with having a named subject. | ||
# - reduces friction when renaming and refactoring | ||
# | ||
# The default for RSpec/NamedSubject assumes a more behavioral style like the rspec docs: | ||
# https://rspec.info/features/3-12/rspec-core/example-groups/basic-structure/ | ||
# | ||
# Configure this cop to allow nameless subjects but only enforce that if a subject is named, the name must be used in assertions. | ||
# This prevents usages like: | ||
# | ||
# subject(:x) { ... } | ||
# subject(:y) { ... } | ||
# it { is_expected.to eq(123) } # asserts on :y only because it is defined last | ||
# | ||
RSpec/NamedSubject: | ||
EnforcedStyle: named_only | ||
|
||
# We prefer `describe '#method_name' do` in a unit test style similar to: | ||
# https://www.betterspecs.org/#describe | ||
# | ||
# The default for RSpec/NestedGroups assumes a more behavioral style like the rspec docs: | ||
# https://rspec.info/features/3-12/rspec-core/example-groups/basic-structure/ | ||
# | ||
# Configure this cop so the Max is the 3 to allow `describe '#method_name do` blocks but keeping it flat within them. | ||
# | ||
# Example with nesting levels: | ||
# | ||
# RSpec.describe TheClass do # 1 | ||
# describe '#the_method' do # 2 | ||
# context 'context A' do # 3 | ||
# it 'does things' do | ||
# end | ||
# end | ||
# context 'context B' do # 3 | ||
# it 'does things' do | ||
# end | ||
# end | ||
# end | ||
# end | ||
# | ||
RSpec/NestedGroups: | ||
# Note that at time of writing 3 is the default but set explicitly anyways as documentation since it caused us some confusion. | ||
Max: 3 | ||
|
||
Layout/LineLength: | ||
Max: 120 | ||
RSpec/ExampleLength: | ||
CountAsOne: ['array', 'heredoc', 'method_call'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in simplecov-inline.gemspec | ||
gemspec | ||
|
||
gem "rake", "~> 13.0" | ||
gem 'rake', '~> 13.0' | ||
|
||
gem "rspec", "~> 3.0" | ||
gem 'rspec', '~> 3.0' | ||
|
||
gem "rubocop", "~> 1.21" | ||
gem 'rubocop', '~> 1.21' | ||
gem 'rubocop-rspec', require: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Simplecov | ||
module Inline | ||
VERSION = "0.1.0" | ||
VERSION = '0.1.0'.freeze | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "lib/simplecov/inline/version" | ||
require_relative 'lib/simplecov/inline/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "simplecov-inline" | ||
spec.name = 'simplecov-inline' | ||
spec.version = Simplecov::Inline::VERSION | ||
spec.authors = ["tris"] | ||
spec.email = ["[email protected]"] | ||
spec.authors = ['tris'] | ||
spec.email = ['[email protected]'] | ||
|
||
spec.summary = "See missed lines of coverage inline with rspec output." | ||
spec.homepage = "https://github.com/appbot/simplecov-inline" | ||
spec.license = "MIT" | ||
spec.summary = 'See missed lines of coverage inline with rspec output.' | ||
spec.homepage = 'https://github.com/appbot/simplecov-inline' | ||
spec.license = 'MIT' | ||
spec.required_ruby_version = '>= 3.1.0' | ||
|
||
spec.metadata["homepage_uri"] = spec.homepage | ||
spec.metadata["source_code_uri"] = "https://github.com/appbot/simplecov-inline" | ||
spec.metadata["changelog_uri"] = "https://github.com/appbot/simplecov-inline/CHANGELOG.md" | ||
spec.metadata['homepage_uri'] = spec.homepage | ||
spec.metadata['source_code_uri'] = 'https://github.com/appbot/simplecov-inline' | ||
spec.metadata['changelog_uri'] = 'https://github.com/appbot/simplecov-inline/CHANGELOG.md' | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
|
@@ -24,12 +22,13 @@ Gem::Specification.new do |spec| | |
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)}) | ||
end | ||
end | ||
spec.bindir = "exe" | ||
spec.bindir = 'exe' | ||
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
spec.require_paths = ['lib'] | ||
|
||
spec.add_dependency "simplecov", "~> 0.22" | ||
spec.add_dependency 'simplecov', '~> 0.22' | ||
|
||
# For more information and examples about making a new gem, check out our | ||
# guide at: https://bundler.io/guides/creating_gem.html | ||
spec.metadata['rubygems_mfa_required'] = 'true' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Simplecov::Inline do | ||
it "has a version number" do | ||
expect(Simplecov::Inline::VERSION).not_to be nil | ||
end | ||
|
||
it "does something useful" do | ||
expect(false).to eq(true) | ||
it 'has a version number' do | ||
expect(Simplecov::Inline::VERSION).not_to be_nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters