sgmap/boussole

View on GitHub

Showing 276 of 276 total issues

Models should subclass ApplicationRecord.
Open

class CapEmploi < ActiveRecord::Base
Severity: Minor
Found in app/models/cap_emploi.rb by rubocop

This cop checks that models subclass ApplicationRecord with Rails 5.0.

Example:

# good class Rails5Model < ApplicationRecord # ... end

# bad class Rails4Model < ActiveRecord::Base # ... end

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8
Severity: Minor
Found in app/models/handicap.rb by rubocop

Models should subclass ApplicationRecord.
Open

class Handicap < ActiveRecord::Base
Severity: Minor
Found in app/models/handicap.rb by rubocop

This cop checks that models subclass ApplicationRecord with Rails 5.0.

Example:

# good class Rails5Model < ApplicationRecord # ... end

# bad class Rails4Model < ActiveRecord::Base # ... end

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8
Severity: Minor
Found in app/models/social_right.rb by rubocop

Specify a :dependent option.
Open

  has_many :service_offerings,
Severity: Minor
Found in app/models/social_right.rb by rubocop

This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

Example:

# bad
class User < ActiveRecord::Base
  has_many :comments
  has_one :avatar
end

# good
class User < ActiveRecord::Base
  has_many :comments, dependent: :restrict_with_exception
  has_one :avatar, dependent: :destroy
  has_many :patients, through: :appointments
end

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8
Severity: Minor
Found in app/models/working_status.rb by rubocop

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8
Severity: Minor
Found in app/models/mission_locale.rb by rubocop

Specify an :inverse_of option.
Open

  has_many :exercise_scopes,
Severity: Minor
Found in app/models/measure.rb by rubocop

This cop looks for has(one|many) and belongsto associations where ActiveRecord can't automatically determine the inverse association because of a scope or the options used. This can result in unnecessary queries in some circumstances. :inverse_of must be manually specified for associations to work in both ways, or set to false to opt-out.

Example:

# good
class Blog < ApplicationRecord
  has_many :posts
end

class Post < ApplicationRecord
  belongs_to :blog
end

Example:

# bad
class Blog < ApplicationRecord
  has_many :posts, -> { order(published_at: :desc) }
end

class Post < ApplicationRecord
  belongs_to :blog
end

# good
class Blog < ApplicationRecord
  has_many(:posts,
    -> { order(published_at: :desc) },
    inverse_of: :blog
  )
end

class Post < ApplicationRecord
  belongs_to :blog
end

# good
class Blog < ApplicationRecord
  with_options inverse_of: :blog do
    has_many :posts, -> { order(published_at: :desc) }
  end
end

class Post < ApplicationRecord
  belongs_to :blog
end

Example:

# bad
class Picture < ApplicationRecord
  belongs_to :imageable, polymorphic: true
end

class Employee < ApplicationRecord
  has_many :pictures, as: :imageable
end

class Product < ApplicationRecord
  has_many :pictures, as: :imageable
end

# good
class Picture < ApplicationRecord
  belongs_to :imageable, polymorphic: true
end

class Employee < ApplicationRecord
  has_many :pictures, as: :imageable, inverse_of: :imageable
end

class Product < ApplicationRecord
  has_many :pictures, as: :imageable, inverse_of: :imageable
end

Example:

# bad
# However, RuboCop can not detect this pattern...
class Physician < ApplicationRecord
  has_many :appointments
  has_many :patients, through: :appointments
end

class Appointment < ApplicationRecord
  belongs_to :physician
  belongs_to :patient
end

class Patient < ApplicationRecord
  has_many :appointments
  has_many :physicians, through: :appointments
end

# good
class Physician < ApplicationRecord
  has_many :appointments
  has_many :patients, through: :appointments
end

class Appointment < ApplicationRecord
  belongs_to :physician, inverse_of: :appointments
  belongs_to :patient, inverse_of: :appointments
end

class Patient < ApplicationRecord
  has_many :appointments
  has_many :physicians, through: :appointments
end

@see http://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

Put empty method definitions on a single line.
Open

    def edit
    end

This cop checks for the formatting of empty method definitions. By default it enforces empty method definitions to go on a single line (compact style), but it can be configured to enforce the end to go on its own line (expanded style).

Note: A method definition is not considered empty if it contains comments.

Example: EnforcedStyle: compact (default)

# bad
def foo(bar)
end

def self.foo(bar)
end

# good
def foo(bar); end

def foo(bar)
  # baz
end

def self.foo(bar); end

Example: EnforcedStyle: expanded

# bad
def foo(bar); end

def self.foo(bar); end

# good
def foo(bar)
end

def self.foo(bar)
end

Put empty method definitions on a single line.
Open

    def edit
    end

This cop checks for the formatting of empty method definitions. By default it enforces empty method definitions to go on a single line (compact style), but it can be configured to enforce the end to go on its own line (expanded style).

Note: A method definition is not considered empty if it contains comments.

Example: EnforcedStyle: compact (default)

# bad
def foo(bar)
end

def self.foo(bar)
end

# good
def foo(bar); end

def foo(bar)
  # baz
end

def self.foo(bar); end

Example: EnforcedStyle: expanded

# bad
def foo(bar); end

def self.foo(bar); end

# good
def foo(bar)
end

def self.foo(bar)
end

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8
Severity: Minor
Found in app/services/event_tracker.rb by rubocop

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8

%i-literals should be delimited by [ and ].
Open

              housing_age_attributes: %i(id minimum maximum),

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8
Severity: Minor
Found in app/mailers/mailer.rb by rubocop

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8
Severity: Minor
Found in Rakefile by rubocop

Unnecessary utf-8 encoding comment.
Open

# encoding: utf-8
Severity: Minor
Found in lib/tasks/linters.rake by rubocop
Severity
Category
Status
Source
Language