Skip to content

Commit

Permalink
Add rubocop (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefarias authored Mar 5, 2024
1 parent f68a3d7 commit 4e10630
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 10 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/ci_tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Tests
name: CI

on:
push:
Expand All @@ -7,13 +7,28 @@ on:
pull_request:

jobs:
build:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler: default
bundler-cache: true
rubygems: latest

- name: Lint code
run: bin/rubocop -f github
test:
runs-on: ubuntu-latest
steps:
- name: SQLite3 version
run: sqlite3 --version

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
12 changes: 12 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
inherit_gem: { rubocop-37signals: rubocop.yml }

require: rubocop-capybara

AllCops:
TargetRubyVersion: 3.0
Exclude:
- "test/dummy/db/schema.rb"

Layout/CommentIndentation:
Exclude:
- "lib/hotwire_combobox/helper.rb"
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ gem "turbo-rails"
gem "propshaft"
gem "minitest-focus"
gem "geared_pagination"
gem "sprockets-rails", :require => "sprockets/railtie"
gem "sprockets-rails", require: "sprockets/railtie"
gem "rubocop-37signals", require: false
gem "rubocop-capybara", require: false
43 changes: 43 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.6)
builder (3.2.4)
Expand Down Expand Up @@ -122,6 +123,8 @@ GEM
irb (1.11.2)
rdoc
reline (>= 0.4.2)
json (2.7.1)
language_server-protocol (3.17.0.3)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -151,6 +154,10 @@ GEM
racc (~> 1.4)
nokogiri (1.16.2-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
propshaft (0.8.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
Expand Down Expand Up @@ -199,13 +206,46 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.1.0)
rdoc (6.6.2)
psych (>= 4.0.0)
regexp_parser (2.9.0)
reline (0.4.3)
io-console (~> 0.5)
rexml (3.2.6)
rubocop (1.61.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-37signals (1.0.0)
rubocop
rubocop-minitest
rubocop-performance
rubocop-rails
rubocop-ast (1.31.1)
parser (>= 3.3.0.4)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-minitest (0.34.5)
rubocop (>= 1.39, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rails (2.24.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
selenium-webdriver (4.10.0)
Expand All @@ -232,6 +272,7 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
webdrivers (5.3.1)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
Expand All @@ -258,6 +299,8 @@ DEPENDENCIES
minitest-focus
propshaft
puma
rubocop-37signals
rubocop-capybara
selenium-webdriver
sprockets-rails
sqlite3
Expand Down
3 changes: 3 additions & 0 deletions bin/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
require "bundler/setup"
load Gem.bin_path("rubocop", "rubocop")
2 changes: 1 addition & 1 deletion lib/hotwire_combobox/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Engine < ::Rails::Engine
unless HotwireCombobox.bypass_convenience_methods?
module FormBuilderExtensions
def combobox(*args, **kwargs)
@template.hw_combobox_tag *args, **kwargs.merge(form: self)
@template.hw_combobox_tag(*args, **kwargs.merge(form: self))
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/dummy/app/controllers/new_options_forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def user_params
.permit(
:favorite_state_id,
:home_state_id,
favorite_state_attributes: [:name],
home_state_attributes: [:name])
favorite_state_attributes: %i[ name ],
home_state_attributes: %i[ name ])
end
end
4 changes: 2 additions & 2 deletions test/dummy/app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def user_params
.permit(
:favorite_state_id,
:home_state_id,
favorite_state_attributes: [:name],
home_state_attributes: [:name])
favorite_state_attributes: %i[ name ],
home_state_attributes: %i[ name ])
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ENV["RAILS_ENV"] = "test"

require_relative "../test/dummy/config/environment"
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
ActiveRecord::Migrator.migrations_paths = [ File.expand_path("../test/dummy/db/migrate", __dir__) ]
ActiveRecord::Migrator.migrations_paths << File.expand_path("../db/migrate", __dir__)
require "rails/test_help"

Expand Down

0 comments on commit 4e10630

Please sign in to comment.