app/models/proposal.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Class Proposal has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

class Proposal < ActiveRecord::Base
  include Rails.application.routes.url_helpers
  include Flaggable
  include Taggable
  include Conflictable
Severity: Minor
Found in app/models/proposal.rb - About 3 hrs to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

      def self.search_by_code(terms)
        matched_code = match_code(terms)
        results = where(id: matched_code[1]) if matched_code
        return results if results.present? && results.first.code == terms
      end
    Severity: Minor
    Found in app/models/proposal.rb and 1 other location - About 15 mins to fix
    app/models/legislation/proposal.rb on lines 77..81

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 26.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Line is too long. [106/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

      scope :successful,               -> { where("cached_votes_up >= ?", Proposal.votes_needed_for_success) }
    Severity: Minor
    Found in app/models/proposal.rb by rubocop

    Line is too long. [105/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

      scope :unsuccessful,             -> { where("cached_votes_up < ?", Proposal.votes_needed_for_success) }
    Severity: Minor
    Found in app/models/proposal.rb by rubocop

    Line is too long. [132/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

      scope :archived,                 -> { where("proposals.created_at <= ?", Setting["months_to_archive_proposals"].to_i.months.ago) }
    Severity: Minor
    Found in app/models/proposal.rb by rubocop

    %w-literals should be delimited by [ and ]. (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces)
    Open

        orders = %w{hot_score confidence_score created_at relevance archival_date}
    Severity: Minor
    Found in app/models/proposal.rb by rubocop

    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)

    Line is too long. [128/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

      scope :not_supported_by_user,    ->(user) { where.not(id: user.find_voted_items(votable_type: "Proposal").compact.map(&:id)) }
    Severity: Minor
    Found in app/models/proposal.rb by rubocop

    Line is too long. [120/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

      validates :responsible_name, length: { in: 6..Proposal.responsible_name_max_length }, unless: :skip_user_verification?
    Severity: Minor
    Found in app/models/proposal.rb by rubocop

    %w-literals should be delimited by [ and ]. (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces)
    Open

      RETIRE_OPTIONS = %w(duplicated started unfeasible done other)
    Severity: Minor
    Found in app/models/proposal.rb by rubocop

    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)

    Line is too long. [118/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        orders << "recommendations" if Setting['feature.user.recommendations_on_proposals'] && user&.recommended_proposals
    Severity: Minor
    Found in app/models/proposal.rb by rubocop

    Line is too long. [131/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

      scope :not_archived,             -> { where("proposals.created_at > ?", Setting["months_to_archive_proposals"].to_i.months.ago) }
    Severity: Minor
    Found in app/models/proposal.rb by rubocop

    There are no issues that match your filters.

    Category
    Status