louismullie/treat

View on GitHub
lib/treat/entities/entity/buildable.rb

Summary

Maintainability
D
1 day
Test Coverage

File buildable.rb has 317 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Treat::Entities::Entity::Buildable

  require 'schiphol'
  require 'fileutils'
  require 'uri'
Severity: Minor
Found in lib/treat/entities/entity/buildable.rb - About 3 hrs to fix

    Method build has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def build(*args)
    
        # This probably needs some doc.
        if args.size == 0
          file_or_value = ''
    Severity: Minor
    Found in lib/treat/entities/entity/buildable.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 from_folder has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def from_folder(folder)
    
        return if Reserved.include?(folder)
    
        unless FileTest.directory?(folder)
    Severity: Minor
    Found in lib/treat/entities/entity/buildable.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 build has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def build(*args)
    
        # This probably needs some doc.
        if args.size == 0
          file_or_value = ''
    Severity: Minor
    Found in lib/treat/entities/entity/buildable.rb - About 1 hr to fix

      Method anything_from_string has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def anything_from_string(string)
          case self.mn.downcase.intern
          when :document
            folder = Treat.paths.files
            if folder[-1] == '/'
      Severity: Minor
      Found in lib/treat/entities/entity/buildable.rb - About 1 hr to fix

        Method from_folder has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def from_folder(folder)
        
            return if Reserved.include?(folder)
        
            unless FileTest.directory?(folder)
        Severity: Minor
        Found in lib/treat/entities/entity/buildable.rb - About 1 hr to fix

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

            def token_from_string(string)
          
              check_encoding(string)
              if Enclitics.include?(string.downcase)
                Treat::Entities::Enclitic.new(string)
          Severity: Minor
          Found in lib/treat/entities/entity/buildable.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 anything_from_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def anything_from_string(string)
              case self.mn.downcase.intern
              when :document
                folder = Treat.paths.files
                if folder[-1] == '/'
          Severity: Minor
          Found in lib/treat/entities/entity/buildable.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 from_serialized_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def from_serialized_file(file)
          
              unless File.readable?(file)
                raise Treat::Exception,
                "Path '#{file}' does not "+
          Severity: Minor
          Found in lib/treat/entities/entity/buildable.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

          There are no issues that match your filters.

          Category
          Status