gitlabhq/grit

View on GitHub
lib/grit/commit.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Class Commit has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Commit
    extend Lazy

    attr_reader :id
    attr_reader :repo
Severity: Minor
Found in lib/grit/commit.rb - About 2 hrs to fix

    Method list_from_string has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.list_from_string(repo, text)
          text_gpgless = text.gsub(/gpgsig -----BEGIN PGP SIGNATURE-----[\n\r](.*[\n\r])*? -----END PGP SIGNATURE-----[\n\r]/, "")
          lines = text_gpgless.split("\n")
    
          commits = []
    Severity: Minor
    Found in lib/grit/commit.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 initialize has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(repo, id, parents, tree, author, authored_date, committer, committed_date, message)
    Severity: Major
    Found in lib/grit/commit.rb - About 1 hr to fix

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

          def self.list_from_string(repo, text)
            text_gpgless = text.gsub(/gpgsig -----BEGIN PGP SIGNATURE-----[\n\r](.*[\n\r])*? -----END PGP SIGNATURE-----[\n\r]/, "")
            lines = text_gpgless.split("\n")
      
            commits = []
      Severity: Minor
      Found in lib/grit/commit.rb - About 1 hr to fix

        Method diff has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def self.diff(repo, a, b = nil, paths = [], options = {})
        Severity: Minor
        Found in lib/grit/commit.rb - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status