redmine/redmine

View on GitHub

Showing 1,179 of 1,179 total issues

Method parse_redmine_links has 193 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse_redmine_links(text, default_project, obj, attr, only_path, options)
    text.gsub!(LINKS_RE) do |_|
      tag_content = $~[:tag_content]
      leading = $~[:leading]
      esc = $~[:esc]
Severity: Major
Found in app/helpers/application_helper.rb - About 7 hrs to fix

    File issues_pdf_helper.rb has 477 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Redmine
      module Export
        module PDF
          module IssuesPdfHelper
            include ActionView::Helpers::NumberHelper
    Severity: Minor
    Found in lib/redmine/export/pdf/issues_pdf_helper.rb - About 7 hrs to fix

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

      jsToolBar.prototype.elements.table = {
        type: 'button',
        title: 'Table',
        fn: {
          wiki: function() {
      Severity: Major
      Found in app/assets/javascripts/jstoolbar/common_mark.js and 1 other location - About 7 hrs to fix
      app/assets/javascripts/jstoolbar/markdown.js on lines 161..176

      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 180.

      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

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

      jsToolBar.prototype.elements.table = {
        type: 'button',
        title: 'Table',
        fn: {
          wiki: function() {
      Severity: Major
      Found in app/assets/javascripts/jstoolbar/markdown.js and 1 other location - About 7 hrs to fix
      app/assets/javascripts/jstoolbar/common_mark.js on lines 165..180

      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 180.

      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

      Class Mailer has 51 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Mailer < ActionMailer::Base
        layout 'mailer'
        helper :application
        helper :issues
        helper :custom_fields
      Severity: Major
      Found in app/models/mailer.rb - About 7 hrs to fix

        File jstoolbar.js has 465 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * This file is part of DotClear.
         * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All rights reserved.
         * This code is released under the GNU General Public License.
         *
        Severity: Minor
        Found in app/assets/javascripts/jstoolbar/jstoolbar.js - About 7 hrs to fix

          Class Attachment has 50 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Attachment < ApplicationRecord
            include Redmine::SafeAttributes
            belongs_to :container, :polymorphic => true
            belongs_to :author, :class_name => "User"
          
          
          Severity: Minor
          Found in app/models/attachment.rb - About 7 hrs to fix

            Class Gantt has 50 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class Gantt
                  class MaxLinesLimitReached < StandardError
                  end
            
                  include ERB::Util
            Severity: Minor
            Found in lib/redmine/helpers/gantt.rb - About 7 hrs to fix

              Method recalculate_attributes_for has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
              Open

                def recalculate_attributes_for(issue_id)
                  if issue_id && p = Issue.find_by_id(issue_id)
                    if p.priority_derived?
                      # priority = highest priority of open children
                      # priority is left unchanged if all children are closed and there's no default priority defined
              Severity: Minor
              Found in app/models/issue.rb - About 6 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

              Method block_textile_lists has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
              Open

                  def block_textile_lists( text )
                      text.gsub!( LISTS_RE ) do |match|
                          lines = match.split( "\n" )
                          last_line = -1
                          depth = []
              Severity: Minor
              Found in lib/redmine/wiki_formatting/textile/redcloth3.rb - About 6 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

              Method save_attachments has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
              Open

                      def save_attachments(attachments, author=User.current)
                        if attachments.respond_to?(:to_unsafe_hash)
                          attachments = attachments.to_unsafe_hash
                        end
              
              
              Severity: Minor
              Found in lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb - About 6 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

              Method to_image has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
              Open

                    def to_image(format='PNG')
                      date_to = (@date_from >> @months) - 1
                      show_weeks = @zoom > 1
                      show_days = @zoom > 2
                      subject_width = 400
              Severity: Minor
              Found in lib/redmine/helpers/gantt.rb - About 6 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 queries_helper.rb has 451 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'redmine/export/csv'
              
              module QueriesHelper
                include ApplicationHelper
              
              
              Severity: Minor
              Found in app/helpers/queries_helper.rb - About 6 hrs to fix

                Method rip_offtags has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                Open

                    def rip_offtags( text, escape_aftertag=true, escape_line=true )
                        if text =~ /<.*>/
                            ## strip and encode <pre> content
                            codepre, used_offtags = 0, {}
                            text.gsub!( OFFTAG_MATCH ) do |line|
                Severity: Minor
                Found in lib/redmine/wiki_formatting/textile/redcloth3.rb - About 6 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

                Class RedCloth3 has 48 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class RedCloth3 < String
                    include Redmine::Helpers::URL
                
                    VERSION = '3.0.4'
                    DEFAULT_RULES = [:textile, :markdown]
                Severity: Minor
                Found in lib/redmine/wiki_formatting/textile/redcloth3.rb - About 6 hrs to fix

                  File attachment.rb has 441 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require "digest"
                  require "fileutils"
                  require "zip"
                  
                  class Attachment < ApplicationRecord
                  Severity: Minor
                  Found in app/models/attachment.rb - About 6 hrs to fix

                    Method validate_query_filters has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def validate_query_filters
                        filters.each_key do |field|
                          if values_for(field)
                            case type_for(field)
                            when :integer
                    Severity: Minor
                    Found in app/models/query.rb - About 6 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

                    Method build_relations has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def build_relations(row, item, issue)
                        IssueRelation::TYPES.each_key do |type|
                          has_delay = [IssueRelation::TYPE_PRECEDES, IssueRelation::TYPE_FOLLOWS].include?(type)
                    
                          if decls = relation_values(row, "relation_#{type}")
                    Severity: Minor
                    Found in app/models/issue_import.rb - About 6 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

                    Method copy_issues has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def copy_issues(project)
                        # Stores the source issue id as a key and the copied issues as the
                        # value.  Used to map the two together for issue relations.
                        issues_map = {}
                    
                    
                    Severity: Minor
                    Found in app/models/project.rb - About 6 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

                    Method index has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def index
                        @days = Setting.activity_days_default.to_i
                    
                        if params[:from]
                          begin; @date_to = params[:from].to_date + 1; rescue; end
                    Severity: Minor
                    Found in app/controllers/activities_controller.rb - About 6 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

                    Severity
                    Category
                    Status
                    Source
                    Language