enclose-io/compiler

View on GitHub
lts/deps/v8/third_party/jinja2/environment.py

Summary

Maintainability
F
2 mos
Test Coverage

File environment.py has 1029 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
"""
    jinja2.environment
    ~~~~~~~~~~~~~~~~~~

Severity: Major
Found in lts/deps/v8/third_party/jinja2/environment.py - About 2 days to fix

    Function compile_templates has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def compile_templates(self, target, extensions=None, filter_func=None,
                              zip='deflated', log_function=None,
                              ignore_errors=True, py_compile=False):
            """Finds all the templates the loader can find, compiles them
            and stores them in `target`.  If `zip` is `None`, instead of in a
    Severity: Minor
    Found in lts/deps/v8/third_party/jinja2/environment.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

    Environment has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Environment(object):
        r"""The core component of Jinja is the `Environment`.  It contains
        important shared variables like configuration, filters, tests,
        globals and others.  Instances of this class may be modified if
        they are not shared and if no template was loaded so far.
    Severity: Minor
    Found in lts/deps/v8/third_party/jinja2/environment.py - About 3 hrs to fix

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

          def __init__(self,
      Severity: Major
      Found in lts/deps/v8/third_party/jinja2/environment.py - About 2 hrs to fix

        Function __new__ has 19 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __new__(cls, source,
        Severity: Major
        Found in lts/deps/v8/third_party/jinja2/environment.py - About 2 hrs to fix

          Function overlay has 19 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def overlay(self, block_start_string=missing, block_end_string=missing,
          Severity: Major
          Found in lts/deps/v8/third_party/jinja2/environment.py - About 2 hrs to fix

            Function call_filter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def call_filter(self, name, value, args=None, kwargs=None,
                                context=None, eval_ctx=None):
                    """Invokes a filter on a value the same way the compiler does it.
            
                    Note that on Python 3 this might return a coroutine in case the
            Severity: Minor
            Found in lts/deps/v8/third_party/jinja2/environment.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 _buffered_generator has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def _buffered_generator(self, size):
                    buf = []
                    c_size = 0
                    push = buf.append
            
            
            Severity: Minor
            Found in lts/deps/v8/third_party/jinja2/environment.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 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def __init__(self,
                             block_start_string=BLOCK_START_STRING,
                             block_end_string=BLOCK_END_STRING,
                             variable_start_string=VARIABLE_START_STRING,
                             variable_end_string=VARIABLE_END_STRING,
            Severity: Minor
            Found in lts/deps/v8/third_party/jinja2/environment.py - About 1 hr to fix

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

                  def getitem(self, obj, argument):
                      """Get an item or attribute of an object but prefer the item."""
                      try:
                          return obj[argument]
                      except (AttributeError, TypeError, LookupError):
              Severity: Minor
              Found in lts/deps/v8/third_party/jinja2/environment.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 dump has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def dump(self, fp, encoding=None, errors='strict'):
                      """Dump the complete stream into a file or file-like object.
                      Per default unicode strings are written, if you want to encode
                      before writing specify an `encoding`.
              
              
              Severity: Minor
              Found in lts/deps/v8/third_party/jinja2/environment.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 compile_templates has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def compile_templates(self, target, extensions=None, filter_func=None,
              Severity: Major
              Found in lts/deps/v8/third_party/jinja2/environment.py - About 50 mins to fix

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

                    def select_template(self, names, parent=None, globals=None):
                        """Works like :meth:`get_template` but tries a number of templates
                        before it fails.  If it cannot find any of the templates, it will
                        raise a :exc:`TemplatesNotFound` exception.
                
                
                Severity: Minor
                Found in lts/deps/v8/third_party/jinja2/environment.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 call_filter has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def call_filter(self, name, value, args=None, kwargs=None,
                Severity: Minor
                Found in lts/deps/v8/third_party/jinja2/environment.py - About 45 mins to fix

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

                      def compile(self, source, name=None, filename=None, raw=False,
                  Severity: Minor
                  Found in lts/deps/v8/third_party/jinja2/environment.py - About 35 mins to fix

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

                        def overlay(self, block_start_string=missing, block_end_string=missing,
                                    variable_start_string=missing, variable_end_string=missing,
                                    comment_start_string=missing, comment_end_string=missing,
                                    line_statement_prefix=missing, line_comment_prefix=missing,
                                    trim_blocks=missing, lstrip_blocks=missing,
                    Severity: Minor
                    Found in lts/deps/v8/third_party/jinja2/environment.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 _load_template has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _load_template(self, name, globals):
                            if self.loader is None:
                                raise TypeError('no loader for this environment specified')
                            cache_key = (weakref.ref(self.loader), name)
                            if self.cache is not None:
                    Severity: Minor
                    Found in lts/deps/v8/third_party/jinja2/environment.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 4 locations. Consider refactoring.
                    Open

                    Severity: Major
                    Found in lts/deps/v8/third_party/jinja2/environment.py and 3 other locations - About 1 mo to fix
                    current/deps/v8/third_party/jinja2/environment.py on lines 0..1276
                    current/tools/inspector_protocol/jinja2/environment.py on lines 0..1276
                    lts/tools/inspector_protocol/jinja2/environment.py on lines 0..1276

                    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 5024.

                    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