Showing 19 of 19 total issues

Class Language has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Language

    # @return [Array<String>] list of file extensions
    attr_reader :extensions

Severity: Minor
Found in lib/cog/language.rb - About 3 hrs to fix

    Class LanguageDSL has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class LanguageDSL
          
          # @api developer
          # @param key [String] unique case-insensitive identifier
          def initialize(key)
    Severity: Minor
    Found in lib/cog/dsl/language_dsl.rb - About 3 hrs to fix

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

          def stamp(template_path, destination=nil, opt={})
            # Ignore destination if its a hash, its meant to be opt
            opt, destination = destination, nil if destination.is_a? Hash
            
            # Render and filter
      Severity: Minor
      Found in lib/cog/generator.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 activate_language has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def activate_language(key, opt={}, &block)
              opt, key = key, nil if key.is_a? Hash
              key = if opt[:ext]
                ext = opt[:ext].to_s.downcase
                ext = ext.slice(1..-1) if ext.start_with?('.')
      Severity: Minor
      Found in lib/cog/config/language_config.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 capture_until has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def capture_until(pattern, opt={})
              @cap_begin_pos = @f.pos - win_fudge
              but_not = opt[:but_not] || []
              but_not = [but_not] unless but_not.is_a?(Array)
              while line = @f.readline
      Severity: Minor
      Found in lib/cog/helpers/file_scanner.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 cog_source_and_type has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def cog_source_and_type
          if ((Cog.project_root && start_with?(Cog.project_root)) ||
              (Cog.project_template_path && start_with?(Cog.project_template_path)) || 
              (Cog.project_generator_path && start_with?(Cog.project_generator_path)) ||
              (Cog.project_plugin_path && start_with?(Cog.project_plugin_path)))
      Severity: Minor
      Found in lib/cog/native_extensions/string.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

      Consider simplifying this complex logical expression.
      Open

          if ((Cog.project_root && start_with?(Cog.project_root)) ||
              (Cog.project_template_path && start_with?(Cog.project_template_path)) || 
              (Cog.project_generator_path && start_with?(Cog.project_generator_path)) ||
              (Cog.project_plugin_path && start_with?(Cog.project_plugin_path)))
            [File.basename(Cog.project_root), :project]
      Severity: Critical
      Found in lib/cog/native_extensions/string.rb - About 1 hr to fix

        Method get_template has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def get_template(path, opt={})
                path = path.to_s
                path += '.erb'
                fullpath = if opt[:absolute]
                  path
        Severity: Minor
        Found in lib/cog/generator/file_methods.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 read_until has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def read_until(pattern, n=0)
                i = 0
                mark!
                while (line = @f.readline) && i <= n
                  if @match = pattern.match(line)
        Severity: Minor
        Found in lib/cog/helpers/file_scanner.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 method_missing has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def method_missing(meth, *args, &block)
                meth = meth.to_s
                if meth.end_with? '_feature'
                  opt = args.last.is_a?(Hash) ? args.pop : {}
                  if /(?:\b|_)(public|protected|private)(?:\b|_)/ =~ meth
        Severity: Minor
        Found in lib/cog/dsl/seed_dsl.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 output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def output(x)
                match_maker do
                  message do
                    if x.is_a? Regexp
                      "to [write|not write] #{x.inspect} to STDOUT"
        Severity: Minor
        Found in lib/cog/spec_helpers/matchers.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 finalize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def finalize
                pattern = /[*]/
                esc = lambda do |x|
                  x.gsub(pattern) {|match| "\\#{match}"}
                end
        Severity: Minor
        Found in lib/cog/dsl/language_dsl.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 stamp_class has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def stamp_class(path, opt={})
              Cog.activate_language opt[:language] do
                l = Cog.active_language
                raise Errors::ActiveLanguageDoesNotSupportSeeds.new :language => l if l.nil? || l.seed_extension.nil?
                
        Severity: Minor
        Found in lib/cog/seed.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

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

              def initialize(filename)
                @filename = filename
                @f = File.open filename, 'r'
                @f = @f.binmode if @f.respond_to?(:binmode)
                @lines = []
        Severity: Minor
        Found in lib/cog/helpers/file_scanner.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 copy_keeps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def copy_keeps(original, scratch)
              Cog.activate_language(:filename => original) do
                original = scratch unless File.exists? original
                keeps = gather_keeps original, scratch
                keeps.each_pair do |hook, c|
        Severity: Minor
        Found in lib/cog/embeds.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 process_cogfiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_cogfiles(opt={})
              @project_cogfile_path = opt[:project_cogfile_path] || find_default_cogfile
              if @project_cogfile_path
                @project_cogfile_path = File.expand_path @project_cogfile_path
                @project_root = File.dirname @project_cogfile_path
        Severity: Minor
        Found in lib/cog/config.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 plugin_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def plugin_path(path, absolute=false)
                return if plugin?
                path = add_config_path :plugin, path, absolute
                if path && File.exists?(path)
                  raise Errors::PluginPathIsNotADirectory.new path unless File.directory?(path)
        Severity: Minor
        Found in lib/cog/dsl/cogfile.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 gather_keeps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def gather_keeps(original, scratch)
              keeps = {}
              gather_from_file(original, :type => 'keep').each_pair do |hook, count|
                c = keeps[hook] = EmbedContext.new(hook, scratch, count[original])
                raise Errors::DuplicateKeep.new :hook => hook if c.count > 1
        Severity: Minor
        Found in lib/cog/embeds.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def update(c, opt={}, &block)
              type = opt[:type] || 'cog'
              Helpers::FileScanner.scan(c.path, statement(type, c.hook), :occurrence => c.actual_index) do |s|
                c.lineno = s.marked_line_number
                c.args = s.match[2].split if s.match[2]
        Severity: Minor
        Found in lib/cog/embeds.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