-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rubocop linter and CI job #579
Conversation
@@ -307,7 +344,12 @@ GEM | |||
zeitwerk (2.6.13) | |||
|
|||
PLATFORMS | |||
ruby |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't working for me with Github Actions. Believe you don't use ruby
anymore and instead break it down by individual platforms like so (this is what a newly generated Rails app will do it appears)
@@ -1,113 +1,113 @@ | |||
class ProfilesController < ApplicationController | |||
$units = {:access => "Access Services", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly whitespace diffs (2 spaces for tabs vs the previous 4 spaces for tabs). Also use symbols over hash rockets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed some indentation issues, Layout/IndentationWidth is disabled in rubocop-rails-omakase (https://github.com/rails/rubocop-rails-omakase/blob/1c1962b59c5135ed2168fd26229224e9a1c53c8e/rubocop.yml#L70) which I suspect is why these are not flagged as rubocop violations. Everything else looks good to me other than that!
app/models/profile.rb
Outdated
friendly_id :full_name, use: :slugged | ||
def full_name | ||
"#{first_name}-#{last_name}" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra indentation here
t.string :liason | ||
t.timestamps null: false | ||
t.string :first_name | ||
t.string :last_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra indentation until line 21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good catches. Yeah, not a fan of this 🤔.
Wonder if we can just turn that Layout/IndentationWidth
cop you found back on as a one off and this problem goes away.
Will try to do this.
end | ||
def self.to_csv(options = {}) | ||
CSV.generate(options) do |csv| | ||
csv << column_names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing indentation here and below
@profiles = @heads + @staff | ||
elsif path.include? "building" | ||
@building = params[:building] | ||
@buildingname = $buildings[params[:building].to_sym] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing indentation here and on line below
path = request.url | ||
if path.include? "unit" | ||
@unit = params[:unit] | ||
@unitname = $units[params[:unit].to_sym] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing indentation here until line 47
digrepo: "Digital Repository & Data Services", | ||
dsc: "Digital Scholarship Centre", | ||
facilities: "Facilities", | ||
health: "Faculty Engagement (Health Sciences)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra indentation here and on line 16
stratigic: "Strategic Partnerships", | ||
tl: "Teaching & Learning", | ||
ux: "User Experience" } | ||
$buildings = { augustana: "Augustana Campus Library", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra indentation here
|
||
def show | ||
@profile = Profile.friendly.find(params[:id]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra indentation here along with others up until line 98
Hey @ConnorSheremeta, Trica said your back today. Need another review here if you can 🙏. Main difference is I switched to Standard over Rails-omakase, due to those weird spacing issues you discovered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I am however curious about linting being done on CI in a separate job rather than as a step in the main job (which is how jupiter is setup)
library-cms/.github/workflows/ci.yml
Line 9 in 1f16575
lint: |
I wonder if the runtime of those checks would differ having a different setup 🤔
class Profile < ActiveRecord::Base | ||
# frozen_string_literal: true | ||
|
||
class Profile < ApplicationRecord |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
csv << column_names | ||
all.each do |product| | ||
csv << product.attributes.values_at(*column_names) | ||
find_each do |product| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -84,9 +86,9 @@ | |||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') | |||
|
|||
if ENV["RAILS_LOG_TO_STDOUT"].present? | |||
logger = ActiveSupport::Logger.new(STDOUT) | |||
logger = ActiveSupport::Logger.new($stdout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
config.exception_level_filters.merge!({ | ||
"ActionController::RoutingError" => "ignore" | ||
}) | ||
config.exception_level_filters["ActionController::RoutingError"] = "ignore" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -83,9 +85,9 @@ | |||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") | |||
|
|||
if ENV["RAILS_LOG_TO_STDOUT"].present? | |||
logger = ActiveSupport::Logger.new(STDOUT) | |||
logger = ActiveSupport::Logger.new($stdout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
It's still using the same runtime. This also allows the linter job and test job to run parallel together (which might not be big on a small app but in theory means faster CI runs). Don't really see much concern here, especially when GitHub Actions is free (I think?) to run it parallelized like this. |
#522
This MR adds Rubcop using StandardRB and other Rubocop addons. This MR fixes all the violations that currently exists and turns on a CI job for rubocop linting going forward.
Uses the new style guide for rubocop from Rails: https://github.com/rails/rubocop-rails-omakaseWhich should be a very lightweight style guide. We could later on use the one from Jupiter or go to something like StandardDecided to use Standard instead, via rubocop.yml. As Connor discovered, many places where tab/spacing wasn't done right with
rubocop-rails-omakase
. So instead of trying to fix and turn on some custom cops that will fix the spacing, decided to just use Standard instead.Most corrections are the following: