mapaction/mapactionpy_arcmap

View on GitHub

Showing 28 of 30 total issues

Function updateTextElements has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    def updateTextElements(self, recipe):
        """
        Updates Text Elements in Marginalia
        """
        for elm in arcpy.mapping.ListLayoutElements(self.mxd, "TEXT_ELEMENT"):
Severity: Minor
Found in mapactionpy_arcmap/map_chef.py - About 7 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

File map_chef.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import arcpy
import logging
import re
from datetime import datetime
Severity: Minor
Found in mapactionpy_arcmap/map_chef.py - About 2 hrs to fix

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

        def disableLayers(self):
            """
            Makes all layers invisible for all data-frames
            """
            for df in arcpy.mapping.ListDataFrames(self.mxd):
    Severity: Major
    Found in mapactionpy_arcmap/map_chef.py and 1 other location - About 2 hrs to fix
    mapactionpy_arcmap/map_chef.py on lines 144..150

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

    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 enableLayers(self):
            """
            Makes all layers visible for all data-frames
            """
            for df in arcpy.mapping.ListDataFrames(self.mxd):
    Severity: Major
    Found in mapactionpy_arcmap/map_chef.py and 1 other location - About 2 hrs to fix
    mapactionpy_arcmap/map_chef.py on lines 133..139

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

    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

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

    def main(args):
        args = parser.parse_args()
        layerDirectory = args.layerDirectory
    
        # r=root, d=directories, f = files
    Severity: Minor
    Found in mapactionpy_arcmap/arc_layer_dumper.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 _export_atlas has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _export_atlas(self, recipe_with_atlas, arc_mxd, export_dir):
            """
            Exports each individual page for recipes which contain an atlas definition
            """
            if not recipe_with_atlas.atlas:
    Severity: Minor
    Found in mapactionpy_arcmap/arcmap_runner.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_label_classes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def apply_label_classes(self, arc_lyr_to_add, recipe_lyr):
            if arc_lyr_to_add.supports("LABELCLASSES"):
                for labelClass in recipe_lyr.label_classes:
                    for lblClass in arc_lyr_to_add.labelClasses:
                        if (lblClass.className == labelClass.class_name):
    Severity: Minor
    Found in mapactionpy_arcmap/map_chef.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_layer_properties has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_layer_properties(file):
        lyr = arcpy.mapping.Layer(file)
        layerName = lyr.name.encode('utf-8').strip()
    
        if lyr.supports("DEFINITIONQUERY"):
    Severity: Minor
    Found in mapactionpy_arcmap/arc_layer_dumper.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 showLegendEntries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def showLegendEntries(self):
            for legend in arcpy.mapping.ListLayoutElements(self.mxd, "LEGEND_ELEMENT"):
                layerNames = list()
                for lyr in legend.listLegendItemLayers():
                    if ((lyr.name in self.legendEntriesToRemove) or (lyr.name in layerNames)):
    Severity: Minor
    Found in mapactionpy_arcmap/map_chef.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 _get_version_number has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_version_number():
        travis_build = environ.get('TRAVIS_BUILD_NUMBER')
        travis_tag = environ.get('TRAVIS_TAG')
    
        if travis_build:
    Severity: Minor
    Found in setup.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 cook has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def cook(self, recipe):
            arcpy.env.addOutputsToMap = False
    
            self.disableLayers()
            self.removeLayers()
    Severity: Minor
    Found in mapactionpy_arcmap/map_chef.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 removeLayers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def removeLayers(self):
            """
            Removes all layers for all data-frames
            """
            for df in arcpy.mapping.ListDataFrames(self.mxd):
    Severity: Minor
    Found in mapactionpy_arcmap/map_chef.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

    TODO found
    Open

                    # TODO add proper fix for applyZoom in line with these two cards
    Severity: Minor
    Found in mapactionpy_arcmap/map_chef.py by fixme

    TODO found
    Open

                # TODO: asmith 2020/03/03
    Severity: Minor
    Found in mapactionpy_arcmap/arcmap_runner.py by fixme

    TODO found
    Open

            # TODO asmith 2020/03/06
    Severity: Minor
    Found in mapactionpy_arcmap/map_chef.py by fixme

    TODO found
    Open

    # TODO: asmith 2020/03/03

    TODO found
    Open

            # TODO asmith 2020/03/06
    Severity: Minor
    Found in mapactionpy_arcmap/map_chef.py by fixme

    TODO found
    Open

    # TODO: asmith
    Severity: Minor
    Found in setup.py by fixme

    TODO found
    Open

    # TODO asmith 2020/03/06
    Severity: Minor
    Found in mapactionpy_arcmap/map_chef.py by fixme

    TODO found
    Open

        # TODO asmith 2020/03/06
    Severity: Minor
    Found in mapactionpy_arcmap/map_chef.py by fixme
    Severity
    Category
    Status
    Source
    Language