Falkor/falkorlib

View on GitHub
lib/falkorlib/common.rb

Summary

Maintainability
D
2 days
Test Coverage
B
88%

File common.rb has 313 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "falkorlib"
require 'open3'
require 'erb' # required for module generation
require 'diffy'
require 'json'
Severity: Minor
Found in lib/falkorlib/common.rb - About 3 hrs to fix

    Method show_diff_and_write has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def show_diff_and_write(content, outfile, options = {
          :no_interaction => false,
          :json_pretty_format => false,
          :no_commit => false
        })
    Severity: Minor
    Found in lib/falkorlib/common.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

    Method list_items has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def list_items(glob_pattern, options = {})
          list  = { 0 => 'Exit' }
          index = 1
          raw_list = { 0 => 'Exit' }
    
    
    Severity: Minor
    Found in lib/falkorlib/common.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

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

        def write_from_erb_template(erbfile, outfile, config = {},
                                    options = {
                                      :no_interaction => false
                                    })
          erbfiles = (erbfile.is_a?(Array)) ? erbfile : [ erbfile ]
    Severity: Minor
    Found in lib/falkorlib/common.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 init_from_template has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def init_from_template(templatedir, rootdir, config = {},
                               options = {
                                 :erb_exclude    => [],
                                 :no_interaction => false
                               })
    Severity: Minor
    Found in lib/falkorlib/common.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 show_diff_and_write has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def show_diff_and_write(content, outfile, options = {
          :no_interaction => false,
          :json_pretty_format => false,
          :no_commit => false
        })
    Severity: Minor
    Found in lib/falkorlib/common.rb - About 1 hr to fix

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

          def normalized_path(dir = Dir.pwd, options = {})
            rootdir = (FalkorLib::Git.init?(dir)) ? FalkorLib::Git.rootdir(dir) : dir
            path = dir
            path = Dir.pwd if dir == '.'
            path = File.join(Dir.pwd, dir) unless (dir =~ /^\// || (dir == '.'))
      Severity: Minor
      Found in lib/falkorlib/common.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 write_from_template has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def write_from_template(src, dstdir, options = {
            :no_interaction => false,
            :no_commit      => false,
            :srcdir         => '',
            :outfile        => ''
      Severity: Minor
      Found in lib/falkorlib/common.rb - About 45 mins 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 init_rvm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def init_rvm(rootdir = Dir.pwd, gemset = '')
            rvm_files = {
              :version => File.join(rootdir, '.ruby-version'),
              :gemset  => File.join(rootdir, '.ruby-gemset')
            }
      Severity: Minor
      Found in lib/falkorlib/common.rb - About 35 mins 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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(cmds)
            exit_status = 0
            puts bold("[Running]\n#{cmds.gsub(/^\s*/, '   ')}")
            $stdout.flush
            #puts cmds.split(/\n */).inspect
      Severity: Minor
      Found in lib/falkorlib/common.rb - About 25 mins 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

      There are no issues that match your filters.

      Category
      Status