opf/openproject

View on GitHub

Showing 628 of 1,682 total issues

Avoid deeply nested control flow statements.
Open

    elsif node.kind_of? Arel::Nodes::NodeExpression
      # Generic case, go through left and right
      modify_conditions(node.left) if node.respond_to?(:left) && node.left
      modify_conditions(node.right) if node.respond_to?(:right) && node.right
Severity: Major
Found in app/models/journable/historic_active_record_relation.rb - About 45 mins to fix

    Method new_start_date has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def new_start_date
        current_start_date = work_package.start_date || work_package.due_date
    
        return unless current_start_date && work_package.schedule_automatically?
    
    
    Severity: Minor
    Found in app/services/work_packages/set_attributes_service.rb - About 45 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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def call
        if repository.managed? && repository.manageable?
    
          ##
          # We want to move this functionality in a Delayed Job,
    Severity: Minor
    Found in app/services/scm/create_managed_repository_service.rb - About 45 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_timestamp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def at_timestamp(timestamp)
          unless timestamp.kind_of? Timestamp or timestamp.kind_of? ActiveSupport::TimeWithZone or timestamp.kind_of? DateTime
            raise ArgumentError, "Expected timestamp to be a Timestamp, an ActiveSupport::TimeWithZone, or a DateTime"
          end
    
    
    Severity: Minor
    Found in app/models/journal/timestamps.rb - About 45 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 parse_qvalues has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_qvalues(value)
        tmp = []
        if value
          parts = value.split(/,\s*/)
          parts.each do |part|
    Severity: Minor
    Found in app/services/set_localization_service.rb - About 45 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

    Avoid deeply nested control flow statements.
    Open

            if node.name == "id"
              # ID needs to be pulled from the Journal table
              node.relation = Journal.arel_table
              node.name = "journable_id"
            else
    Severity: Major
    Found in app/models/journable/historic_active_record_relation.rb - About 45 mins to fix

      Method set_templated_description has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_templated_description
          # We only set this if the work package is new
          return unless work_package.new_record?
      
          # And the type was changed
      Severity: Minor
      Found in app/services/work_packages/set_attributes_service.rb - About 45 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

      Function prepareInputFromFactory has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          prepareInputFromFactory: function (input, fieldId, fieldName, fieldOrder, maxTabIndex, fieldEditable) {
      Severity: Minor
      Found in frontend/src/stimulus/controllers/dynamic/backlogs/model.js - About 45 mins to fix

        Method set_default_requested_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def set_default_requested_attributes # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity
                model.requested_login_attribute ||= first_mapping(Saml::Defaults::MAIL_MAPPING)
                model.requested_mail_attribute ||= first_mapping(Saml::Defaults::MAIL_MAPPING)
                model.requested_firstname_attribute ||= first_mapping(Saml::Defaults::FIRSTNAME_MAPPING)
                model.requested_lastname_attribute ||= first_mapping(Saml::Defaults::LASTNAME_MAPPING)
        Severity: Minor
        Found in modules/auth_saml/app/services/saml/providers/set_attributes_service.rb - About 45 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

        Function Reporting has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        window.Reporting = (function($) {
          var onload = function (func) {
            $(document).ready(func);
          };
        
        

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

          def page_param(options = params)
            page = if options[:page]
                     options[:page].to_i
                   elsif options[:offset] && options[:limit]
                     begin
        Severity: Minor
        Found in app/helpers/pagination_helper.rb - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def csv_row(work_package)
              return super unless with_descriptions
        
              super.tap do |row|
                if row.any?
        Severity: Minor
        Found in app/models/work_package/exports/csv.rb - About 45 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 allowed_values_subset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def allowed_values_subset
                grid_configs_of_values
                  .filter_map do |value, config|
                  next unless config && config[:class]
        
        
        Severity: Minor
        Found in modules/grids/app/queries/grids/filters/scope_filter.rb - About 45 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

        Avoid deeply nested control flow statements.
        Open

                  elsif days >= days_per_month
                    months = (days / days_per_month).to_i
                    days = (days % days_per_month).to_i
        Severity: Major
        Found in lib/chronic_duration.rb - About 45 mins to fix

          Function drop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            async drop(el:Element, target:Element, _source:Element|null, _sibling:Element|null) {
              const dropUrl = el.getAttribute('data-drop-url');
          
              let targetPosition = Array.from(target.children).indexOf(el);
              if (target.children.length > 0 && target.children[0].getAttribute('data-empty-list-item') === 'true') {

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

                def to_hours
                  s = dup
                  s.strip!
                  if s =~ %r{^(\d+([.,]\d+)?)h?$}
                    s = $1
          Severity: Minor
          Found in lib/open_project/patches/string.rb - About 45 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 destroy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def destroy
              render_404 and return unless @cost_entry
              render_403 and return unless @cost_entry.editable_by?(User.current)
          
              @cost_entry.destroy
          Severity: Minor
          Found in modules/costs/app/controllers/costlog_controller.rb - About 45 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

          Avoid deeply nested control flow statements.
          Open

                      if days >= days_per_week
                        weeks = (days / days_per_week).to_i
                        days = (days % days_per_week).to_i
                        if weeks >= FULL_WEEKS_PER_MONTH
                          months = (weeks / FULL_WEEKS_PER_MONTH).to_i
          Severity: Major
          Found in lib/chronic_duration.rb - About 45 mins to fix

            Function untouchFieldsWhenWorkIsEdited has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              private untouchFieldsWhenWorkIsEdited() {
                if (this.areBothTouched('remaining_hours', 'done_ratio')) {
                  if (this.isValueEmpty('done_ratio') && this.isValueEmpty('remaining_hours')) {
                    return;
                  }

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

                    def batch_aware_status
                      batch = GoodJob::Job.find_by(id: represented.job_id)&.batch
                      return represented.status unless batch
            
                      unless batch.finished?
            Severity: Minor
            Found in modules/job_status/lib/api/v3/job_status/job_status_representer.rb - About 45 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