opf/openproject

View on GitHub

Showing 620 of 1,668 total issues

Avoid too many return statements within this function.
Open

    return false;

    Avoid too many return statements within this function.
    Open

      return false;
    Severity: Major
    Found in frontend/src/app/core/setup/globals/global-listeners/link-hijacking.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return false;
      Severity: Major
      Found in frontend/src/app/spot/components/form-field/form-field.component.ts - About 30 mins to fix

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

            def user_allowed_to_change_parent
              return if model.parent_id.nil? || model.parent.nil?
              return unless model.parent_id_changed?
        
              unless model.parent.visible?
        Severity: Minor
        Found in app/contracts/work_packages/update_contract.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 create_missing! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_missing!(entries)
              existing = User.where(login: entries.keys).pluck(:login, :id).to_h
        
              entries.each do |login, data|
                next if existing[login]

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

          def value(html, values)
            html = html ? "_html" : ""
        
            new = visible(values.last)
            old = visible(values.first)

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

            def highlighted_attributes
              return [] unless EnterpriseToken.allows_to?(:conditional_highlighting)
        
              val = super
        
        
        Severity: Minor
        Found in app/models/query/highlighting.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 scope has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def scope
            if users_only
              project.nil? ? User : project.users.user
            else
              project.nil? ? Principal : project.principals.human
        Severity: Minor
        Found in app/services/user_search_service.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 user_allowed_to_manage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def user_allowed_to_manage
            changed_settings = model.version_settings.select(&:changed?)
        
            super unless !model.changed? && changed_settings.any?
        
        

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

            def allowed_in_single_project?(permissions, project)
              return false if project.nil?
              return false unless project.active? || project.being_archived?
        
              permissions_filtered_for_project = permissions_by_enabled_project_modules(project, permissions)
        Severity: Minor
        Found in app/services/authorization/user_permissible_service.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 start_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def start_date(due_date, duration)
                assert_strictly_positive_duration(duration)
                return nil unless due_date && duration
        
                start_date = latest_working_day(due_date)
        Severity: Minor
        Found in app/services/work_packages/shared/working_days.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 pluck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def pluck(*column_names)
            column_names.map! do |column_name|
              case column_name
              when :id, "id"
                "journals.journable_id"
        Severity: Minor
        Found in app/models/journable/historic_active_record_relation.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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            scope = @project ? @project.news : News.all
        
            @newss = scope.merge(News.latest_for(current_user, count: 0))
                          .page(page_param)
        Severity: Minor
        Found in app/controllers/news_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 csv_row has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def csv_row(work_package)
              super.tap do |row|
                if row.any?
                  row << if work_package.description
                           work_package.description.squish
        Severity: Minor
        Found in app/models/work_package/exports/csv.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 project_or_global_meetings_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def project_or_global_meetings_path(filters: nil, sort: nil)
            return polymorphic_path([@project, :meetings]) if filters.blank? && sort.blank?
        
            query_params = {}.tap do |query|
              query[:filters] = filters.to_json if filters.present?
        Severity: Minor
        Found in modules/meeting/app/helpers/meetings_helper.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_project_dependent_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_project_dependent_attributes
            return unless work_package.project_id_changed? && work_package.project_id
        
            model.change_by_system do
              set_version_to_nil
        Severity: Minor
        Found in app/services/work_packages/set_attributes_service.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 at_least_one_admin_is_active has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def at_least_one_admin_is_active
              return unless
                (model.admin_changed? && !model.admin?) ||
                (model.admin? && model.status_changed? && model.locked?)
        
        
        Severity: Minor
        Found in app/contracts/users/update_contract.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 due_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def due_date(start_date, duration)
                assert_strictly_positive_duration(duration)
                return nil unless start_date && duration
        
                due_date = soonest_working_day(start_date)
        Severity: Minor
        Found in app/services/work_packages/shared/working_days.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 query_manageable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def query_manageable
              return if model.query.blank?
        
              if query_visible?
                errors.add(:base, :error_unauthorized) unless query_permissions?
        Severity: Minor
        Found in app/contracts/views/base_contract.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 user_allowed_to_change has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def user_allowed_to_change
              # Check user self-saving their own queries
              # or user saving public queries
              if model.public_was
                user_allowed_to_change_public
        Severity: Minor
        Found in app/contracts/queries/update_contract.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