rstacruz/sinatra-assetpack

View on GitHub

Showing 11 of 11 total issues

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

      def add_individual_routes!
        assets.served.each do |path, from|
          get %r{#{"^/#{path}/".squeeze('/')}(.*)$} do |file|
            fmt = File.extname(file)[1..-1]

Severity: Minor
Found in lib/sinatra/assetpack/class_methods.rb - About 6 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

Class Options has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Options
      include Builder
      include Configurator

      def initialize(app, &blk)
Severity: Minor
Found in lib/sinatra/assetpack/options.rb - About 2 hrs to fix

    Method add_individual_routes! has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def add_individual_routes!
            assets.served.each do |path, from|
              get %r{#{"^/#{path}/".squeeze('/')}(.*)$} do |file|
                fmt = File.extname(file)[1..-1]
    
    
    Severity: Minor
    Found in lib/sinatra/assetpack/class_methods.rb - About 1 hr to fix

      Method combined has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def combined
              session = Rack::Test::Session.new(@assets.app)
              paths.map { |path|
                result = session.get(path)
                if result.body.respond_to?(:force_encoding)
      Severity: Minor
      Found in lib/sinatra/assetpack/package.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(app, &blk)
              unless app.root?
                raise Error, "Please set :root in your Sinatra app."
              end
      
      
      Severity: Minor
      Found in lib/sinatra/assetpack/options.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 preproc has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.preproc(source, assets)
              source.gsub(/url\((["']?)(.*?)(["']?)\)/) do |match|
      
                # Not parsable by URI.parse
                begin
      Severity: Minor
      Found in lib/sinatra/assetpack/css.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 compress has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def compress(str, type, engine=nil, options={})
              # Use defaults if no engine is given.
              return fallback(str, type, options)  if engine.nil?
      
              # Ensure that the engine exists.
      Severity: Minor
      Found in lib/sinatra/assetpack/compressor.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 dimensions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def dimensions
              return @dimensions  unless @dimensions.nil?
      
              dim = /(\d+) x (\d+)/.match(`file "#{@file}"`)
              w, h = dim[1,2]
      Severity: Minor
      Found in lib/sinatra/assetpack/image.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(assets, name, type, path, filespecs)
      Severity: Minor
      Found in lib/sinatra/assetpack/package.rb - About 35 mins to fix

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

              def get_file_uri(file, assets)
                raise RuntimeError, "You must pass in an asset for a URI to be created for it." if file.nil?
        
                local = assets.local_file_for file
        
        
        Severity: Minor
        Found in lib/sinatra/assetpack/html_helpers.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 files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def files(match=nil)
                return @files unless @reload_files_cache
        
                # All
                # A buncha tuples
        Severity: Minor
        Found in lib/sinatra/assetpack/options.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