redmine/redmine

View on GitHub

Showing 1,181 of 1,181 total issues

Method sql_for_relations has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  def sql_for_relations(field, operator, value, options={})
    relation_options = IssueRelation::TYPES[field]
    return relation_options unless relation_options

    relation_type = field
Severity: Minor
Found in app/models/issue_query.rb - About 4 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 allowed_to? has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  def allowed_to?(action, context, options={}, &block)
    if context && context.is_a?(Project)
      return false unless context.allows_to?(action)
      # Admin users are authorized for anything else
      return true if admin?
Severity: Minor
Found in app/models/user.rb - About 4 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 blocks has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def blocks( text, deep_code = false )
        text.replace( text.split( BLOCKS_GROUP_RE ).collect do |blk|
            plain = blk !~ /\A[#*> ]/

            # skip blocks that are complex HTML
Severity: Minor
Found in lib/redmine/wiki_formatting/textile/redcloth3.rb - About 4 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 find_current_user has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  def find_current_user
    user = nil
    unless api_request?
      if session[:user_id]
        # existing session
Severity: Minor
Found in app/controllers/application_controller.rb - About 4 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 CustomField has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class CustomField < ApplicationRecord
  include Redmine::SafeAttributes
  include Redmine::SubclassFactory

  has_many :enumerations,
Severity: Minor
Found in app/models/custom_field.rb - About 4 hrs to fix

    File repositories_controller.rb has 344 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'digest/sha1'
    require 'redmine/scm/adapters'
    
    class ChangesetNotFound < StandardError; end
    class InvalidRevisionParam < StandardError; end
    Severity: Minor
    Found in app/controllers/repositories_controller.rb - About 4 hrs to fix

      Method journalize_changes has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        def journalize_changes
          # attributes changes
          if @attributes_before_change
            attrs = (journalized.journalized_attribute_names + @attributes_before_change.keys).uniq
            attrs.each do |attribute|
      Severity: Minor
      Found in app/models/journal.rb - About 4 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 bulk_edit has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        def bulk_edit
          @issues.sort!
          @copy = params[:copy].present?
          @notes = params[:notes]
      
      
      Severity: Minor
      Found in app/controllers/issues_controller.rb - About 4 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 clean_html has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          def clean_html( text, tags = BASIC_TAGS )
              text.gsub!( "<![CDATA[", '' )
              text.gsub!( /<(\/*)(\w+)([^>]*)>/ ) do
                  raw = $~
                  tag = raw[2].downcase
      Severity: Minor
      Found in lib/redmine/wiki_formatting/textile/redcloth3.rb - About 4 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 revisions has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block)
                path_with_project_utf8   = path_with_proj(path)
                path_with_project_locale = scm_iconv(@path_encoding, 'UTF-8', path_with_project_utf8)
                logger.debug "<cvs> revisions path:" +
                    "'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}"
      Severity: Major
      Found in lib/redmine/scm/adapters/cvs_adapter.rb - About 4 hrs to fix

        File abstract_adapter.rb has 341 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'cgi'
        require 'redmine/scm/adapters'
        
        module Redmine
          module Scm
        Severity: Minor
        Found in lib/redmine/scm/adapters/abstract_adapter.rb - About 4 hrs to fix

          File account_controller.rb has 338 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class AccountController < ApplicationController
            helper :custom_fields
            include CustomFieldsHelper
          
            self.main_menu = false
          Severity: Minor
          Found in app/controllers/account_controller.rb - About 4 hrs to fix

            Class RepositoriesController has 32 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class RepositoriesController < ApplicationController
              menu_item :repository
              menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers]
              default_search_scope :changesets
            
            
            Severity: Minor
            Found in app/controllers/repositories_controller.rb - About 4 hrs to fix

              Method scan_comment_for_issue_ids has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                def scan_comment_for_issue_ids
                  return if comments.blank?
              
                  # keywords used to reference issues
                  ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip)
              Severity: Minor
              Found in app/models/changeset.rb - About 3 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 render_project_nested_lists has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                def render_project_nested_lists(projects, &block)
                  s = +''
                  if projects.any?
                    ancestors = []
                    original_project = @project
              Severity: Minor
              Found in app/helpers/application_helper.rb - About 3 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_new_issue_from_params has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                def build_new_issue_from_params
                  @issue = Issue.new
                  if params[:copy_from]
                    begin
                      @issue.init_journal(User.current)
              Severity: Minor
              Found in app/controllers/issues_controller.rb - About 3 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

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

                module WikiFormatting
                  module Markdown
                    class HtmlParser < Redmine::WikiFormatting::HtmlParser
              
                      self.tags = tags.merge(
              Severity: Major
              Found in lib/redmine/wiki_formatting/markdown/html_parser.rb and 1 other location - About 3 hrs to fix
              lib/redmine/wiki_formatting/textile/html_parser.rb on lines 21..49

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

              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

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

                module WikiFormatting
                  module Textile
                    class HtmlParser < Redmine::WikiFormatting::HtmlParser
              
                      self.tags = tags.merge(
              Severity: Major
              Found in lib/redmine/wiki_formatting/textile/html_parser.rb and 1 other location - About 3 hrs to fix
              lib/redmine/wiki_formatting/markdown/html_parser.rb on lines 21..49

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

              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

              Function buildFilterRow has 96 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function buildFilterRow(field, operator, values) {
                var fieldId = field.replace('.', '_');
                var filterTable = $("#filters-table");
                var filterOptions = availableFilters[field];
                if (!filterOptions) return;
              Severity: Major
              Found in app/assets/javascripts/application.js - About 3 hrs to fix

                Class Journal has 31 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Journal < ApplicationRecord
                  include Redmine::SafeAttributes
                
                  belongs_to :journalized, :polymorphic => true
                  # added as a quick fix to allow eager loading of the polymorphic association
                Severity: Minor
                Found in app/models/journal.rb - About 3 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language