From 410c332ec4514b27a3aef6c6abc53f98f8f62e80 Mon Sep 17 00:00:00 2001 From: Jon Rogers Date: Fri, 24 Jan 2020 00:06:53 -0800 Subject: [PATCH] Add rubocop rake task Problem ------- More dog-fooding. We want to promote the use of our carbonfive/c5-conventions rubocop file. Let's use it here. Solution -------- * Copy the carbonfive/c5-conventions `.rubocop.yml` into place * Remove `rubocop-performance` because we don't *really* need it and it'd require adding another gem dev depenency - seems overkill for it's possible benefit on *this* project * Add `lib/tasks` to `rakelib` * Add `rubocop.rake` file to get the `rubocop` and `rubocop:autocorrect` tasks * Run rubocop:autocorrect which cleaned a few things in bin/raygun NOTE ---- This repo is *still* not rubocop clean. There are several not-autofixable issues that could (should?) be addressed once this is approved. --- .rubocop.yml | 104 +++++++++++++++++++++++++++++++++++++++++ Rakefile | 1 + bin/raygun | 4 +- lib/tasks/rubocop.rake | 3 ++ raygun.gemspec | 1 + 5 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 .rubocop.yml create mode 100644 lib/tasks/rubocop.rake diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..e169310 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,104 @@ +# Configuration hierarchy: +# +# 1. Rubocop defaults +# 2. Carbon Five defaults (this file) +# 3. Project overrides +# +# See http://rubocop.readthedocs.io/en/latest/configuration/#inheriting-configuration-from-a-remote-url for details. +# + +AllCops: + DisplayCopNames: true + DisplayStyleGuide: true + +# +# Ruby Cops +# + +Layout/CaseIndentation: + Enabled: false + +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent + +Layout/HashAlignment: + Enabled: false + +Layout/LineLength: + Max: 120 + +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +Lint/AmbiguousBlockAssociation: + Enabled: false + +Lint/ScriptPermission: + Exclude: + - "Rakefile" + +Metrics/AbcSize: + Max: 35 + Exclude: + - "spec/**/*" + +Metrics/BlockLength: + CountComments: false + Max: 50 + Exclude: + - "config/**/*" + - "spec/**/*" + +Metrics/ClassLength: + Max: 250 + Exclude: + - "spec/**/*" + +Metrics/MethodLength: + Max: 25 + Exclude: + - "db/migrate/*" + - "spec/**/*" + +Naming/PredicateName: + Enabled: false + +Security/YAMLLoad: + Enabled: false + +Style/BarePercentLiterals: + EnforcedStyle: percent_q + +Style/BlockDelimiters: + EnforcedStyle: braces_for_chaining + +Style/Documentation: + Enabled: false + +Style/EmptyMethod: + EnforcedStyle: expanded + +Style/FrozenStringLiteralComment: + EnforcedStyle: never + +Style/Lambda: + EnforcedStyle: literal + +Style/ModuleFunction: + EnforcedStyle: extend_self + +Style/MutableConstant: + Enabled: false + +Style/PreferredHashMethods: + Enabled: false + +Style/StringLiterals: + EnforcedStyle: double_quotes + +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes + +Style/StructInheritance: + Enabled: true + diff --git a/Rakefile b/Rakefile index 2995527..3d7181d 100644 --- a/Rakefile +++ b/Rakefile @@ -1 +1,2 @@ require "bundler/gem_tasks" +Rake.add_rakelib "lib/tasks" diff --git a/bin/raygun b/bin/raygun index 53e7864..a9497e2 100755 --- a/bin/raygun +++ b/bin/raygun @@ -1,10 +1,10 @@ #!/usr/bin/env ruby -File.expand_path('../../lib', __FILE__).tap do |lib| +File.expand_path("../lib", __dir__).tap do |lib| $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) end -require 'raygun/raygun' +require "raygun/raygun" raygun = Raygun::Runner.parse(ARGV) diff --git a/lib/tasks/rubocop.rake b/lib/tasks/rubocop.rake new file mode 100644 index 0000000..86bf404 --- /dev/null +++ b/lib/tasks/rubocop.rake @@ -0,0 +1,3 @@ +require "rubocop/rake_task" + +RuboCop::RakeTask.new diff --git a/raygun.gemspec b/raygun.gemspec index 7c63440..8f06903 100644 --- a/raygun.gemspec +++ b/raygun.gemspec @@ -23,4 +23,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency "bundler", "~> 2.0" gem.add_development_dependency "rake", "~> 13.0" + gem.add_development_dependency "rubocop", "~> 0.79" end