Showing 17 of 39 total issues

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

    def run(self, context):
        '''Run the generator.

        :param context: The context of the site.
        :type context: ssg.context.Context
Severity: Minor
Found in ssg/generators/tagcloud.py - About 6 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    def run(self, context):
        '''Run the generator.

        :param context: The context of the site.
        :type context: ssg.context.Context
Severity: Minor
Found in ssg/generators/blogindex.py - About 6 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function _check_updated has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

def _check_updated(context):
    '''
    Check which files need updating.

    :param context: Site context.
Severity: Minor
Found in ssg/writer.py - 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

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

    def run(self, context):
        '''Run the generator.

        :param context: The context of the site.
        :type context: ssg.context.Context
Severity: Minor
Found in ssg/generators/categoryindex.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 write has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def write(input_path, context, update=True):
    '''Write and copy all output files into place.

    :param input_path: Path with input files.
    :type input_path: string
Severity: Minor
Found in ssg/writer.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 cleanup_destination has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def cleanup_destination(output_path, written_files):
    '''Delete any files in the destination directory that are no longer in
    the source directory. The algorithm replaces ".md" with ".html."

    :param output_path: Path to output files.
Severity: Minor
Found in ssg/writer.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 __check_tmpl_vars has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def __check_tmpl_vars(self, content):
        '''
        Check for stray single dollar characters.

        :param content: List of content lines.
Severity: Minor
Found in ssg/contentfilters/localurl.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 get_files has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def get_files(path, extension):
    '''Get a list of files with extension from path an subdirectories.

    :param path: Path to look for files
    :type path: string
Severity: Minor
Found in ssg/tools.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 apply_templates has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def apply_templates(path, context):
    """
    Apply jinja2 templates to content, and write the files.

    :param path: Path to templates
Severity: Minor
Found in ssg/__init__.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 _set_template_post has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _set_template_post(self, context):
        '''Apply post template to all content that has type post, if no
        template is set.
        '''
        for content in context.contents:
Severity: Minor
Found in ssg/generators/blogindex.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

Avoid deeply nested control flow statements.
Open

                        for tag in content['metadata']['tags'].split(','):
                            tag = tag.lower().strip()
                            filelist[tag] = tags[tag]['filename']
                            logger.debug('"' + tags[tag]['filename'] + '"' +
                                         ' for tag: ' + tag)
Severity: Major
Found in ssg/generators/tagcloud.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        for tag in content['metadata']['tags'].split(','):
                            tag = tag.strip().lower()
                            if tag in tags:
                                tags[tag]['items'] += 1
                                tags[tag]['posts'].append(content)
Severity: Major
Found in ssg/generators/tagcloud.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if category in categories:
                            # Increase post count and add post to the category
                            categories[category]['items'] += 1
                            categories[category]['posts'].append(content)
                        else:
Severity: Major
Found in ssg/generators/categoryindex.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if page == 1:
                            self._create_index(context, 0, n_pages, posts)
                        page += 1
Severity: Major
Found in ssg/generators/blogindex.py - About 45 mins to fix

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

    def parse(self, path):
        """
        Parse category from path and return meta data in a dictionary.

        :param path: Path to content.
Severity: Minor
Found in ssg/metaext/categorymetaparser.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 process_content has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def process_content(path, context):
    """
    Process all contents, converting it to HTML.

    *Metadata need to start at the first line of the file, and to have ONE
Severity: Minor
Found in ssg/__init__.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 get_dirs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def get_dirs(root_dir):
    '''
    Get a list of all directories and subdirectories of these, from a given
    path.

Severity: Minor
Found in ssg/tools.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

Severity
Category
Status
Source
Language