diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..b2fbef9 --- /dev/null +++ b/.rubocop.yml @@ -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' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..968cd94 --- /dev/null +++ b/.rubocop_todo.yml @@ -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' diff --git a/Gemfile b/Gemfile index 1f49266..59f5be4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,4 @@ -source "https://rubygems.org" - +source 'https://rubygems.org' # Specify your gem's dependencies in failing_spec_detector.gemspec gemspec diff --git a/Rakefile b/Rakefile index 3c5b792..26cc08d 100644 --- a/Rakefile +++ b/Rakefile @@ -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) diff --git a/bin/console b/bin/console index c7fac3d..c9787af 100755 --- a/bin/console +++ b/bin/console @@ -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. @@ -10,5 +10,5 @@ require "failing_spec_detector" # require "pry" # Pry.start -require "irb" +require 'irb' IRB.start(__FILE__) diff --git a/failing_spec_detector.gemspec b/failing_spec_detector.gemspec index d31f9fb..7eb4f9d 100644 --- a/failing_spec_detector.gemspec +++ b/failing_spec_detector.gemspec @@ -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 = ["aballaghsafa@gmail.com"] + spec.authors = ['safa'] + spec.email = ['aballaghsafa@gmail.com'] 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 diff --git a/spec/failing_spec_detector/failing_spec_formatter_spec.rb b/spec/failing_spec_detector/failing_spec_formatter_spec.rb index a2f2bdf..566bae8 100644 --- a/spec/failing_spec_detector/failing_spec_formatter_spec.rb +++ b/spec/failing_spec_detector/failing_spec_formatter_spec.rb @@ -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 @@ -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 @@ -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 diff --git a/spec/failing_spec_detector_spec.rb b/spec/failing_spec_detector_spec.rb index 3a374c7..9b91d4a 100644 --- a/spec/failing_spec_detector_spec.rb +++ b/spec/failing_spec_detector_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5327447..fc86103 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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!