Skip to content

Commit

Permalink
Fix Lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
safafa committed Jan 29, 2024
1 parent cb4fa05 commit f44625a
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 35 deletions.
27 changes: 27 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
inherit_from: .rubocop_todo.yml

AllCops:
NewCops: enable
SuggestExtensions: false

Naming/FileName:
Exclude:
- lib/rubocop-solidus.rb

Metrics/BlockLength:
Exclude:
- 'Rakefile'
- '**/*.rake'
- 'spec/**/*.rb'
- '*.gemspec'

Metrics/MethodLength:
Exclude:
- 'Rakefile'
- '**/*.rake'
- 'spec/**/*.rb'
- '*.gemspec'

Metrics/ClassLength:
Exclude:
- 'tasks/**/*.rb'
56 changes: 56 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-12-27 14:39:52 UTC using RuboCop version 1.57.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
# SupportedStyles: Gemfile, gems.rb, gemspec
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
Gemspec/DevelopmentDependencies:
Exclude:
- 'failing_spec_detector.gemspec'

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 19

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 12

# Offense count: 1
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/failing_spec_detector/failing_spec_formatter.rb'

# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'Gemfile'
- 'Rakefile'
- 'bin/console'
- 'failing_spec_detector.gemspec'
- 'lib/failing_spec_detector.rb'
- 'lib/failing_spec_detector/version.rb'
- 'spec/failing_spec_detector_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: literals, strict
Style/MutableConstant:
Exclude:
- 'lib/failing_spec_detector/version.rb'
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
source "https://rubygems.org"

source 'https://rubygems.org'

# Specify your gem's dependencies in failing_spec_detector.gemspec
gemspec
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

RSpec::Core::RakeTask.new(:spec)
Expand Down
6 changes: 3 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "failing_spec_detector"
require 'bundler/setup'
require 'failing_spec_detector'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand All @@ -10,5 +10,5 @@ require "failing_spec_detector"
# require "pry"
# Pry.start

require "irb"
require 'irb'
IRB.start(__FILE__)
37 changes: 19 additions & 18 deletions failing_spec_detector.gemspec
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@

lib = File.expand_path("../lib", __FILE__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "failing_spec_detector/version"
require 'failing_spec_detector/version'

Gem::Specification.new do |spec|
spec.name = "failing_spec_detector"
spec.name = 'failing_spec_detector'
spec.version = FailingSpecDetector::VERSION
spec.authors = ["safa"]
spec.email = ["[email protected]"]
spec.authors = ['safa']
spec.email = ['[email protected]']

spec.summary = 'A tool to detect failing specs and group them by error message'
spec.description = <<~DESCRIPTION
Automatic Failing spec detector.
Introduces a custom rspec formatter to detect failing specs and group them by exception.
DESCRIPTION
spec.homepage = "https://github.com/nebulab/failing_spec_detector"
spec.license = "MIT"
spec.homepage = 'https://github.com/nebulab/failing_spec_detector'
spec.license = 'MIT'
spec.required_ruby_version = '>= 2.7.0'

# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/nebulab/failing_spec_detector"
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/nebulab/failing_spec_detector'
# spec.metadata["changelog_uri"] = "https://github.com/nebulab/failing_spec_detector"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
raise 'RubyGems 2.0 or newer is required to protect against ' \
'public gem pushes.'
end

# 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.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_development_dependency "bundler"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.metadata['rubygems_mfa_required'] = 'true'
end
12 changes: 6 additions & 6 deletions spec/failing_spec_detector/failing_spec_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

let(:examples) { [failed_notification1, failed_notification2, failed_notification3] }
let(:expected_exceptions) { [failed_notification1.exception.to_s, failed_notification3.exception.to_s] }
let(:failed_notification1) { ::RSpec::Core::Notifications::ExampleNotification.for(failed_example1) }
let(:failed_notification2) { ::RSpec::Core::Notifications::ExampleNotification.for(failed_example2) }
let(:failed_notification3) { ::RSpec::Core::Notifications::ExampleNotification.for(failed_example3) }
let(:failed_notification1) { RSpec::Core::Notifications::ExampleNotification.for(failed_example1) }
let(:failed_notification2) { RSpec::Core::Notifications::ExampleNotification.for(failed_example2) }
let(:failed_notification3) { RSpec::Core::Notifications::ExampleNotification.for(failed_example3) }
let(:failed_example1) do
exception = ::RuntimeError.new('Test Error 1')
exception = RuntimeError.new('Test Error 1')
exception.set_backtrace ["/spec/one_spec.rb:11:in `some_method'"]

example = self.class.example
Expand All @@ -33,7 +33,7 @@
end

let(:failed_example2) do
exception = ::RuntimeError.new('Test Error 1')
exception = RuntimeError.new('Test Error 1')
exception.set_backtrace ["/spec/two_spec.rb:20:in `some_method'"]

example = self.class.example
Expand All @@ -46,7 +46,7 @@
end

let(:failed_example3) do
exception = ::RuntimeError.new('Test Error 2')
exception = RuntimeError.new('Test Error 2')
exception.set_backtrace ["/spec/three_spec.rb:4:in `some_method'"]

example = self.class.example
Expand Down
2 changes: 1 addition & 1 deletion spec/failing_spec_detector_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec.describe FailingSpecDetector do
it "has a version number" do
it 'has a version number' do
expect(FailingSpecDetector::VERSION).not_to be nil
end
end
6 changes: 3 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require "bundler/setup"
require "failing_spec_detector/failing_spec_formatter"
require 'bundler/setup'
require 'failing_spec_detector/failing_spec_formatter'
require 'fileutils'
require 'tempfile'

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
config.example_status_persistence_file_path = '.rspec_status'

# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
Expand Down

0 comments on commit f44625a

Please sign in to comment.