torvalds/linux

View on GitHub
Documentation/sphinx/kfigure.py

Summary

Maintainability
F
3 days
Test Coverage

File kfigure.py has 471 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8; mode: python -*-
# pylint: disable=C0103, R0903, R0912, R0915
u"""
    scalable figure and image handling
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Severity: Minor
Found in Documentation/sphinx/kfigure.py - About 7 hrs to fix

    Function convert_image has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    def convert_image(img_node, translator, src_fname=None):
        """Convert a image node for the builder.
    
        Different builder prefer different image formats, e.g. *latex* builder
        prefer PDF while *html* builder prefer SVG format for images.
    Severity: Minor
    Found in Documentation/sphinx/kfigure.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 setupTools has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def setupTools(app):
        u"""
        Check available build tools and log some *verbose* messages.
    
        This function is called once, when the builder is initiated.
    Severity: Minor
    Found in Documentation/sphinx/kfigure.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 add_kernel_figure_to_std_domain has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_kernel_figure_to_std_domain(app, doctree):
        """Add kernel-figure anchors to 'std' domain.
    
        The ``StandardDomain.process_doc(..)`` method does not know how to resolve
        the caption (label) of ``kernel-figure`` directive (it only knows about
    Severity: Minor
    Found in Documentation/sphinx/kfigure.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 svg2pdf has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def svg2pdf(app, svg_fname, pdf_fname):
        """Converts SVG to PDF with ``inkscape(1)`` or ``convert(1)`` command.
    
        Uses ``inkscape(1)`` from Inkscape (https://inkscape.org/) or ``convert(1)``
        from ImageMagick (https://www.imagemagick.org) for conversion.
    Severity: Minor
    Found in Documentation/sphinx/kfigure.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

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

            if uri.endswith('.*') or uri.find('://') != -1:
                raise self.severe(
                    'Error in "%s: %s": glob pattern and remote images are not allowed'
                    % (self.name, uri))
    Severity: Major
    Found in Documentation/sphinx/kfigure.py and 1 other location - About 1 hr to fix
    Documentation/sphinx/kfigure.py on lines 488..492

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

    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

            if uri.endswith('.*') or uri.find('://') != -1:
                raise self.severe(
                    'Error in "%s: %s":'
                    ' glob pattern and remote images are not allowed'
                    % (self.name, uri))
    Severity: Major
    Found in Documentation/sphinx/kfigure.py and 1 other location - About 1 hr to fix
    Documentation/sphinx/kfigure.py on lines 452..455

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

    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 3 locations. Consider refactoring.
    Open

        app.add_node(kernel_render,
                     html    = (visit_kernel_render, pass_handle),
                     latex   = (visit_kernel_render, pass_handle),
                     texinfo = (visit_kernel_render, pass_handle),
                     text    = (visit_kernel_render, pass_handle),
    Severity: Major
    Found in Documentation/sphinx/kfigure.py and 2 other locations - About 1 hr to fix
    Documentation/sphinx/kfigure.py on lines 131..136
    Documentation/sphinx/kfigure.py on lines 140..145

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

    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 3 locations. Consider refactoring.
    Open

        app.add_node(kernel_figure,
                     html    = (visit_kernel_figure, pass_handle),
                     latex   = (visit_kernel_figure, pass_handle),
                     texinfo = (visit_kernel_figure, pass_handle),
                     text    = (visit_kernel_figure, pass_handle),
    Severity: Major
    Found in Documentation/sphinx/kfigure.py and 2 other locations - About 1 hr to fix
    Documentation/sphinx/kfigure.py on lines 131..136
    Documentation/sphinx/kfigure.py on lines 149..154

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

    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 3 locations. Consider refactoring.
    Open

        app.add_node(kernel_image,
                     html    = (visit_kernel_image, pass_handle),
                     latex   = (visit_kernel_image, pass_handle),
                     texinfo = (visit_kernel_image, pass_handle),
                     text    = (visit_kernel_image, pass_handle),
    Severity: Major
    Found in Documentation/sphinx/kfigure.py and 2 other locations - About 1 hr to fix
    Documentation/sphinx/kfigure.py on lines 140..145
    Documentation/sphinx/kfigure.py on lines 149..154

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

    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

            if len(result) == 2 or isinstance(result[0], nodes.system_message):
                return result
    Severity: Minor
    Found in Documentation/sphinx/kfigure.py and 1 other location - About 45 mins to fix
    Documentation/sphinx/kfigure.py on lines 457..458

    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

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

            if exit_code != 0:
                kernellog.warn(app,
                              "Error #%d when calling: %s" % (exit_code, " ".join(cmd)))
    Severity: Minor
    Found in Documentation/sphinx/kfigure.py and 1 other location - About 45 mins to fix
    Documentation/sphinx/kfigure.py on lines 420..421

    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

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

            if len(result) == 2 or isinstance(result[0], nodes.system_message):
                return result
    Severity: Minor
    Found in Documentation/sphinx/kfigure.py and 1 other location - About 45 mins to fix
    Documentation/sphinx/kfigure.py on lines 494..495

    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

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

            if exit_code != 0:
                kernellog.warn(app, "Error #%d when calling: %s" % (exit_code, " ".join(cmd)))
    Severity: Minor
    Found in Documentation/sphinx/kfigure.py and 1 other location - About 45 mins to fix
    Documentation/sphinx/kfigure.py on lines 356..358

    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

    There are no issues that match your filters.

    Category
    Status