From 668bd642e53e2d0fe7cd98bb4f20c2aae890fd57 Mon Sep 17 00:00:00 2001 From: Mattia Roccoberton Date: Thu, 3 Sep 2020 11:26:54 +0200 Subject: [PATCH] Add Rubocop --- .gitignore | 1 + .rubocop.yml | 74 ++++++-------------------------- Gemfile | 2 + activeadmin_quill_editor.gemspec | 1 + bin/rubocop | 29 +++++++++++++ 5 files changed, 47 insertions(+), 60 deletions(-) create mode 100755 bin/rubocop diff --git a/.gitignore b/.gitignore index 297db61..3cad262 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.orig /.rspec_failures +/.rubocop-* /Gemfile.lock /_misc/ diff --git a/.rubocop.yml b/.rubocop.yml index 7888bdd..6bcb7ad 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,73 +1,27 @@ -require: - - rubocop-rspec - -Rails: - Enabled: true +inherit_from: + - https://relaxed.ruby.style/rubocop.yml AllCops: - TargetRubyVersion: 2.3.8 - TargetRailsVersion: 5.2 Exclude: - - db/schema.rb - bin/* - - node_modules/**/* - # Temporary files - - tmp/**/* + - spec/dummy/**/* + NewCops: enable -Rails/InverseOf: +Gemspec/RequiredRubyVersion: Enabled: false -Style/Documentation: +Naming/FileName: Enabled: false -Metrics/ClassLength: - # Default value is 100 - Max: 150 - -Metrics/LineLength: - # Default is 80 +Layout/LineLength: + Enabled: true Max: 120 -Metrics/ModuleLength: - # Default is 100 - Max: 150 +Style/HashEachMethods: + Enabled: true -Metrics/ParameterLists: - # Default is 5 - Max: 6 +Style/HashTransformKeys: + Enabled: true -RSpec/ExampleLength: - # Default is 10 - Max: 20 - -Style/FrozenStringLiteralComment: - # Deface DOES edit strings in place - Exclude: - - 'app/overrides/**/*' - -RSpec/MultipleExpectations: - # Default is 3 - Max: 5 - -RSpec/NestedGroups: - # Default is 3 - Max: 6 - -Metrics/AbcSize: - Max: 25 - -Metrics/BlockLength: - # This value double the rubocop default - Max: 50 - -Metrics/CyclomaticComplexity: - # This value double the rubocop default - Max: 12 - -Metrics/MethodLength: - # This value double the rubocop default - Max: 20 - -Metrics/PerceivedComplexity: - # Default is 7 - Max: 10 +Style/HashTransformValues: + Enabled: true diff --git a/Gemfile b/Gemfile index fa75df1..7f4f5e9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' gemspec diff --git a/activeadmin_quill_editor.gemspec b/activeadmin_quill_editor.gemspec index 19d200e..3bcca4c 100644 --- a/activeadmin_quill_editor.gemspec +++ b/activeadmin_quill_editor.gemspec @@ -25,6 +25,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'puma', '~> 4.3.5' spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1' spec.add_development_dependency 'rspec-rails', '~> 4.0.1' + spec.add_development_dependency 'rubocop', '~> 0.90.0' spec.add_development_dependency 'selenium-webdriver', '~> 3.142.7' spec.add_development_dependency 'sqlite3', '~> 1.4.2' end diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..d0c4882 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rubocop' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rubocop", "rubocop")