webdestroya/lita-github-commits

View on GitHub

Showing 4 of 4 total issues

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

      def format_message(payload)
        commits = payload['commits']
        branch = branch_from_ref(payload['ref'])
        if commits.size > 0
          author = committer_and_author(commits.first)
Severity: Minor
Found in lib/lita/handlers/github_commits.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 check_for_commit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def check_for_commit(response)
        sha = abbrev_sha(response.match_data[1])
        if sha.nil? || sha.empty?
          #this shouldn't match regex
          response.reply("[GitHub] I need at least #{SHA_ABBREV_LENGTH} characters of the commit SHA") if response.message.command?
Severity: Minor
Found in lib/lita/handlers/github_commits.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 receive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def receive(request, response)
        event_type = request.env['HTTP_X_GITHUB_EVENT'] || 'unknown'
        Lita.logger.debug("Received GitHub #{event_type} event") rescue ""
        if !valid_signature(request)
          response.status = 404
Severity: Minor
Found in lib/lita/handlers/github_commits.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

Method valid_signature has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def valid_signature(request)
        #not actually validating yet, just checking for presence of signature
        #should look something like
        #payload_body = request.body.read
        #signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), config.github_webhook_secret, payload_body)
Severity: Minor
Found in lib/lita/handlers/github_commits.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