hackedteam/test-av

View on GitHub
lib/bottle.py

Summary

Maintainability
F
2 wks
Test Coverage

File bottle.py has 2548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Bottle is a fast and simple micro-framework for small web applications. It
offers request dispatching (Routes) with url parameter support, templates,
Severity: Major
Found in lib/bottle.py - About 1 wk to fix

    Function code has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
    Open

        def code(self):
            stack = [] # Current Code indentation
            lineno = 0 # Current line of code
            ptrbuffer = [] # Buffer for printable strings and token tuple instances
            codebuffer = [] # Buffer for generated python code
    Severity: Minor
    Found in lib/bottle.py - About 1 day 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

    Function run has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    def run(app=None, server='wsgiref', host='127.0.0.1', port=8080,
            interval=1, reloader=False, quiet=False, plugins=None,
            debug=False, **kargs):
        """ Start a server instance. This method blocks until the server terminates.
    
    
    Severity: Minor
    Found in lib/bottle.py - About 5 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

    BaseRequest has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseRequest(object):
        """ A wrapper for WSGI environment dictionaries that adds a lot of
            convenient access methods and properties. Most of them are read-only.
    
            Adding new attributes to a request actually adds them to the environ
    Severity: Minor
    Found in lib/bottle.py - About 5 hrs to fix

      Function add has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def add(self, rule, method, target, name=None):
              ''' Add a new route or replace the target for an existing route. '''
              if rule in self.rules:
                  self.rules[rule][method] = target
                  if name: self.builder[name] = self.builder[rule]
      Severity: Minor
      Found in lib/bottle.py - 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

      Function _cast has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def _cast(self, out, peek=None):
              """ Try to convert the parameter into something WSGI compatible and set
              correct HTTP headers when possible.
              Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like,
              iterable of strings and iterable of unicodes
      Severity: Minor
      Found in lib/bottle.py - 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

      Function static_file has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def static_file(filename, root, mimetype='auto', download=False):
          """ Open a file in a safe way and return :exc:`HTTPResponse` with status
              code 200, 305, 401 or 404. Set Content-Type, Content-Encoding,
              Content-Length and Last-Modified header. Obey If-Modified-Since header
              and HEAD requests.
      Severity: Minor
      Found in lib/bottle.py - 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

      BaseResponse has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class BaseResponse(object):
          """ Storage class for a response body as well as headers and cookies.
      
              This class does support dict-like case-insensitive item-access to
              headers, but is NOT a dict. Most notably, iterating over a response
      Severity: Minor
      Found in lib/bottle.py - About 2 hrs to fix

        Bottle has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Bottle(object):
            """ Each Bottle object represents a single, distinct web application and
                consists of routes, callbacks, plugins, resources and configuration.
                Instances are callable WSGI applications.
        
        
        Severity: Minor
        Found in lib/bottle.py - About 2 hrs to fix

          MultiDict has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class MultiDict(DictMixin):
              """ This dict stores multiple values per key, but behaves exactly like a
                  normal dict in that it returns only the newest value for any given key.
                  There are special methods available to access the full list of values.
              """
          Severity: Minor
          Found in lib/bottle.py - About 2 hrs to fix

            Function match has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def match(self, environ):
                    ''' Return a (target, url_agrs) tuple or raise HTTPError(400/404/405). '''
                    path, targets, urlargs = environ['PATH_INFO'] or '/', None, {}
                    if path in self.static:
                        targets = self.static[path]
            Severity: Minor
            Found in lib/bottle.py - 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

            Function set_cookie has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def set_cookie(self, name, value, secret=None, **options):
                    ''' Create a new cookie or replace an old one. If the `secret` parameter is
                        set, create a `Signed Cookie` (described below).
            
                        :param name: the name of the cookie.
            Severity: Minor
            Found in lib/bottle.py - 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

            Function run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def run(self):
                    exists = os.path.exists
                    mtime = lambda path: os.stat(path).st_mtime
                    files = dict()
            
            
            Severity: Minor
            Found in lib/bottle.py - 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

            Function lookup has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def lookup(self, name):
                    ''' Search for a resource and return an absolute file path, or `None`.
            
                        The :attr:`path` list is searched in order. The first match is
                        returend. Symlinks are followed. The result is cached to speed up
            Severity: Minor
            Found in lib/bottle.py - 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

            Function POST has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def POST(self):
                    """ The values of :attr:`forms` and :attr:`files` combined into a single
                        :class:`FormsDict`. Values are either strings (form values) or
                        instances of :class:`cgi.FieldStorage` (file uploads).
                    """
            Severity: Minor
            Found in lib/bottle.py - 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

            Function template has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            def template(*args, **kwargs):
                '''
                Get a rendered template as a string iterator.
                You can use a name, a filename or a template string as first parameter.
                Template rendering arguments can be passed as dictionaries
            Severity: Minor
            Found in lib/bottle.py - 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

            Function all_plugins has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def all_plugins(self):
                    ''' Yield all Plugins affecting this route. '''
                    unique = set()
                    for p in reversed(self.app.plugins + self.plugins):
                        if True in self.skiplist: break
            Severity: Minor
            Found in lib/bottle.py - 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

            Function _make_callback has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def _make_callback(self):
                    callback = self.callback
                    for plugin in self.all_plugins():
                        try:
                            if hasattr(plugin, 'apply'):
            Severity: Minor
            Found in lib/bottle.py - 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

            Function validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def validate(**vkargs):
                """
                Validates and manipulates keyword arguments by user defined callables.
                Handles ValueError and missing arguments by raising HTTPError(403).
                """
            Severity: Minor
            Found in lib/bottle.py - 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

            Function run has 10 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def run(app=None, server='wsgiref', host='127.0.0.1', port=8080,
            Severity: Major
            Found in lib/bottle.py - About 1 hr to fix

              Function parse_rule has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_rule(self, rule):
                      ''' Parses a rule into a (name, filter, conf) token stream. If mode is
                          None, name contains a static rule part. '''
                      offset, prefix = 0, ''
                      for match in self.rule_syntax.finditer(rule):
              Severity: Minor
              Found in lib/bottle.py - 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

              Function path_shift has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              def path_shift(script_name, path_info, shift=1):
                  ''' Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa.
              
                      :return: The modified paths.
                      :param script_name: The SCRIPT_NAME path.
              Severity: Minor
              Found in lib/bottle.py - 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

              Function parse_range_header has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              def parse_range_header(header, maxlen=0):
                  ''' Yield (start, end) ranges parsed from a HTTP Range header. Skip
                      unsatisfiable ranges. The end index is non-inclusive.'''
                  if not header or header[:6] != 'bytes=': return
                  ranges = [r.split('-', 1) for r in header[6:].split(',') if '-' in r]
              Severity: Minor
              Found in lib/bottle.py - 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

              Function wsgi has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def wsgi(self, environ, start_response):
                      """ The bottle WSGI-interface. """
                      try:
                          out = self._cast(self._handle(environ))
                          # rfc2616 section 4.3
              Severity: Minor
              Found in lib/bottle.py - 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

              Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, app, rule, method, callback, name=None,
              Severity: Major
              Found in lib/bottle.py - About 1 hr to fix

                Function __iter__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __iter__(self):
                        ''' Iterate over all existing files in all registered paths. '''
                        search = self.path[:]
                        while search:
                            path = search.pop()
                Severity: Minor
                Found in lib/bottle.py - 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

                Function search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def search(cls, name, lookup=[]):
                        """ Search name in all directories specified in lookup.
                        First without, then with common extensions. Return first hit. """
                        if os.path.isfile(name): return name
                        for spath in lookup:
                Severity: Minor
                Found in lib/bottle.py - 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

                Function route has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def route(self, path=None, method='GET', callback=None, name=None,
                              apply=None, skip=None, **config):
                        """ A decorator to bind a function to a request URL. Example::
                
                                @app.route('/hello/:name')
                Severity: Minor
                Found in lib/bottle.py - 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

                Function route has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def route(self, path=None, method='GET', callback=None, name=None,
                Severity: Major
                Found in lib/bottle.py - About 50 mins to fix

                  Function uninstall has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def uninstall(self, plugin):
                          ''' Uninstall plugins. Pass an instance to remove a specific plugin, a type
                              object to remove all plugins that match that type, a string to remove
                              all plugins with a matching ``name`` attribute or ``True`` to remove all
                              plugins. Return the list of removed plugins. '''
                  Severity: Minor
                  Found in lib/bottle.py - 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

                  Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(self, code=500, output='Unknown Error', exception=None,
                  Severity: Minor
                  Found in lib/bottle.py - About 35 mins to fix

                    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(self, source=None, name=None, lookup=[], encoding='utf8', **settings):
                    Severity: Minor
                    Found in lib/bottle.py - About 35 mins to fix

                      Function urlparts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def urlparts(self):
                              ''' The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.
                                  The tuple contains (scheme, host, path, query_string and fragment),
                                  but the fragment is always empty because it is not visible to the
                                  server. '''
                      Severity: Minor
                      Found in lib/bottle.py - 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

                      Function iter_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def iter_headers(self):
                              ''' Yield (header, value) tuples, skipping headers that are not
                                  allowed with the current response status code. '''
                              headers = self._headers.items()
                              bad_headers = self.bad_headers.get(self._status_code)
                      Severity: Minor
                      Found in lib/bottle.py - 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

                      Function reset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def reset(self, route=None):
                              ''' Reset all routes (force plugins to be re-applied) and clear all
                                  caches. If an ID or route object is given, only that specific route
                                  is affected. '''
                              if route is None: routes = self.routes
                      Severity: Minor
                      Found in lib/bottle.py - 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

                      Avoid too many return statements within this function.
                      Open

                              return HTTPResponse(body, header=header, status=206)
                      Severity: Major
                      Found in lib/bottle.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return itertools.chain([first], out)
                        Severity: Major
                        Found in lib/bottle.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return HTTPResponse(body, header=header)
                          Severity: Major
                          Found in lib/bottle.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                            return request.environ['wsgi.file_wrapper'](out)
                            Severity: Major
                            Found in lib/bottle.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return self._cast(first)
                              Severity: Major
                              Found in lib/bottle.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                return WSGIFileWrapper(out)
                                Severity: Major
                                Found in lib/bottle.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                              return HTTPError(416, "Requested Range Not Satisfiable")
                                  Severity: Major
                                  Found in lib/bottle.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                return self._cast('')
                                    Severity: Major
                                    Found in lib/bottle.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return self._cast(HTTPError(500, 'Unsupported response type: %s'\
                                      Severity: Major
                                      Found in lib/bottle.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                    return imap(lambda x: x.encode(response.charset),
                                        Severity: Major
                                        Found in lib/bottle.py - About 30 mins to fix

                                          Function add_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              def add_path(self, path, base=None, index=None, create=False):
                                                  ''' Add a new path to the list of search paths. Return False if it does
                                                      not exist.
                                          
                                                      :param path: The new search path. Relative paths are turned into an
                                          Severity: Minor
                                          Found in lib/bottle.py - 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

                                          Function _handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              def _handle(self, environ):
                                                  try:
                                                      environ['bottle.app'] = self
                                                      request.bind(environ)
                                                      response.bind()
                                          Severity: Minor
                                          Found in lib/bottle.py - 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

                                          Function __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              def __init__(self, source=None, name=None, lookup=[], encoding='utf8', **settings):
                                                  """ Create a new template.
                                                  If the source parameter (str or buffer) is missing, the name argument
                                                  is used to guess a template filename. Subclasses can assume that
                                                  self.source and/or self.filename are set. Both are strings.
                                          Severity: Minor
                                          Found in lib/bottle.py - 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

                                          Function mount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              def mount(self, prefix, app, **options):
                                                  ''' Mount an application (:class:`Bottle` or plain WSGI) to a specific
                                                      URL prefix. Example::
                                          
                                                          root_app.mount('/admin/', admin_app)
                                          Severity: Minor
                                          Found in lib/bottle.py - 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

                                          Identical blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                              def render(self, *args, **kwargs):
                                                  for dictarg in args: kwargs.update(dictarg)
                                                  _defaults = self.defaults.copy()
                                                  _defaults.update(kwargs)
                                                  return self.tpl.render(**_defaults)
                                          Severity: Major
                                          Found in lib/bottle.py and 1 other location - About 2 hrs to fix
                                          lib/bottle.py on lines 2887..2891

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 52.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Identical blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                              def render(self, *args, **kwargs):
                                                  for dictarg in args: kwargs.update(dictarg)
                                                  _defaults = self.defaults.copy()
                                                  _defaults.update(kwargs)
                                                  return self.tpl.render(**_defaults)
                                          Severity: Major
                                          Found in lib/bottle.py and 1 other location - About 2 hrs to fix
                                          lib/bottle.py on lines 2846..2850

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 52.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                                  def items(self): return ((k, v[-1]) for k, v in self.dict.items())
                                          Severity: Minor
                                          Found in lib/bottle.py and 1 other location - About 45 mins to fix
                                          lib/bottle.py on lines 1716..1717

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 35.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                                  def iteritems(self):
                                                      return ((k, v[-1]) for k, v in self.dict.iteritems())
                                          Severity: Minor
                                          Found in lib/bottle.py and 1 other location - About 45 mins to fix
                                          lib/bottle.py on lines 1703..1703

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 35.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                              if shift > 0 and shift <= len(pathlist):
                                                  moved = pathlist[:shift]
                                                  scriptlist = scriptlist + moved
                                                  pathlist = pathlist[shift:]
                                          Severity: Minor
                                          Found in lib/bottle.py and 1 other location - About 40 mins to fix
                                          lib/bottle.py on lines 2257..2260

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 34.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                                  def allitems(self):
                                                      return ((k, v) for k, vl in self.dict.items() for v in vl)
                                          Severity: Minor
                                          Found in lib/bottle.py and 1 other location - About 40 mins to fix
                                          lib/bottle.py on lines 1718..1719

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 34.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                                  def iterallitems(self):
                                                      return ((k, v) for k, vl in self.dict.iteritems() for v in vl)
                                          Severity: Minor
                                          Found in lib/bottle.py and 1 other location - About 40 mins to fix
                                          lib/bottle.py on lines 1704..1705

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 34.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                              elif shift < 0 and shift >= -len(scriptlist):
                                                  moved = scriptlist[shift:]
                                                  pathlist = moved + pathlist
                                                  scriptlist = scriptlist[:shift]
                                          Severity: Minor
                                          Found in lib/bottle.py and 1 other location - About 40 mins to fix
                                          lib/bottle.py on lines 2253..2256

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 34.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                                              if len(p) == 2:
                                                                  code("globals()['_rebase']=(%s, dict(%s))" % (repr(p[0]), p[1]))
                                          Severity: Minor
                                          Found in lib/bottle.py and 1 other location - About 30 mins to fix
                                          lib/bottle.py on lines 3027..3028

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 32.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                                              if len(p) == 2:
                                                                  code("_=_include(%s, _stdout, %s)" % (repr(p[0]), p[1]))
                                          Severity: Minor
                                          Found in lib/bottle.py and 1 other location - About 30 mins to fix
                                          lib/bottle.py on lines 3035..3036

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 32.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          There are no issues that match your filters.

                                          Category
                                          Status