holderdeord/hdo-site

View on GitHub
lib/hdo/import/persister.rb

Summary

Maintainability
D
2 days
Test Coverage

File persister.rb has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Hdo
  module Import
    class Persister
      attr_writer :log

Severity: Minor
Found in lib/hdo/import/persister.rb - About 3 hrs to fix

    Class Persister has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Persister
          attr_writer :log
    
          def initialize
            @log = Logger.new(STDOUT)
    Severity: Minor
    Found in lib/hdo/import/persister.rb - About 3 hrs to fix

      Method import_vote has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def import_vote(xvote)
              log_import xvote
              xvote.validate!
      
              vote = Vote.find_by_external_id xvote.external_id
      Severity: Minor
      Found in lib/hdo/import/persister.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 import_vote has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def import_vote(xvote)
              log_import xvote
              xvote.validate!
      
              vote = Vote.find_by_external_id xvote.external_id
      Severity: Major
      Found in lib/hdo/import/persister.rb - About 2 hrs to fix

        Method import_promise has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def import_promise(promise)
                log_import promise
        
                unless promise.valid?
                  @log.error "promise is not valid: #{promise.inspect}"
        Severity: Minor
        Found in lib/hdo/import/persister.rb - About 1 hr to fix

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

                def import_promise(promise)
                  log_import promise
          
                  unless promise.valid?
                    @log.error "promise is not valid: #{promise.inspect}"
          Severity: Minor
          Found in lib/hdo/import/persister.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 import_proposition has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def import_proposition(xprop, vote = nil)
                  log_import xprop
                  xprop.validate!
          
                  return if xprop.external_id == "-1" # https://github.com/holderdeord/hdo-site/issues/138
          Severity: Minor
          Found in lib/hdo/import/persister.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

          Avoid too many return statements within this method.
          Open

                      return
          Severity: Major
          Found in lib/hdo/import/persister.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return
            Severity: Major
            Found in lib/hdo/import/persister.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return
              Severity: Major
              Found in lib/hdo/import/persister.rb - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status