-
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,45 @@ | ||
# Omakase Ruby styling for Rails | ||
require: | ||
- rubocop-capybara | ||
- rubocop-minitest | ||
- rubocop-performance | ||
- rubocop-rails | ||
- standard | ||
|
||
inherit_gem: | ||
rubocop-rails-omakase: rubocop.yml | ||
standard: config/base.yml | ||
|
||
AllCops: | ||
SuggestExtensions: false | ||
TargetRubyVersion: 3.3 | ||
NewCops: enable | ||
|
||
Minitest/MultipleAssertions: | ||
Max: 10 # default 3 | ||
|
||
Style/FrozenStringLiteralComment: | ||
Enabled: true | ||
|
||
# These below cops are good practice going forward, but due to legacy we exclude some migrations | ||
Rails/CreateTableWithTimestamps: | ||
Exclude: | ||
- db/migrate/20181101154531_create_cms.rb | ||
- db/migrate/20220603215833_create_active_storage_variant_records.active_storage.rb | ||
|
||
Rails/SkipsModelValidations: | ||
Exclude: | ||
- db/migrate/20220603215832_add_service_name_to_active_storage_blobs.active_storage.rb | ||
|
||
Rails/BulkChangeTable: | ||
Exclude: | ||
- db/migrate/20181101154602_create_friendly_id_slugs.rb | ||
- db/migrate/20181101154832_add_slug_to_profiles.rb | ||
|
||
Rails/ThreeStateBooleanColumn: | ||
Exclude: | ||
- db/migrate/20181101154627_create_profiles.rb | ||
|
||
# Below are cops that are currently disabled, where we should fix in the future | ||
# TODO: Fix ProfilesController so we don't need to use global vars | ||
Style/GlobalVars: | ||
Exclude: | ||
- app/controllers/profiles_controller.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require_relative 'config/application' | ||
require_relative "config/application" | ||
|
||
Rails.application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module ApplicationCable | ||
class Channel < ActionCable::Channel::Base | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module ApplicationCable | ||
class Connection < ActionCable::Connection::Base | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationController < ActionController::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class ErrorsController < ApplicationController | ||
def file_not_found | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
class ProfilesController < ApplicationController | ||
$units = { access: "Access Services", | ||
archives: "Archives", | ||
bib: "Cataloguing Strategies", | ||
collections: "Collection Strategies", | ||
copyright: "Copyright", | ||
digital: "Digital Production & Preservation Services", | ||
digrepo: "Digital Repository & Data Services", | ||
dsc: "Digital Scholarship Centre", | ||
facilities: "Facilities", | ||
health: "Faculty Engagement (Health Sciences)", | ||
science: "Faculty Engagement (Natural + Applied Sciences)", | ||
humanities: "Faculty Engagement (Social Sciences + Humanities)", | ||
iss: "Information Services & User Engagement", | ||
admin: "Library Administration", | ||
lad: "Library Application Development", | ||
las: "Library Application Support", | ||
metadata: "Metadata Strategies", | ||
open: "Open Publishing & Digitization Services", | ||
rdm: "Research Data Management", | ||
researchimpact: "Research Impact", | ||
its: "Specialized Technical Support", | ||
special: "Special Collections", | ||
stratigic: "Strategic Partnerships", | ||
tl: "Teaching & Learning", | ||
ux: "User Experience" } | ||
$buildings = { augustana: "Augustana Campus Library", | ||
bsj: "Bibliothèque Saint-Jean", | ||
bpsc: "Bruce Peel Special Collections", | ||
cameron: "Cameron Library", | ||
sperber: "Sperber Library", | ||
rcrf: "Research & Collections Resource Facility", | ||
rutherford: "Rutherford Library", | ||
stjosephs: "St. Joseph's Library" } | ||
$units = {access: "Access Services", | ||
archives: "Archives", | ||
bib: "Cataloguing Strategies", | ||
collections: "Collection Strategies", | ||
copyright: "Copyright", | ||
digital: "Digital Production & Preservation Services", | ||
digrepo: "Digital Repository & Data Services", | ||
dsc: "Digital Scholarship Centre", | ||
facilities: "Facilities", | ||
health: "Faculty Engagement (Health Sciences)", | ||
science: "Faculty Engagement (Natural + Applied Sciences)", | ||
humanities: "Faculty Engagement (Social Sciences + Humanities)", | ||
iss: "Information Services & User Engagement", | ||
admin: "Library Administration", | ||
lad: "Library Application Development", | ||
las: "Library Application Support", | ||
metadata: "Metadata Strategies", | ||
open: "Open Publishing & Digitization Services", | ||
rdm: "Research Data Management", | ||
researchimpact: "Research Impact", | ||
its: "Specialized Technical Support", | ||
special: "Special Collections", | ||
stratigic: "Strategic Partnerships", | ||
tl: "Teaching & Learning", | ||
ux: "User Experience"} | ||
$buildings = {augustana: "Augustana Campus Library", | ||
bsj: "Bibliothèque Saint-Jean", | ||
bpsc: "Bruce Peel Special Collections", | ||
cameron: "Cameron Library", | ||
sperber: "Sperber Library", | ||
rcrf: "Research & Collections Resource Facility", | ||
rutherford: "Rutherford Library", | ||
stjosephs: "St. Joseph's Library"} | ||
|
||
# You'll have to define "cmsPassword" in secrets.yml, or this will fail. Thanks, ansible. | ||
http_basic_authenticate_with name: Rails.application.secrets.cms_user, password: Rails.application.secrets.cms_password, except: [ :index, :show ] | ||
http_basic_authenticate_with name: Rails.application.secrets.cms_user, password: Rails.application.secrets.cms_password, except: [:index, :show] | ||
|
||
def index | ||
path = request.url | ||
if path.include? "unit" | ||
@unit = params[:unit] | ||
if path.include? "unit" | ||
@unit = params[:unit] | ||
@unitname = $units[params[:unit].to_sym] | ||
@allunit = Profile.where(unit: @unit) | ||
@heads = @allunit.where(opt_in: true).order(:last_name) | ||
@staff = @allunit.where(opt_in: nil).order(:last_name) | ||
@profiles = @heads + @staff | ||
elsif path.include? "building" | ||
@building = params[:building] | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Missing indentation here and on line below |
||
@profiles = Profile.where("campus_address=?", params[:building]).order(:first_name) | ||
else | ||
@profiles = Profile.all.order(:first_name) | ||
end | ||
respond_to do |format| | ||
format.html | ||
format.csv { send_data @profiles.to_csv } | ||
end | ||
else | ||
@profiles = Profile.order(:first_name) | ||
end | ||
respond_to do |format| | ||
format.html | ||
format.csv { send_data @profiles.to_csv } | ||
end | ||
end | ||
|
||
def show | ||
@profile = Profile.friendly.find(params[:id]) | ||
@profile = Profile.friendly.find(params[:id]) | ||
end | ||
|
||
|
||
def new | ||
@profile = Profile.new | ||
@buildings = $buildings | ||
|
@@ -76,26 +77,26 @@ def edit | |
end | ||
|
||
def create | ||
@profile = Profile.new(profile_params) | ||
@profile.save | ||
redirect_to @profile | ||
@profile = Profile.new(profile_params) | ||
@profile.save | ||
redirect_to @profile | ||
end | ||
|
||
def update | ||
@profile = Profile.friendly.find(params[:id]) | ||
@profile = Profile.friendly.find(params[:id]) | ||
|
||
if @profile.update(profile_params) | ||
redirect_to @profile | ||
else | ||
render "edit" | ||
render "edit" | ||
end | ||
end | ||
|
||
def destroy | ||
@profile = Profile.friendly.find(params[:id]) | ||
@profile.destroy | ||
@profile = Profile.friendly.find(params[:id]) | ||
@profile.destroy | ||
|
||
redirect_to profiles_path | ||
redirect_to profiles_path | ||
end | ||
|
||
def units | ||
|
@@ -104,7 +105,6 @@ def units | |
@profiles = Profile.where("unit=?", params[:id]) | ||
end | ||
|
||
|
||
private | ||
|
||
def profile_params | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
module ApplicationHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationJob < ActiveJob::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationRecord < ActiveRecord::Base | ||
self.abstract_class = true | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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