redmine/redmine

View on GitHub

Showing 1,181 of 1,181 total issues

Method pba has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def pba( text_in, element = "" )
        return +'' unless text_in

        style = []
        text = text_in.dup
Severity: Minor
Found in lib/redmine/wiki_formatting/textile/redcloth3.rb - About 5 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_pdf has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

      def to_pdf
        pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
        pdf.SetTitle("#{l(:label_gantt)} #{project}")
        pdf.alias_nb_pages
        pdf.footer_date = format_date(User.current.today)
Severity: Minor
Found in lib/redmine/helpers/gantt.rb - About 5 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

function collapseAllRowGroups(el) {
  var tbody = $(el).parents('tbody').first();
  tbody.children('tr').each(function(index) {
    if ($(this).hasClass('group')) {
      $(this).removeClass('open');
Severity: Major
Found in app/assets/javascripts/application.js and 1 other location - About 5 hrs to fix
app/assets/javascripts/application.js on lines 56..66

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

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

function expandAllRowGroups(el) {
  var tbody = $(el).parents('tbody').first();
  tbody.children('tr').each(function(index) {
    if ($(this).hasClass('group')) {
      $(this).addClass('open');
Severity: Major
Found in app/assets/javascripts/application.js and 1 other location - About 5 hrs to fix
app/assets/javascripts/application.js on lines 44..54

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

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

Method initialize_available_filters has 126 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize_available_filters
    add_available_filter(
      "status_id",
      :type => :list_status, :values => lambda {issue_statuses_values}
    )
Severity: Major
Found in app/models/issue_query.rb - About 5 hrs to fix

    File cvs_adapter.rb has 376 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Method revisions has 125 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def revisions(path, identifier_from, identifier_to, options={})
                revs = Revisions.new
                cmd_args = %w|log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --parents --stdin|
                cmd_args << '--no-renames' if self.class.client_version_above?([2, 9])
                cmd_args << "--reverse" if options[:reverse]
      Severity: Major
      Found in lib/redmine/scm/adapters/git_adapter.rb - About 5 hrs to fix

        Method show_detail has 122 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def show_detail(detail, no_html=false, options={})
            multiple = false
            show_diff = false
            no_details = false
        
        
        Severity: Major
        Found in app/helpers/issues_helper.rb - About 4 hrs to fix

          Method to_image has 121 lines of code (exceeds 25 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: Major
          Found in lib/redmine/helpers/gantt.rb - About 4 hrs to fix

            Method update has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                @page = @wiki.find_or_new_page(params[:id])
                return render_403 unless editable?
            
                was_new_page = @page.new_record?
            Severity: Minor
            Found in app/controllers/wiki_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 calc_col_width has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                    def calc_col_width(issues, query, table_width, pdf)
                      # calculate statistics
                      #  by captions
                      pdf.SetFontStyle('B', 8)
                      margins = pdf.get_margins
            Severity: Minor
            Found in lib/redmine/export/pdf/issues_pdf_helper.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 method_missing has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                    def method_missing(sym, *args, &block)
                      if args.count > 0
                        if args.first.is_a?(Hash)
                          if @struct.last.is_a?(Array)
                            @struct.last << args.first unless block
            Severity: Minor
            Found in lib/redmine/views/builders/structure.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 coordinates has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                  def coordinates(start_date, end_date, progress, zoom=nil)
                    zoom ||= @zoom
                    coords = {}
                    if start_date && end_date && start_date <= self.date_to && end_date >= self.date_from
                      if start_date >= self.date_from
            Severity: Minor
            Found in lib/redmine/helpers/gantt.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

            File preparation.rb has 361 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Redmine
              module Preparation
                def self.prepare
                  ApplicationRecord.include Redmine::Acts::Positioned
                  ApplicationRecord.include Redmine::Acts::Mentionable
            Severity: Minor
            Found in lib/redmine/preparation.rb - About 4 hrs to fix

              Method html_task has 115 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def html_task(params, coords, markers, label, object)
                      output = +''
                      data_options = {}
                      if object
                        data_options[:collapse_expand] = "#{object.class}-#{object.id}".downcase
              Severity: Major
              Found in lib/redmine/helpers/gantt.rb - About 4 hrs to fix

                Method run has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                Open

                  def run(options={})
                    max_items = options[:max_items]
                    max_time = options[:max_time]
                    current = 0
                    imported = 0
                Severity: Minor
                Found in app/models/import.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 requires_redmine has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                Open

                    def requires_redmine(arg)
                      arg = {:version_or_higher => arg} unless arg.is_a?(Hash)
                      arg.assert_valid_keys(:version, :version_or_higher)
                
                      current = Redmine::VERSION.to_a
                Severity: Minor
                Found in lib/redmine/plugin.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 build_object has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def build_object(row, item)
                    issue = Issue.new
                    issue.author = user
                    issue.notify = !!ActiveRecord::Type::Boolean.new.cast(settings['notifications'])
                
                
                Severity: Major
                Found in app/models/issue_import.rb - About 4 hrs to fix

                  Class MailHandler has 35 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class MailHandler < ActionMailer::Base
                    include ActionView::Helpers::SanitizeHelper
                    include Redmine::I18n
                  
                    class UnauthorizedAction < StandardError; end
                  Severity: Minor
                  Found in app/models/mail_handler.rb - About 4 hrs to fix

                    Method to_pdf has 111 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def to_pdf
                            pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
                            pdf.SetTitle("#{l(:label_gantt)} #{project}")
                            pdf.alias_nb_pages
                            pdf.footer_date = format_date(User.current.today)
                    Severity: Major
                    Found in lib/redmine/helpers/gantt.rb - About 4 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language