SpontaneousCMS/spontaneous

View on GitHub
lib/spontaneous/loader.rb

Summary

Maintainability
C
1 day
Test Coverage

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

      def safe_load(file, mtime=nil)
        reload = mtime && mtime > mtimes[file]

        logger.debug "Reloading #{relativize_path(file)}" if reload

Severity: Minor
Found in lib/spontaneous/loader.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

File loader.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'pathname'

module Spontaneous
  class Loader
    attr_reader :use_reloader, :load_paths
Severity: Minor
Found in lib/spontaneous/loader.rb - About 2 hrs to fix

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

        def load_classes_with_requirements(klasses)
          klasses.uniq!
    
          while klasses.size > 0
            # Note size to make sure things are loading
    Severity: Minor
    Found in lib/spontaneous/loader.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 safe_load has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def safe_load(file, mtime=nil)
            reload = mtime && mtime > mtimes[file]
    
            logger.debug "Reloading #{relativize_path(file)}" if reload
    
    
    Severity: Minor
    Found in lib/spontaneous/loader.rb - About 1 hr to fix

      Method reload! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def reload!
              changed_files = []
              rotation do |file, mtime|
                # Retrive the last modified time
                new_file = mtimes[file].nil?
      Severity: Minor
      Found in lib/spontaneous/loader.rb - About 1 hr to fix

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

            def load_classes_with_requirements(klasses)
              klasses.uniq!
        
              while klasses.size > 0
                # Note size to make sure things are loading
        Severity: Minor
        Found in lib/spontaneous/loader.rb - About 1 hr to fix

          Method reload! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def reload!
                  rotation do |file, mtime|
                    # Retrive the last modified time
                    new_file = mtimes[file].nil?
                    previous_mtime = mtimes[file] ||= mtime
          Severity: Minor
          Found in lib/spontaneous/loader.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 reload! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def reload!
                  changed_files = []
                  rotation do |file, mtime|
                    # Retrive the last modified time
                    new_file = mtimes[file].nil?
          Severity: Minor
          Found in lib/spontaneous/loader.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 safe_stat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def safe_stat(file)
                  return unless file
                  stat = ::File.stat(file)
                  return file, stat if stat.file?
                rescue Errno::ENOENT, Errno::ENOTDIR
          Severity: Minor
          Found in lib/spontaneous/loader.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

          There are no issues that match your filters.

          Category
          Status