mapaction/mapactionpy_arcmap

View on GitHub

Showing 10 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

    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

    Severity
    Category
    Status
    Source
    Language