dradis/dradis-ce

View on GitHub

Showing 43 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

    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

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

                    def self.load(yaml)
                      return self.new if self != Object && yaml.nil?
                      return yaml unless yaml.is_a?(String) && yaml =~ /^---/
                  
                      obj = YAML.load(yaml)
                  Severity: Minor
                  Found in app/models/user_preferences.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 set_service has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def set_service(data)
                      data = data.symbolize_keys
                      port     = data.fetch(:port)
                      protocol = data.fetch(:protocol)
                      source   = data.fetch(:source)
                  Severity: Minor
                  Found in app/models/concerns/node_properties.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language