From 7abb42cf0ef7c8a38cef93464fcbb93489581be2 Mon Sep 17 00:00:00 2001 From: Peter Suschlik Date: Mon, 9 Feb 2015 17:10:50 +0100 Subject: [PATCH] Run rubocop --- .rubocop.yml | 63 ++++++++++++++++++++++++++++++++ .rubocop_todo.yml | 6 +++ .travis.yml | 2 +- Gemfile | 4 ++ Rakefile | 10 +---- rakelib/rubocop.rake | 18 +++++++++ spec/integration/adapter_spec.rb | 2 +- spec/test/adapter_lint_test.rb | 2 +- 8 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml create mode 100644 rakelib/rubocop.rake diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..d825743 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,63 @@ +# Generated by `rubocop --auto-gen-config` +inherit_from: .rubocop_todo.yml + +# It’s quite readable when we know what we are doing +Lint/AssignmentInCondition: + Enabled: false + +# No need to handle LoadError in rake +Lint/HandleExceptions: + Exclude: + - rakelib/*.rake + +# The enforced style doesn’t match Vim’s defaults +Style/AlignParameters: + Enabled: false + +# UTF-8 is perfectly fine in comments +Style/AsciiComments: + Enabled: false + +# Allow using braces for value-returning blocks +Style/Blocks: + Enabled: false + +# Documentation checked by Inch CI +Style/Documentation: + Enabled: false + +# Early returns have their vices +Style/GuardClause: + Enabled: false + +# Need to be skipped for >-> usage +Style/Lambda: + Enabled: false + +# Multiline block chains are ok +Style/MultilineBlockChain: + Enabled: false + +# Even a single escaped slash can be confusing +Style/RegexpLiteral: + MaxSlashes: 0 + +# Don’t introduce semantic fail/raise distinction +Style/SignalException: + EnforcedStyle: only_raise + +# Need to be skipped for >-> usage +Style/SpaceAroundOperators: + Enabled: false + +# Accept both single and double quotes +Style/StringLiterals: + Enabled: false + +# Allow def self.foo; @foo; end +Style/TrivialAccessors: + Enabled: false + +# Allow rom-csv +Style/FileName: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..aaeb0ca --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,6 @@ +# This configuration was generated by `rubocop --auto-gen-config` +# on 2015-02-09 17:10:04 +0100 using RuboCop version 0.28.0. +# 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. diff --git a/.travis.yml b/.travis.yml index a5bd467..aea7707 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: ruby -bundler_args: --without yard guard benchmarks +bundler_args: --without tools env: - CODECLIMATE_REPO_TOKEN=886f3b795e74159719804f8e18b853f4c23a81bd814404e52ec248a0dae6d656 script: "bundle exec rake spec" diff --git a/Gemfile b/Gemfile index ecdf9e0..5b228c2 100644 --- a/Gemfile +++ b/Gemfile @@ -9,3 +9,7 @@ group :test do gem 'virtus' gem 'minitest' end + +group :tools do + gem 'rubocop' +end diff --git a/Rakefile b/Rakefile index acef8c1..6f290b8 100644 --- a/Rakefile +++ b/Rakefile @@ -1,10 +1,4 @@ -require "rspec/core/rake_task" -require "rubocop/rake_task" - -task default: [:spec, :rubocop] +require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) - -RuboCop::RakeTask.new do |task| - task.options << "--display-cop-names" -end +task default: :spec diff --git a/rakelib/rubocop.rake b/rakelib/rubocop.rake new file mode 100644 index 0000000..73ca9a9 --- /dev/null +++ b/rakelib/rubocop.rake @@ -0,0 +1,18 @@ +begin + require "rubocop/rake_task" + + Rake::Task[:default].enhance [:rubocop] + + RuboCop::RakeTask.new do |task| + task.options << "--display-cop-names" + end + + namespace :rubocop do + desc 'Generate a configuration file acting as a TODO list.' + task :auto_gen_config do + exec "bundle exec rubocop --auto-gen-config" + end + end + +rescue LoadError +end diff --git a/spec/integration/adapter_spec.rb b/spec/integration/adapter_spec.rb index 0f67dd8..ac997c1 100644 --- a/spec/integration/adapter_spec.rb +++ b/spec/integration/adapter_spec.rb @@ -39,7 +39,7 @@ def by_name(name) expect(jane.email).to eql('jane@doe.org') expect(jane.roles.length).to eql(2) expect(jane.roles).to eql([ - { name: 'Member' } , { name: 'Admin' } + { name: 'Member' }, { name: 'Admin' } ]) end end diff --git a/spec/test/adapter_lint_test.rb b/spec/test/adapter_lint_test.rb index 5e25fa2..b96bda8 100644 --- a/spec/test/adapter_lint_test.rb +++ b/spec/test/adapter_lint_test.rb @@ -8,7 +8,7 @@ class MemoryAdapterLintTest < MiniTest::Test def setup @adapter = ROM::YAML::Adapter - @uri = "yaml://#{File.expand_path("./spec/fixtures/test_db.yml")}" + @uri = "yaml://#{File.expand_path('./spec/fixtures/test_db.yml')}" end end