Skip to content

Commit

Permalink
Improve Rubocop config, fix offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Aug 29, 2024
1 parent b5d5ee1 commit 889fbcb
Show file tree
Hide file tree
Showing 77 changed files with 1,179 additions and 1,000 deletions.
27 changes: 26 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AllCops:
Exclude:
- bin/*
- gemfiles/*
- spec/**/*
- spec/dummy/**/*

Gemspec/RequireMFA:
Enabled: false
Expand Down Expand Up @@ -45,12 +45,18 @@ Style/Alias:
Style/RaiseArgs:
EnforcedStyle: compact

Style/EmptyMethod:
Exclude:
- spec/**/*

##########
# LAYOUT #
##########

Layout/LineLength:
Max: 130
Exclude:
- spec/**/*

Layout/EmptyLines:
Enabled: false
Expand Down Expand Up @@ -80,3 +86,22 @@ Layout/HashAlignment:

Naming/BlockForwarding:
Enabled: false

#########
# RSPEC #
#########

RSpec/MultipleExpectations:
Enabled: false

RSpec/ExampleLength:
Enabled: false

RSpec/InstanceVariable:
Enabled: false

RSpec/ChangeByZero:
Enabled: false

RSpec/NotToNot:
EnforcedStyle: to_not
2 changes: 2 additions & 0 deletions spec/config_capybara.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Capybara.register_driver(:headless_chrome) do |app|
Capybara::Cuprite::Driver.new(app, headless: true, js_errors: true, window_size: [1200, 800])
end
Expand Down
2 changes: 2 additions & 0 deletions spec/config_rspec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.configure do |config|
config.include Capybara::DSL

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
Expand Down
11 changes: 7 additions & 4 deletions spec/dummy/app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class AssignmentsController < ApplicationController
before_action :set_assignment, only: [:show, :edit, :update, :destroy]
before_action :create_new_form, only: [:new, :create]
before_action :create_edit_form, only: [:edit, :update]
before_action :set_assignment, only: %i[show edit update destroy]
before_action :create_new_form, only: %i[new create]
before_action :create_edit_form, only: %i[edit update]


def index
Expand Down Expand Up @@ -52,6 +54,7 @@ def destroy
end

private

# Use callbacks to share common setup or constraints between actions.
def set_assignment
@assignment = Assignment.find(params[:id])
Expand All @@ -68,6 +71,6 @@ def create_edit_form

# Never trust parameters from the scary internet, only allow the white list through.
def assignment_params
params.require(:assignment).permit(:name, tasks_attributes: [:id, :name, :_destroy])
params.require(:assignment).permit(:name, tasks_attributes: %i[id name _destroy])
end
end
11 changes: 7 additions & 4 deletions spec/dummy/app/controllers/conferences_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class ConferencesController < ApplicationController
before_action :set_conference, only: [:show, :edit, :update, :destroy]
before_action :create_new_form, only: [:new, :create]
before_action :create_edit_form, only: [:edit, :update]
before_action :set_conference, only: %i[show edit update destroy]
before_action :create_new_form, only: %i[new create]
before_action :create_edit_form, only: %i[edit update]

# GET /conferences
# GET /conferences.json
Expand Down Expand Up @@ -62,6 +64,7 @@ def destroy
end

private

# Use callbacks to share common setup or constraints between actions.
def set_conference
@conference = Conference.find(params[:id])
Expand All @@ -79,6 +82,6 @@ def create_edit_form
# Never trust parameters from the scary internet, only allow the white list through.
def conference_params
params.require(:conference).permit(:name, :city, speaker_attributes: [:id, :name, :occupation,
presentations_attributes: [:id, :_destroy, :topic, :duration]])
{ presentations_attributes: %i[id _destroy topic duration] },])
end
end
17 changes: 10 additions & 7 deletions spec/dummy/app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

class ProjectsController < ApplicationController
before_action :set_project, only: [:show, :edit, :update, :destroy]
before_action :set_project, only: %i[show edit update destroy]

# GET /projects
# GET /projects.json
Expand Down Expand Up @@ -66,19 +68,20 @@ def destroy
end

private

# Use callbacks to share common setup or constraints between actions.
def set_project
@project = Project.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def project_params
params.require(:project).permit(:name, :owner_id, tasks_attributes: [ :name, :description, :done, :id, :_destroy,
sub_tasks_attributes: [ :name, :description, :done, :id, :_destroy ] ],
owner_attributes: [ :name, :role, :description, :id, :_destroy ],
contributors_attributes: [ :name, :role, :description, :id, :_destroy ],
project_tags_attributes: [ :tag_id, :id, :_destroy, tag_attributes:
[ :name, :id, :_destroy ] ])
params.require(:project).permit(:name, :owner_id, tasks_attributes: [:name, :description, :done, :id, :_destroy,
{ sub_tasks_attributes: %i[name description done id _destroy] },],
owner_attributes: %i[name role description id _destroy],
contributors_attributes: %i[name role description id _destroy],
project_tags_attributes: [:tag_id, :id, :_destroy, { tag_attributes:
%i[name id _destroy] },])
end

end
11 changes: 7 additions & 4 deletions spec/dummy/app/controllers/songs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class SongsController < ApplicationController
before_action :set_song, only: [:show, :edit, :update, :destroy]
before_action :create_new_form, only: [:new, :create]
before_action :create_edit_form, only: [:edit, :update]
before_action :set_song, only: %i[show edit update destroy]
before_action :create_new_form, only: %i[new create]
before_action :create_edit_form, only: %i[edit update]

# GET /songs
# GET /songs.json
Expand Down Expand Up @@ -63,6 +65,7 @@ def destroy
end

private

# Use callbacks to share common setup or constraints between actions.
def set_song
@song = Song.find(params[:id])
Expand All @@ -80,6 +83,6 @@ def create_edit_form
# Never trust parameters from the scary internet, only allow the white list through.
def song_params
params.require(:song).permit(:title, :length, artist_attributes:
[:name, producer_attributes: [ :name, :studio ] ] )
[:name, { producer_attributes: %i[name studio] }] )
end
end
12 changes: 7 additions & 5 deletions spec/dummy/app/controllers/surveys_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class SurveysController < ApplicationController
before_action :set_survey, only: [:show, :edit, :update, :destroy]
before_action :create_new_form, only: [:new, :create]
before_action :create_edit_form, only: [:edit, :update]
before_action :set_survey, only: %i[show edit update destroy]
before_action :create_new_form, only: %i[new create]
before_action :create_edit_form, only: %i[edit update]

# GET /surveys
# GET /surveys.json
Expand Down Expand Up @@ -62,6 +64,7 @@ def destroy
end

private

# Use callbacks to share common setup or constraints between actions.
def set_survey
@survey = Survey.find(params[:id])
Expand All @@ -78,7 +81,6 @@ def create_edit_form

# Never trust parameters from the scary internet, only allow the white list through.
def survey_params
params.require(:survey).permit(:name, questions_attributes: [:id, :_destroy, :content,
answers_attributes: [:id, :_destroy, :content]])
params.require(:survey).permit(:name, questions_attributes: [:id, :_destroy, :content, { answers_attributes: %i[id _destroy content] }])
end
end
13 changes: 8 additions & 5 deletions spec/dummy/app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
before_action :create_new_form, only: [:new, :create]
before_action :create_edit_form, only: [:edit, :update]
before_action :set_user, only: %i[show edit update destroy]
before_action :create_new_form, only: %i[new create]
before_action :create_edit_form, only: %i[edit update]

# GET /users
# GET /users.json
Expand Down Expand Up @@ -61,6 +63,7 @@ def destroy
end

private

# Use callbacks to share common setup or constraints between actions.
def set_user
@user = User.find(params[:id])
Expand All @@ -77,7 +80,7 @@ def create_edit_form

# Never trust parameters from the scary internet, only allow the white list through.
def user_params
params.require(:user).permit(:name, :age, :gender, email_attributes: [:id, :address],
profile_attributes: [:id, :twitter_name, :github_name])
params.require(:user).permit(:name, :age, :gender, email_attributes: %i[id address],
profile_attributes: %i[id twitter_name github_name])
end
end
2 changes: 2 additions & 0 deletions spec/dummy/app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class WelcomeController < ApplicationController

def index
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/forms/assignment_form.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AssignmentForm < ActionForm::Base
self.main_model = :assignment

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/forms/conference_form.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ConferenceForm < ActionForm::Base
attribute :name, required: true
attribute :city, required: true
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/forms/project_form.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ProjectForm < ActionForm::Base
attribute :name
attribute :description
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/forms/song_form.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SongForm < ActionForm::Base
attribute :title, required: true
attribute :length, required: true
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/forms/survey_form.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SurveyForm < ActionForm::Base
attribute :name, required: true

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/forms/user_form.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class UserForm < ActionForm::Base
self.main_model = :user

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/answer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Answer < ActiveRecord::Base
belongs_to :question
end
2 changes: 2 additions & 0 deletions spec/dummy/app/models/artist.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Artist < ActiveRecord::Base
has_one :producer, dependent: :destroy
belongs_to :song
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/assignment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Assignment < ActiveRecord::Base
has_many :tasks
validates :name, uniqueness: true
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/conference.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Conference < ActiveRecord::Base
has_one :speaker, dependent: :destroy
validates :name, uniqueness: true
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/email.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Email < ActiveRecord::Base
belongs_to :user

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/person.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Person < ActiveRecord::Base
belongs_to :project
end
2 changes: 2 additions & 0 deletions spec/dummy/app/models/presentation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Presentation < ActiveRecord::Base
belongs_to :speaker
end
2 changes: 2 additions & 0 deletions spec/dummy/app/models/producer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Producer < ActiveRecord::Base
belongs_to :artist

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/profile.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Profile < ActiveRecord::Base
belongs_to :user

Expand Down
6 changes: 4 additions & 2 deletions spec/dummy/app/models/project.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class Project < ActiveRecord::Base
has_many :tasks
has_many :contributors, :class_name => 'Person'
belongs_to :owner, :class_name => 'Person'
has_many :contributors, class_name: 'Person'
belongs_to :owner, class_name: 'Person'

has_many :project_tags
has_many :tags, through: :project_tags
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/project_tag.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ProjectTag < ActiveRecord::Base
belongs_to :project
belongs_to :tag
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/question.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Question < ActiveRecord::Base
belongs_to :survey
has_many :answers, dependent: :destroy
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/song.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Song < ActiveRecord::Base
has_one :artist, dependent: :destroy

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/speaker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Speaker < ActiveRecord::Base
has_many :presentations, dependent: :destroy
belongs_to :conference
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/sub_task.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SubTask < ActiveRecord::Base
belongs_to :task
end
2 changes: 2 additions & 0 deletions spec/dummy/app/models/survey.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Survey < ActiveRecord::Base
has_many :questions, dependent: :destroy

Expand Down
Loading

0 comments on commit 889fbcb

Please sign in to comment.