petities/petitions.eu

View on GitHub

Showing 12 of 22 total issues

Class Petition has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

class Petition < ApplicationRecord
  translates :name, :description, :initiators,
             :statement, :request, :slug,
             fallbacks_for_empty_translations: true,
             versioning: :paper_trail
Severity: Minor
Found in app/models/petition.rb - About 3 hrs to fix

    Method create has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create
        @petition = Petition.new(petition_params)
    
        @petition.status = 'concept'
    
    
    Severity: Minor
    Found in app/controllers/petitions_controller.rb - About 1 hr to fix

      Method create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          @petition = Petition.new(petition_params)
      
          @petition.status = 'concept'
      
      
      Severity: Minor
      Found in app/controllers/petitions_controller.rb - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method set_redis_keys has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_redis_keys(task = false)
          redis = Redis.current
      
          # last updates
          if confirmed_at
      Severity: Minor
      Found in app/models/signature.rb - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method included has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.included(dsl)
          dsl.actions :all, except: [:new]
          dsl.filter :petition_id
      
          dsl.filter :person_name
      Severity: Minor
      Found in app/admin_concerns/admin_signatures.rb - About 1 hr to fix

        Method redis_history_chart_json has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def redis_history_chart_json(hist = 10)
            start = Time.now - hist.day
        
            if created_at and start < created_at
              start = created_at
        Severity: Minor
        Found in app/models/petition.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            # try to find old signature first
            email = signature_params[:person_email]
            @signature = Signature.find_by(person_email: email, petition: @petition)
        
        
        Severity: Minor
        Found in app/controllers/signatures_controller.rb - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method set_petition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def set_petition
            find_petition
        
            return if @petition.nil?
        
        
        Severity: Minor
        Found in app/controllers/petitions_controller.rb - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method invalid_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def invalid_attributes
            remove = []
        
            return remove if user.has_role?(:admin)
        
        
        Severity: Minor
        Found in app/policies/petition_policy.rb - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @update = Update.new(update_params)
            authorize @update
        
            respond_to do |format|
        Severity: Minor
        Found in app/controllers/updates_controller.rb - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method confirm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def confirm
            @petition = @signature.petition
            # generate the update signature url
            @url = petition_signature_confirm_submit_path(@petition, @signature.unique_key)
        
        
        Severity: Minor
        Found in app/controllers/signatures_controller.rb - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def update
              if params[:petition_id].present?
                petition = Petition.find(params[:petition_id])
                role = petition.roles.find_or_create_by(name: :admin)
                params[:user][:role_ids].push(role.id)
        Severity: Minor
        Found in app/admin/user.rb - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Severity
        Category
        Status
        Source
        Language