akretion/storage

View on GitHub

Showing 8 of 17 total issues

Function render_value has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        render_value: function () {
            var self = this;
            var url = this.get('value');
            if (!url) {
                url = this.placeholder;
Severity: Minor
Found in storage_image/static/src/js/storage_image.js - About 1 hr to fix

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

        def get_or_create_thumbnail(self, size_x, size_y, url_key=None):
            self.ensure_one()
            # preserve the prefetch when changing context
            self = self.with_context(bin_size=False).with_prefetch(self._prefetch)
            if url_key:
    Severity: Minor
    Found in storage_thumbnail/models/thumbnail_mixin.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def add(self, relative_path, data, **kwargs):
            with sftp(self.collection) as client:
                full_path = self._fullpath(relative_path)
                dirname = os.path.dirname(full_path)
                if dirname:
    Severity: Minor
    Found in storage_backend_sftp/components/sftp_adapter.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 write has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def write(self, vals):
            if "data" in vals:
                for record in self:
                    if record.data:
                        raise UserError(
    Severity: Minor
    Found in storage_file/models/storage_file.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 _compute_variant_media_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _compute_variant_media_ids(self):
            for variant in self:
                res = self.env["product.media.relation"].browse([])
                for media in variant.media_ids:
                    if not (
    Severity: Minor
    Found in storage_media_product/models/product.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 sftp_mkdirs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def sftp_mkdirs(client, path, mode=511):
        try:
            client.mkdir(path, mode)
        except IOError as e:
            if e.errno == errno.ENOENT and path:
    Severity: Minor
    Found in storage_backend_sftp/components/sftp_adapter.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 _compute_variant_image_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _compute_variant_image_ids(self):
            for variant in self:
                res = self.env["product.image.relation"].browse([])
                for image in variant.image_ids:
                    if not (
    Severity: Minor
    Found in storage_image_product/models/product_product.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 onchange_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def onchange_name(self):
            for record in self:
                if record.name:
                    filename, extension = os.path.splitext(record.name)
                    record.name = "{}{}".format(slugify(filename), extension)
    Severity: Minor
    Found in storage_image/models/storage_image.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

    Severity
    Category
    Status
    Source
    Language