passcod/caskbot

View on GitHub

Showing 6 of 8 total issues

Method parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def parse(file)
    f = file.split("\n")
    r = {}
    r[:started]  = try_date f.shift.match(/(?:at\s)(.+)/)[1]
    
Severity: Minor
Found in plugins/audit.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 parse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse(file)
    f = file.split("\n")
    r = {}
    r[:started]  = try_date f.shift.match(/(?:at\s)(.+)/)[1]
    
Severity: Minor
Found in plugins/audit.rb - About 1 hr to fix

    Method execute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def execute(m, url)
        digest = Digest::SHA2.new(256)
    
        request = Typhoeus::Request.new url, followlocation: true
        request.on_headers do |res|
    Severity: Minor
    Found in plugins/hash.rb - About 1 hr to fix

      Method execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def execute(m, param)
          param ||= ''
          param.strip!
          if param == ''
            m.reply "Usage: #{@@commands.first}"
      Severity: Minor
      Found in plugins/search.rb - About 55 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 cmd_search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def cmd_search(m, *params)
          return m.reply 'Need to run !audit summary once first' unless @@summary
          return m.reply 'Usage: audit search PATTERN' unless params && params.length > 0
          
          pattern = params.join ' '
      Severity: Minor
      Found in plugins/audit.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 get_casklist has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_casklist(repo)
          unless %r{/} =~ repo
            repo = if %r{^homebrew-} =~ repo
              "caskroom/#{repo}"
            else
      Severity: Minor
      Found in plugins/search.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

      Severity
      Category
      Status
      Source
      Language