dradis/dradis-ce

View on GitHub

Showing 55 of 55 total issues

Method find has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

  def self.find(*args)
    options = args.extract_options!
    dir = Dir.new(pwd)

    # makes the find request and stores it to resources
Severity: Minor
Found in app/models/attachment.rb - About 7 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 configure has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def configure
      # init the config files
      init_all = false
      Dir['config/*.template'].each do |template|
        config = File.join('config', File.basename(template, '.template'))
Severity: Minor
Found in lib/tasks/thor/setup.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

Class Methodology has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class Methodology
  include ActiveModel::Conversion
  include ActiveModel::Dirty
  include ActiveModel::Validations
  extend ActiveModel::Naming
Severity: Minor
Found in app/models/methodology.rb - About 3 hrs to fix

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

        open: function(animationClass) {
          this.$navbar.css('left', '207px');
          this.$sidebar
            .removeClass('sidebar-collapsed no-animation animate')
            .addClass('sidebar-expanded ' + animationClass)
    Severity: Major
    Found in app/assets/javascripts/tylium/modules/sidebar.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/tylium/modules/sidebar.js on lines 27..35

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

    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

        close: function(animationClass) {
          this.$navbar.css('left', '0px');
          this.$sidebar
            .removeClass('sidebar-expanded no-animation animate')
            .addClass('sidebar-collapsed ' + animationClass)
    Severity: Major
    Found in app/assets/javascripts/tylium/modules/sidebar.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/tylium/modules/sidebar.js on lines 39..47

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

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

      def location
        result = ''
        # Get node if object is a Note or an Evidence.
        if ['Note','Evidence'].include?(type)
          if type == 'Evidence'
    Severity: Minor
    Found in app/presenters/recoverable_revision_presenter.rb - About 2 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

    Function behaviors has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      behaviors() {
        var that = this;
    
        this.$target.on('click change keyup select', function() {
          // enabling/disabling specific toolbar functions for textareas on selection
    Severity: Major
    Found in app/assets/javascripts/shared/editor_toolbar.js - About 2 hrs to fix

      Function restoreData has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        restoreData() {
          var that = this;
          var data = JSON.parse(localStorage.getItem(this.key));
      
          if (data !== null) {
      Severity: Minor
      Found in app/assets/javascripts/tylium/modules/auto_save/local.js - About 2 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 has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.find(*args)
          options = args.extract_options!
          dir = Dir.new(pwd)
      
          # makes the find request and stores it to resources
      Severity: Minor
      Found in app/models/attachment.rb - About 1 hr to fix

        Method save has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def save
            if File.exists?(fullpath) && File.file?(fullpath)
              self.close
            else
              raise "Node with ID=#{@node_id} does not exist" unless @node_id && Node.exists?(@node_id)
        Severity: Minor
        Found in app/models/attachment.rb - About 1 hr 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 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            count = 0
            if params[:sources]
        
              # create new issue if existing issue not given
        Severity: Minor
        Found in app/controllers/issues/merge_controller.rb - About 1 hr 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_package has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def create_package(target)
          puts "\nCreating package #{ target }..."
        
          package_dir = "#{PACKAGE_NAME}-#{VERSION}-#{target}"
        
        
        Severity: Minor
        Found in packaging/rake_rules.rb - About 1 hr to fix

          Method create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def create
              if params[:use_template] == 'yes'
                begin
                  # check template param
                  unless Methodology.all.map(&:filename).include?(params[:template])
          Severity: Minor
          Found in app/controllers/boards_controller.rb - About 1 hr 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_multiple has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def create_multiple
              # validate Issue
              issue = current_project.issues.find(evidence_params[:issue_id])
          
              if params[:evidence][:node_ids]
          Severity: Minor
          Found in app/controllers/evidence_controller.rb - About 1 hr to fix

            Method value has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def value
                return 'n/a' unless property_value.present?
            
                # We want to always render :services as table, but some times there is a
                # single port. We just turn it into a single-element array
            Severity: Minor
            Found in app/presenters/property_presenter.rb - About 1 hr 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 issues_from_import_records has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def issues_from_import_records(records)
                issues = []
                records.each_with_index do |record,index|
                  issue = Issue.new do |issue|
                    issue.id = index
            Severity: Minor
            Found in app/helpers/issues_helper.rb - About 1 hr 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 has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def create
                if params[:use_template] == 'yes'
                  begin
                    # check template param
                    unless Methodology.all.map(&:filename).include?(params[:template])
            Severity: Minor
            Found in app/controllers/boards_controller.rb - About 1 hr to fix

              Function restoreData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                restoreData() {
                  var that = this;
                  var data = JSON.parse(localStorage.getItem(this.key));
              
                  if (data !== null) {
              Severity: Minor
              Found in app/assets/javascripts/tylium/modules/auto_save/local.js - About 1 hr to fix

                Function textareaElements has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  textareaElements(include) {
                    var str = '';
                
                    if (include.includes('field')) str += '<div class="editor-btn" data-btn="field" aria-label="add new field">\
                      <i class="fa fa-plus"></i>\
                Severity: Minor
                Found in app/assets/javascripts/shared/editor_toolbar.js - About 1 hr to fix

                  Method move has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def move(item, new_position = {})
                        item.class.transaction do
                          previous_item = item.send("previous_#{item.class.name.downcase}")
                          next_item = item.send("next_#{item.class.name.downcase}")
                  
                  
                  Severity: Minor
                  Found in app/models/concerns/acts_as_linked_list.rb - About 1 hr 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