Skip to content

Commit

Permalink
Update Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerpbts committed Nov 24, 2017
1 parent 4ef4d36 commit cc06a14
Show file tree
Hide file tree
Showing 63 changed files with 166 additions and 152 deletions.
12 changes: 10 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ Rails/Date:
Rails/HttpPositionalArguments:
Enabled: false

Rails/SkipsModelValidations:
Enabled: false

Documentation:
Enabled: false

Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*.rb'

Style/Semicolon:
AllowAsExpressionSeparator: true

Expand All @@ -39,10 +46,10 @@ Style/FrozenStringLiteralComment:
Style/StructInheritance:
Enabled: false

Style/AlignParameters:
Layout/AlignParameters:
Enabled: false

Style/ClosingParenthesisIndentation:
Layout/ClosingParenthesisIndentation:
Enabled: false

Metrics/LineLength:
Expand All @@ -65,6 +72,7 @@ Metrics/ClassLength:
Max: 110
Exclude:
- 'app/controllers/projects_controller.rb'
- 'app/controllers/teams_controller.rb'

Metrics/PerceivedComplexity:
Enabled: true
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ group :development do
gem "better_errors"
gem "binding_of_caller"
gem "bullet"
gem 'rubocop', '0.46.0'
gem 'rubocop', '0.49.1'
end

group :development, :test do
Expand Down
16 changes: 9 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ GEM
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
orm_adapter (0.5.0)
parser (2.4.0.0)
ast (~> 2.2)
parallel (1.12.0)
parser (2.4.0.2)
ast (~> 2.3)
pg (0.19.0)
pg_search (1.0.6)
activerecord (>= 3.1)
Expand Down Expand Up @@ -361,7 +362,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
rake (12.0.0)
rake (12.3.0)
ransack (1.8.2)
actionpack (>= 3.0)
activerecord (>= 3.0)
Expand Down Expand Up @@ -409,13 +410,14 @@ GEM
rspec-mocks (~> 3.5.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
rubocop (0.46.0)
parser (>= 2.3.1.1, < 3.0)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
ruby-progressbar (1.9.0)
safe_yaml (1.0.4)
sass (3.4.22)
sass-rails (5.0.6)
Expand Down Expand Up @@ -559,7 +561,7 @@ DEPENDENCIES
rspec-activemodel-mocks
rspec-its
rspec-rails
rubocop (= 0.46.0)
rubocop (= 0.49.1)
sass-rails
shoulda-matchers
sidekiq
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env rake
# 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.

Expand Down
2 changes: 1 addition & 1 deletion app/admin/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
f.actions
end

sidebar 'Project Details', only: [:show, :edit] do
sidebar 'Project Details', only: %i[show edit] do
ul do
li link_to 'Memberships', manage_project_memberships_path(resource)
li link_to 'Ownerships', manage_project_ownerships_path(resource)
Expand Down
2 changes: 1 addition & 1 deletion app/admin/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
f.actions
end

sidebar 'Team Details', only: [:show, :edit] do
sidebar 'Team Details', only: %i[show edit] do
ul do
li link_to 'Ownerships', manage_team_ownerships_path(resource)
li link_to 'Enrollments', manage_team_enrollments_path(resource)
Expand Down
2 changes: 1 addition & 1 deletion app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
f.actions
end

sidebar 'Team Details', only: [:show, :edit] do
sidebar 'Team Details', only: %i[show edit] do
ul do
li link_to 'Memberships', manage_user_memberships_path(resource)
li link_to 'Enrollments', manage_user_enrollments_path(resource)
Expand Down
2 changes: 1 addition & 1 deletion app/api/v1/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def allowed_update_params
params do
optional :state,
type: Symbol,
values: [:done, :in_progress, :backlog, :chilly_bin],
values: %i[done in_progress backlog chilly_bin],
default: :backlog
optional :created_at, type: DateTime
optional :accepted_at, type: DateTime
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Admin::UsersController < ApplicationController
before_action :set_user, only: [:edit, :update, :destroy, :enrollment]
before_action :set_user, only: %i[edit update destroy enrollment]

# GET /admin/users
def index
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def set_current_team_if_single
end

def must_pundit?
!devise_controller? && !(self.class.parent == Manage)
!devise_controller? && self.class.parent != Manage
end

def set_layout_settings
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/integrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class IntegrationsController < ApplicationController
before_action :set_project, :set_integrations
before_action -> { define_sidebar :project_settings }, only: %i(index)
before_action -> { define_sidebar :project_settings }, only: %i[index]

respond_to :html, :json

Expand Down
12 changes: 6 additions & 6 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class ProjectsController < ApplicationController
before_action :set_project, only: %i(show edit update destroy import import_upload
before_action :set_project, only: %i[show edit update destroy import import_upload
reports ownership archive unarchive
change_archived projects_unjoined)
before_action :prepare_session, only: %i(import import_upload)
before_action -> { define_sidebar :project_settings }, only: %i(import edit)
before_action :set_story_flow, only: %i(show)
before_action :fluid_layout, only: %i(show edit import)
change_archived projects_unjoined]
before_action :prepare_session, only: %i[import import_upload]
before_action -> { define_sidebar :project_settings }, only: %i[import edit]
before_action :set_story_flow, only: %i[show]
before_action :fluid_layout, only: %i[show edit import]

# GET /projects
# GET /projects.xml
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class RegistrationsController < Devise::RegistrationsController
prepend_before_action :check_captcha, only: :create, if: -> { show_recaptcha? }
before_action :set_locale, only: :create
before_action :check_registration_enabled, only: [:new, :create]
before_action :check_registration_enabled, only: %i[new create]
before_action :devise_params
after_action :reset_locale, only: :update

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def create
private

def allowed_params
attachinary_params = [
:id, :public_id, :version, :signature, :width, :height, :format, :resource_type,
:created_at, :tags, :bytes, :type, :etag, :url, :secure_url, :original_filename
attachinary_params = %i[
id public_id version signature width height format resource_type
created_at tags bytes type etag url secure_url original_filename
]

params.require(:story).permit(
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class TeamsController < ApplicationController
skip_before_action :check_team_presence, only: [:index, :switch, :new, :create]
skip_before_action :check_team_presence, only: %i[index switch new create]
skip_after_action :verify_policy_scoped, only: :index

def index
Expand Down
2 changes: 1 addition & 1 deletion app/models/activity.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Activity < ActiveRecord::Base
class Activity < ApplicationRecord
include Central::Support::ActivityConcern::Associations
include Central::Support::ActivityConcern::Validations
include Central::Support::ActivityConcern::Callbacks
Expand Down
2 changes: 1 addition & 1 deletion app/models/admin_user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AdminUser < ActiveRecord::Base
class AdminUser < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :authy_authenticatable, :database_authenticatable, :trackable, :validatable
Expand Down
2 changes: 1 addition & 1 deletion app/models/api_token.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApiToken < ActiveRecord::Base
class ApiToken < ApplicationRecord
before_create :generate_token

belongs_to :team
Expand Down
3 changes: 3 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
2 changes: 1 addition & 1 deletion app/models/changeset.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Changeset < ActiveRecord::Base
class Changeset < ApplicationRecord
belongs_to :project
belongs_to :story

Expand Down
2 changes: 1 addition & 1 deletion app/models/enrollment.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Enrollment < ActiveRecord::Base
class Enrollment < ApplicationRecord
belongs_to :team
belongs_to :user
end
2 changes: 1 addition & 1 deletion app/models/integration.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Integration < ActiveRecord::Base
class Integration < ApplicationRecord
include Central::Support::IntegrationConcern
end
2 changes: 1 addition & 1 deletion app/models/membership.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Membership < ActiveRecord::Base
class Membership < ApplicationRecord
belongs_to :project, counter_cache: true
belongs_to :user, counter_cache: true

Expand Down
2 changes: 1 addition & 1 deletion app/models/note.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Note < ActiveRecord::Base
class Note < ApplicationRecord
belongs_to :user
belongs_to :story

Expand Down
2 changes: 1 addition & 1 deletion app/models/ownership.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Ownership < ActiveRecord::Base
class Ownership < ApplicationRecord
belongs_to :team
belongs_to :project
end
8 changes: 4 additions & 4 deletions app/models/project.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Project < ActiveRecord::Base
class Project < ApplicationRecord
include Central::Support::ProjectConcern::Attributes
include Central::Support::ProjectConcern::Associations
include Central::Support::ProjectConcern::Validations
Expand All @@ -10,12 +10,12 @@ class Project < ActiveRecord::Base

MAX_MEMBERS_PER_CARD = 4

JSON_ATTRIBUTES = %w(
JSON_ATTRIBUTES = %w[
id name iteration_length iteration_start_day start_date
default_velocity
).freeze
].freeze

JSON_METHODS = %w(last_changeset_id point_values).freeze
JSON_METHODS = %w[last_changeset_id point_values].freeze

belongs_to :tag_group

Expand Down
14 changes: 7 additions & 7 deletions app/models/story.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Story < ActiveRecord::Base
class Story < ApplicationRecord
include Central::Support::StoryConcern::Attributes
include Central::Support::StoryConcern::Associations
include Central::Support::StoryConcern::Validations
Expand All @@ -23,7 +23,7 @@ def documents_attributes
has_many :tasks, dependent: :destroy

has_attachments :documents,
accept: [:raw, :jpg, :png, :psd, :docx, :xlsx, :doc, :xls, :pdf],
accept: %i[raw jpg png psd docx xlsx doc xls pdf],
maximum: 10

attr_accessor :documents_attributes_was
Expand All @@ -47,14 +47,14 @@ def documents_attributes
against: :labels,
ranked_by: ':trigram'

JSON_ATTRIBUTES = %w(
JSON_ATTRIBUTES = %w[
title release_date accepted_at created_at updated_at description
project_id story_type owned_by_id requested_by_id
owned_by_name owned_by_initials requested_by_name estimate
state position id labels
).freeze
].freeze

JSON_METHODS = %w(errors notes documents tasks).freeze
JSON_METHODS = %w[errors notes documents tasks].freeze

def as_json(_options = {})
super(only: JSON_ATTRIBUTES, methods: JSON_METHODS)
Expand All @@ -68,7 +68,7 @@ def readonly?
# and the state is changing to any state other than 'unstarted' or 'unscheduled'
def fix_project_start_date
return unless state_changed?
return unless project && !project.start_date && !%w(unstarted unscheduled).include?(state)
return unless project && !project.start_date && !%w[unstarted unscheduled].include?(state)
project.start_date = Date.current
end

Expand All @@ -80,7 +80,7 @@ def fix_story_accepted_at
end

def release_date=(val)
return unless val.present?
return if val.blank?

date = Chronic.parse(val)
self[:release_date] = date
Expand Down
2 changes: 1 addition & 1 deletion app/models/tag_group.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class TagGroup < ActiveRecord::Base
class TagGroup < ApplicationRecord
has_many :projects
belongs_to :team

Expand Down
2 changes: 1 addition & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Task < ActiveRecord::Base
class Task < ApplicationRecord
belongs_to :story

validates :name, presence: true
Expand Down
4 changes: 2 additions & 2 deletions app/models/team.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Team < ActiveRecord::Base
class Team < ApplicationRecord
include Central::Support::TeamConcern::Associations
include Central::Support::TeamConcern::Validations
include Central::Support::TeamConcern::Scopes
Expand All @@ -7,7 +7,7 @@ class Team < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged

has_attachment :logo, accept: [:jpg, :png, :gif, :bmp]
has_attachment :logo, accept: %i[jpg png gif bmp]

has_many :api_tokens
has_many :tag_groups
Expand Down
8 changes: 4 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class User < ActiveRecord::Base
class User < ApplicationRecord
include Central::Support::UserConcern::Associations
include Central::Support::UserConcern::Validations
include Central::Support::UserConcern::Callbacks
Expand All @@ -7,9 +7,9 @@ class User < ActiveRecord::Base
gravtastic default: 'identicon'

# FIXME: - DRY up, repeated in Story model
JSON_ATTRIBUTES = %w(id name initials username email finished_tour).freeze
JSON_ATTRIBUTES = %w[id name initials username email finished_tour].freeze

AUTHENTICATION_KEYS = %i(email).freeze
AUTHENTICATION_KEYS = %i[email].freeze

# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
Expand Down Expand Up @@ -60,7 +60,7 @@ def tour_steps
end

def as_json(_options = {})
super(only: JSON_ATTRIBUTES, methods: [:tour_steps, :guest?])
super(only: JSON_ATTRIBUTES, methods: %i[tour_steps guest?])
end

def self.find_first_by_auth_conditions(warden_conditions)
Expand Down
2 changes: 1 addition & 1 deletion app/operations/team_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def create_activity
protected

def after_save
return unless current_user.present?
return if current_user.blank?
model.enrollments.create user: current_user, is_admin: true
end
end
Expand Down

0 comments on commit cc06a14

Please sign in to comment.