Showing 106 of 4,066 total issues

File budget_investments_spec.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

feature 'Tags' do

  let(:author)  { create(:user, :level_two, username: 'Isabel') }
Severity: Minor
Found in spec/features/tags/budget_investments_spec.rb - About 2 hrs to fix

    File proposal_notifications_spec.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rails_helper'
    
    feature 'Proposal Notifications' do
    
      xscenario "Send a notification" do
    Severity: Minor
    Found in spec/features/proposal_notifications_spec.rb - About 2 hrs to fix

      File proposal_notifications_spec.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'rails_helper'
      
      feature 'Proposal Notifications' do
      
        xscenario "Send a notification" do
      Severity: Minor
      Found in spec/custom/features/proposal_notifications_spec.rb - About 2 hrs to fix

        Class ProposalsController has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class ProposalsController < ApplicationController
          include FeatureFlags
          include CommentableActions
          include FlagActions
        
        
        Severity: Minor
        Found in app/controllers/proposals_controller.rb - About 2 hrs to fix

          File activity_spec.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'rails_helper'
          
          feature 'Admin activity' do
          
            background do
          Severity: Minor
          Found in spec/features/admin/activity_spec.rb - About 2 hrs to fix

            Class Debate has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

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

              Function editorConfig has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              CKEDITOR.editorConfig = function( config )
              {
                config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
                config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
                config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
              Severity: Minor
              Found in app/assets/javascripts/ckeditor/config.js - About 2 hrs 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

              File draft_versions_spec.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'rails_helper'
              
              feature 'Legislation Draft Versions' do
                let(:user) { create(:user) }
                let(:administrator) do
              Severity: Minor
              Found in spec/features/legislation/draft_versions_spec.rb - About 2 hrs to fix

                Method initialize has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def initialize(user)
                      merge Abilities::Common.new(user)
                
                      can [:search, :index], ::User
                
                
                Severity: Minor
                Found in app/models/custom/abilities/animator.rb - About 1 hr to fix

                  Method initialize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def initialize(user)
                        merge Abilities::Common.new(user)
                  
                        can :read, Organization
                        can(:verify, Organization){ |o| !o.verified? }
                  Severity: Minor
                  Found in app/models/abilities/moderation.rb - About 1 hr to fix

                    Function initialize_modules has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var initialize_modules = function() {
                      App.Comments.initialize();
                      App.Users.initialize();
                      App.Votes.initialize();
                      App.AllowParticipation.initialize();
                    Severity: Minor
                    Found in app/assets/javascripts/application.js - About 1 hr to fix

                      Method import has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def import(sp)
                          budget = Budget.last || Budget.create!(name: Date.current.year.to_s, currency_symbol: "€")
                      
                          group = nil
                          heading = nil
                      Severity: Minor
                      Found in lib/migrate_spending_proposals_to_investments.rb - About 1 hr to fix

                        Method calculate_user_status has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def calculate_user_status(authorable = nil)
                            user_status = "user"
                        
                            if user_signed_in?
                              user_status += ":signed"
                        Severity: Minor
                        Found in app/helpers/cache_keys_helper.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 register_vote has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def register_vote(user, vote_value)
                            if votable_by?(user)
                              previous_vote_value = ::CastToBoolean.call(user.voted_as_when_voted_for(self))
                              current_vote_value = ::CastToBoolean.call(vote_value)
                              if previous_vote_value == current_vote_value
                        Severity: Minor
                        Found in app/models/custom/debate.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 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def create
                            if !@process.allegations_phase.open? || @draft_version.final_version?
                              render(json: {}, status: :not_found) && return
                            end
                        
                        
                        Severity: Minor
                        Found in app/controllers/legislation/annotations_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 has_orders has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def has_orders(valid_orders, *args)
                              before_action(*args) do |c|
                                @valid_orders = valid_orders.respond_to?(:call) ? valid_orders.call(c) : valid_orders.dup
                                @valid_orders.delete('relevance') if params[:search].blank?
                                @current_order = @valid_orders.include?(params[:order]) ? params[:order] : @valid_orders.first
                        Severity: Minor
                        Found in app/controllers/concerns/has_orders.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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def update
                            self.resource = resource_class.find_by(confirmation_token: params[:confirmation_token])
                        
                            if resource.encrypted_password.blank?
                              resource.assign_attributes(resource_params)
                        Severity: Minor
                        Found in app/controllers/users/confirmations_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 scoped_filter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def self.scoped_filter(params, current_filter)
                              budget  = Budget.find_by(slug: params[:budget_id]) || Budget.find_by(id: params[:budget_id])
                              results = Investment.by_budget(budget)
                        
                              results = results.where("cached_votes_up + physical_votes >= ?",
                        Severity: Minor
                        Found in app/models/budget/investment.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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def update
                            content_params.each do |content|
                              values = content[:values].slice(*translation_params)
                        
                              unless values.empty?

                        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 sign_in_with has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def sign_in_with(feature, provider)
                              raise ActionController::RoutingError.new('Not Found') unless Setting["feature.#{feature}"]
                        
                              auth = env["omniauth.auth"]
                        
                        
                        Severity: Minor
                        Found in app/controllers/custom/users/omniauth_callbacks_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

                        Severity
                        Category
                        Status
                        Source
                        Language