Skip to content

Commit

Permalink
chore(lint): mandatory linter commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenrixon committed Jan 25, 2023
1 parent c0d102f commit e893f2f
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 83 deletions.
23 changes: 7 additions & 16 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ inherit_gem:
rubocop-mhenrixon:
- config/default.yml

require:
- rubocop-performance
- rubocop-rake
- rubocop-rspec

AllCops:
NewCops: enable
TargetRubyVersion: 2.7
Expand All @@ -10,17 +15,13 @@ AllCops:
Exclude:
- "**/*.erb"
- "**/*.lua"
- '**/vendor/**/*'
- "**/vendor/**/*"
- "myapp/**/*"
- "bin/bench"

Layout/EndAlignment:
EnforcedStyleAlignWith: variable

Layout/LineLength:
Exclude:
- myapp/db/**/*.rb
- myapp/config/initializers/devise.rb

Layout/LineContinuationLeadingSpace:
Enabled: false

Expand All @@ -44,16 +45,9 @@ Metrics/AbcSize:
Metrics/CyclomaticComplexity:
Max: 7

Metrics/MethodLength:
Max: 13
Exclude:
- myapp/db/**/*.rb
- myapp/config/initializers/devise.rb

Metrics/BlockLength:
Enabled: true
Exclude:
- "myapp/db/**/*.rb"
- "**/spec/**/*.rb"
- "**/*.rake"
- "Rakefile"
Expand All @@ -74,8 +68,6 @@ Naming/FileName:
- lib/sidekiq-unique-jobs.rb
- Gemfile
- Rakefile
- myapp/Gemfile
- myapp/Rakefile

Naming/RescuedExceptionsVariableName:
PreferredName: ex
Expand Down Expand Up @@ -139,7 +131,6 @@ Style/Documentation:
Enabled: true
Exclude:
- "examples/**/*.rb"
- "myapp/**/*.rb"
- "bin/**/*.rb"
- "lib/sidekiq_unique_jobs/testing.rb"
- "lib/sidekiq_unique_jobs/core_ext.rb"
Expand Down
34 changes: 34 additions & 0 deletions myapp/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
inherit_from:
- ../.rubocop.yml

AllCops:
Include:
- "myapp/**/*"
- "**/*.rb"

require:
- rubocop-performance
- rubocop-rake
- rubocop-rails
- rubocop-rspec

Layout/LineLength:
Exclude:
- db/**/*.rb
- config/initializers/devise.rb

Metrics/MethodLength:
Max: 13
Exclude:
- db/**/*.rb
- config/initializers/devise.rb

Metrics/BlockLength:
Exclude:
- "db/**/*.rb"

Naming/FileName:
Exclude:
- Gemfile
- Rakefile
- Gemfile
- Rakefile

Naming/MethodParameterName:
Enabled: false

Style/Documentation:
Exclude:
- "**/*.rb"
102 changes: 51 additions & 51 deletions myapp/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,54 @@ require_relative "config/application"

Rails.application.load_tasks

desc "Run ERBLint"
task :erblint do # rubocop:disable Rails/RakeEnvironment
sh("bin/erblint --lint-all")
end

desc "Fix ERBLint"
task "erblint:fix" do # rubocop:disable Rails/RakeEnvironment
sh("bin/erblint --lint-all -a")
end

desc "Run ESLint"
task :eslint do # rubocop:disable Rails/RakeEnvironment
sh("yarn lint:js")
end

desc "Fix ESLint problems"
task "eslint:fix" do # rubocop:disable Rails/RakeEnvironment
sh("yarn lint:js --fix")
end

desc "Run ESLint"
task :stylelint do # rubocop:disable Rails/RakeEnvironment
sh("yarn lint:css")
end

desc "Fix ESLint problems"
task "stylelint:fix" do # rubocop:disable Rails/RakeEnvironment
sh("yarn lint:css --fix")
end

multitask lint: %i[erblint eslint stylelint]

multitask "lint:fix" => %w[
erblint:fix
eslint:fix
stylelint:fix
]

multitask "lint:fixall" => %w[
erblint:fix
eslint:fix
stylelint:fix
]

multitask ci: %i[
erblint
eslint
rubocop
spec
stylelint
]
desc "Run ERBLint"
task :erblint do # rubocop:disable Rails/RakeEnvironment
sh("bin/erblint --lint-all")
end

desc "Fix ERBLint"
task "erblint:fix" do # rubocop:disable Rails/RakeEnvironment
sh("bin/erblint --lint-all -a")
end

desc "Run ESLint"
task :eslint do # rubocop:disable Rails/RakeEnvironment
sh("yarn lint:js")
end

desc "Fix ESLint problems"
task "eslint:fix" do # rubocop:disable Rails/RakeEnvironment
sh("yarn lint:js --fix")
end

desc "Run ESLint"
task :stylelint do # rubocop:disable Rails/RakeEnvironment
sh("yarn lint:css")
end

desc "Fix ESLint problems"
task "stylelint:fix" do # rubocop:disable Rails/RakeEnvironment
sh("yarn lint:css --fix")
end

multitask lint: [:erblint, :eslint, :stylelint]

multitask "lint:fix" => %w[
erblint:fix
eslint:fix
stylelint:fix
]

multitask "lint:fixall" => %w[
erblint:fix
eslint:fix
stylelint:fix
]

multitask ci: [
:erblint,
:eslint,
:rubocop,
:spec,
:stylelint,
]
10 changes: 5 additions & 5 deletions myapp/app/helpers/devise_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
# rubocop:disable Metrics/MethodLength
# devise helper
module DeviseHelper
def devise_error_messages!
Expand All @@ -11,7 +11,7 @@ def devise_error_messages!
sentence = I18n.t(
"errors.messages.not_saved",
count: resource.errors.count,
resource: resource.class.model_name.human.downcase
resource: resource.class.model_name.human.downcase,
)

html = <<-HTML
Expand All @@ -21,7 +21,7 @@ def devise_error_messages!
</div>
HTML

html.html_safe
html.html_safe # rubocop:disable Rails/OutputSafety
end

def devise_simple_error_messages!
Expand Down Expand Up @@ -49,7 +49,7 @@ def devise_simple_error_messages!
HTML
end

html.html_safe
html.html_safe # rubocop:disable Rails/OutputSafety
end
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
# rubocop:enable Metrics/MethodLength
4 changes: 2 additions & 2 deletions myapp/app/jobs/cron_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class CronJob
on_conflict: :reschedule

def perform
puts "hello"
Rails.logger.debug "hello"
sleep 1
puts "bye"
Rails.logger.debug "bye"
end
end
2 changes: 1 addition & 1 deletion myapp/app/jobs/issue_432_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def redis
end

def log(arguments, action)
puts " !!! #{action} #{arguments.inspect} "
Rails.logger.debug { " !!! #{action} #{arguments.inspect} " }
"\at #{Time.now.to_i - redis.get('start').to_i} sec, " \
"counter is #{redis.get('counter')}"
end
Expand Down
27 changes: 27 additions & 0 deletions myapp/bin/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/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.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("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")
2 changes: 1 addition & 1 deletion myapp/db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
email: "[email protected]",
password: "Abc123!!",
password_confirmation: "Abc123!!",
admin: true
admin: true,
)

user.confirm
2 changes: 1 addition & 1 deletion myapp/spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require "rspec/rails"
require "pry"

Dir[Rails.root.join("spec", "support", "**", "*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f }

ActiveRecord::Migration.maintain_test_schema!

Expand Down
2 changes: 1 addition & 1 deletion myapp/spec/system/static_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "system_helper"

RSpec.describe "Static pages", driver: :null do
let(:page) { @playwright_page }
let(:page) { @playwright_page } # rubocop:disable RSpec/InstanceVariable

it "can browse" do
page.goto(root_path)
Expand Down
8 changes: 4 additions & 4 deletions myapp/spec/system/support/playwright_setup.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

BROWSERS = %i[
chrome
firefox
webkit
BROWSERS = [
:chrome,
:firefox,
:webkit,
].freeze
HEADLESS = %w[1 true].include?(ENV.fetch("HEADLESS", "true"))
BROWSER = ENV.fetch("BROWSER", :webkit).to_sym
Expand Down
2 changes: 1 addition & 1 deletion myapp/spec/system_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require "rails_helper"

Dir[Rails.root.join("spec/system/support/**/*.rb")].each { |f| require f }
Dir[Rails.root.join("spec/system/support/**/*.rb")].sort.each { |f| require f }
require Rails.root.join("spec/support/webmock_setup").to_s

0 comments on commit e893f2f

Please sign in to comment.