learnjin/rewritten

View on GitHub

Showing 11 of 11 total issues

Method call has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

      def call(env)
        req = Rack::Request.new(env)

        subdomain = env['SUBDOMAIN'] ? "#{env['SUBDOMAIN']}:" : ''

Severity: Minor
Found in lib/rack/url.rb - About 4 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 call has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

      def call(env)
        req = Rack::Request.new(env)
        status, headers, response = @app.call(env)

        if status == 200
Severity: Minor
Found in lib/rack/html.rb - About 3 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 get_current_translation has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def get_current_translation(path, tail = nil)
    uri = URI.parse(path)

    # find directly
    translation = Rewritten.z_range("to:#{path}", -1)
Severity: Minor
Found in lib/rewritten.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 call has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def call(env)
        req = Rack::Request.new(env)

        subdomain = env['SUBDOMAIN'] ? "#{env['SUBDOMAIN']}:" : ''

Severity: Minor
Found in lib/rack/url.rb - About 1 hr to fix

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

      def infinitive(some_from)
        some_from ||= ''
    
        conjugated = some_from.chomp('/')
    
    
    Severity: Minor
    Found in lib/rewritten.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def call(env)
            puts '-> Rack::Rewritten::Subdomain'
            req = Rack::Request.new(env)
    
            @fqdns.each do |n|
    Severity: Minor
    Found in lib/rack/subdomain.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

    Avoid too many return statements within this function.
    Open

              return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
    Severity: Major
    Found in lib/rewritten/server/public/jquery.relatize_date.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                return $r.strftime(fromTime, fmt);
      Severity: Major
      Found in lib/rewritten/server/public/jquery.relatize_date.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                  return '1 day ago';
        Severity: Major
        Found in lib/rewritten/server/public/jquery.relatize_date.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                    return days + " days ago"
          Severity: Major
          Found in lib/rewritten/server/public/jquery.relatize_date.js - About 30 mins to fix

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

              def includes?(path)
                result = Rewritten.redis.hget("from:#{path.chomp('/')}", :to)
                result = Rewritten.redis.hget("from:#{path.split('?')[0]}", :to) unless result
            
                if result.nil? && translate_partial && path.count('/') > 1
            Severity: Minor
            Found in lib/rewritten.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