Skip to content

Commit

Permalink
Set up linters
Browse files Browse the repository at this point in the history
  • Loading branch information
rubydevi committed Oct 31, 2023
1 parent 6f75df7 commit d889562
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 17 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Linters

on: pull_request

env:
FORCE_COLOR: 1

jobs:
rubocop:
name: Rubocop
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-ruby@v1
with:
ruby-version: 3.1.x
- name: Setup Rubocop
run: |
gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/
[ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.rubocop.yml
- name: Rubocop Report
run: rubocop --color
nodechecker:
name: node_modules checker
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Check node_modules existence
run: |
if [ -d "node_modules/" ]; then echo -e "\e[1;31mThe node_modules/ folder was pushed to the repo. Please remove it from the GitHub repository and try again."; echo -e "\e[1;32mYou can set up a .gitignore file with this folder included on it to prevent this from happening in the future." && exit 1; fi
62 changes: 62 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
AllCops:
NewCops: enable
Exclude:
- 'db/**/*'
- 'bin/*'
- 'config/**/*'
- 'Guardfile'
- 'Rakefile'
- 'node_modules/**/*'

DisplayCopNames: true

Layout/LineLength:
Max: 120
Metrics/MethodLength:
Include:
- 'app/controllers/*'
- 'app/models/*'
Max: 20
Metrics/AbcSize:
Include:
- 'app/controllers/*'
- 'app/models/*'
Max: 50
Metrics/ClassLength:
Max: 150
Metrics/BlockLength:
AllowedMethods: ['describe']
Max: 30

Style/Documentation:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Style/EachForSimpleLoop:
Enabled: false
Style/AndOr:
Enabled: false
Style/DefWithParentheses:
Enabled: false
Style/FrozenStringLiteralComment:
EnforcedStyle: never

Layout/EndOfLine:
Enabled: False
Layout/HashAlignment:
EnforcedColonStyle: key
Layout/ExtraSpacing:
AllowForAlignment: false
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
Lint/RaiseException:
Enabled: false
Lint/StructNewOverride:
Enabled: false
Style/HashEachMethods:
Enabled: false
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
18 changes: 8 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
source "https://rubygems.org"
source 'https://rubygems.org'

ruby "3.2.2"
ruby '3.2.2'

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.1"
gem 'rails', '~> 7.1.1'

# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"
gem 'pg', '~> 1.1'

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"
gem 'puma', '>= 5.0'

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
# gem "jbuilder"
Expand All @@ -24,10 +24,10 @@ gem "puma", ">= 5.0"
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ]
gem 'tzinfo-data', platforms: %i[windows jruby]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
gem 'bootsnap', require: false

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"
Expand All @@ -37,12 +37,10 @@ gem "bootsnap", require: false

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ]
gem 'debug', platforms: %i[mri windows]
end

group :development do
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"

end

4 changes: 2 additions & 2 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout "mailer"
default from: 'from@example.com'
layout 'mailer'
end
2 changes: 1 addition & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is used by Rack-based servers to start the application.

require_relative "config/environment"
require_relative 'config/environment'

run Rails.application
Rails.application.load_server
2 changes: 1 addition & 1 deletion test/channels/application_cable/connection_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "test_helper"
require 'test_helper'

module ApplicationCable
class ConnectionTest < ActionCable::Connection::TestCase
Expand Down
6 changes: 3 additions & 3 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'

module ActiveSupport
class TestCase
Expand Down

0 comments on commit d889562

Please sign in to comment.