From 405b52b2e1f1abb5e7823951135a507b2107643f Mon Sep 17 00:00:00 2001 From: Jake Spain Date: Mon, 30 Jan 2023 16:31:05 -0500 Subject: [PATCH] Add rakefile and rubocop config from other provider gems --- .jrubyrc | 2 ++ .rubocop.yml | 54 +++++++++++++++++++++++++++++++++++++++------ Rakefile | 27 ++++++++++++++++++----- spec/spec_helper.rb | 14 ++++++++++++ 4 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 .jrubyrc create mode 100644 spec/spec_helper.rb diff --git a/.jrubyrc b/.jrubyrc new file mode 100644 index 0000000..e140581 --- /dev/null +++ b/.jrubyrc @@ -0,0 +1,2 @@ +# for simplecov to work in jruby, without this we are getting errors when debugging spec tests +debug.fullTrace=true diff --git a/.rubocop.yml b/.rubocop.yml index e3462a7..850e19f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,13 +1,53 @@ AllCops: - TargetRubyVersion: 2.6 + Include: + - 'lib/**/*.rb' + Exclude: + - 'scripts/**/*' + - 'spec/**/*' + - 'vendor/**/*' + - Gemfile + - Rakefile -Style/StringLiterals: +# These short variable names make sense as exceptions to the rule, but generally I think short variable names do hurt readability +Naming/MethodParameterName: + AllowedNames: + - vm + - dc + - s + - x + - f + +#new cops: +Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1) Enabled: true - EnforcedStyle: double_quotes - -Style/StringLiteralsInInterpolation: +Lint/EmptyBlock: # (new in 1.1) Enabled: true - EnforcedStyle: double_quotes +Lint/ToEnumArguments: # (new in 1.1) + Enabled: true +Lint/UnmodifiedReduceAccumulator: # (new in 1.1) + Enabled: true +Style/ArgumentsForwarding: # (new in 1.1) + Enabled: false +Style/DocumentDynamicEvalDefinition: # (new in 1.1) + Enabled: true +Style/SwapValues: # (new in 1.1) + Enabled: false +#disabled + +Metrics/AbcSize: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false +Metrics/ParameterLists: + Enabled: false Layout/LineLength: - Max: 120 + Enabled: false +Metrics/BlockLength: + Enabled: false diff --git a/Rakefile b/Rakefile index 1924143..76d6a80 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,25 @@ -# frozen_string_literal: true +require 'rspec/core/rake_task' -require "bundler/gem_tasks" -require "rubocop/rake_task" +rubocop_available = Gem::Specification::find_all_by_name('rubocop').any? +require 'rubocop/rake_task' if rubocop_available -RuboCop::RakeTask.new +desc 'Run rspec tests with coloring.' +RSpec::Core::RakeTask.new(:test) do |t| + t.rspec_opts = %w[--color --format documentation] + t.pattern = 'spec/' +end -task default: :rubocop +desc 'Run rspec tests and save JUnit output to results.xml.' +RSpec::Core::RakeTask.new(:junit) do |t| + t.rspec_opts = %w[-r yarjuf -f JUnit -o results.xml] + t.pattern = 'spec/' +end + +if rubocop_available + desc 'Run RuboCop' + RuboCop::RakeTask.new(:rubocop) do |task| + task.options << '--display-cop-names' + end +end + +task :default => [:test] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..4cc72cf --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'simplecov' +SimpleCov.start do + add_filter '/spec/' +end + +def project_root_dir + File.dirname(File.dirname(__FILE__)) +end + +def fixtures_dir + File.join(project_root_dir, 'spec', 'fixtures') +end \ No newline at end of file