apel/db/records/storage.py

Summary

Maintainability
F
5 days
Test Coverage

Using Document to parse untrusted XML data is known to be vulnerable to XML attacks. Replace Document with the equivalent defusedxml package, or make sure defusedxml.defuse_stdlib() is called.
Open

from xml.dom.minidom import Document

Severity: Info
Found in apel/db/records/storage.py by bandit

Cyclomatic complexity is too high in method get_ur. (15)
Open

    def get_ur(self, withhold_dns=False):
        '''
        Returns the StorageRecord in StAR format. See
        http://cds.cern.ch/record/1452920/

Severity: Minor
Found in apel/db/records/storage.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Function get_ur has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def get_ur(self, withhold_dns=False):
        '''
        Returns the StorageRecord in StAR format. See
        http://cds.cern.ch/record/1452920/

Severity: Minor
Found in apel/db/records/storage.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_ur has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get_ur(self, withhold_dns=False):
        '''
        Returns the StorageRecord in StAR format. See
        http://cds.cern.ch/record/1452920/

Severity: Minor
Found in apel/db/records/storage.py - About 1 hr to fix

    Too many local variables (41/15)
    Open

        def get_ur(self, withhold_dns=False):
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when a function or method has too many local variables.

    Too many branches (14/12)
    Open

        def get_ur(self, withhold_dns=False):
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when a function or method has too many branches, making it hard to follow.

    Too many statements (98/50)
    Open

        def get_ur(self, withhold_dns=False):
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when a function or method has too many statements. You should then split it in smaller functions / methods.

    Unable to import 'future.builtins'
    Open

    from future.builtins import str
    Severity: Critical
    Found in apel/db/records/storage.py by pylint

    Used when pylint has been unable to import a module.

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

            if self.get_field('Role') is not None:
                role_attr = doc.createElement('sr:GroupAttribute')
                role_attr.setAttribute('sr:attributeType', 'role')
                role_attr.appendChild(doc.createTextNode(self.get_field('Role')))
                s_identity.appendChild(role_attr)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/job.py on lines 215..219
    apel/db/records/job.py on lines 221..225
    apel/db/records/job.py on lines 227..231
    apel/db/records/normalised_summary.py on lines 172..176
    apel/db/records/normalised_summary.py on lines 178..182
    apel/db/records/storage.py on lines 181..185
    apel/db/records/summary.py on lines 167..171
    apel/db/records/summary.py on lines 173..177

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

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

            if self.get_field('SubGroup') is not None:
                sub_attr = doc.createElement('sr:GroupAttribute')
                sub_attr.setAttribute('sr:attributeType', 'subgroup')
                sub_attr.appendChild(doc.createTextNode(self.get_field('SubGroup')))
                s_identity.appendChild(sub_attr)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/job.py on lines 215..219
    apel/db/records/job.py on lines 221..225
    apel/db/records/job.py on lines 227..231
    apel/db/records/normalised_summary.py on lines 172..176
    apel/db/records/normalised_summary.py on lines 178..182
    apel/db/records/storage.py on lines 187..191
    apel/db/records/summary.py on lines 167..171
    apel/db/records/summary.py on lines 173..177

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

    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

            if self.get_field('LogicalCapacityUsed') is not None:
                logical_capacity_used = self.get_field('LogicalCapacityUsed')
                l_capacity_used = doc.createElement('sr:LogicalCapacityUsed')
                l_capacity_used.appendChild(doc.createTextNode(str(logical_capacity_used)))
                ur.appendChild(l_capacity_used)
    Severity: Major
    Found in apel/db/records/storage.py and 2 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 142..146
    apel/db/records/storage.py on lines 217..221

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

    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

            if self.get_field('ResourceCapacityAllocated') is not None:
                resource_capacity_allocated = self.get_field('ResourceCapacityAllocated')
                r_capacity_allocated = doc.createElement('sr:ResourceCapacityAllocated')
                r_capacity_allocated.appendChild(doc.createTextNode(str(resource_capacity_allocated)))
                ur.appendChild(r_capacity_allocated)
    Severity: Major
    Found in apel/db/records/storage.py and 2 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 142..146
    apel/db/records/storage.py on lines 211..215

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

    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

            if self.get_field('FileCount') is not None:
                file_count = self.get_field('FileCount')
                f_count = doc.createElement('sr:FileCount')
                f_count.appendChild(doc.createTextNode(str(file_count)))
                ur.appendChild(f_count)
    Severity: Major
    Found in apel/db/records/storage.py and 2 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 211..215
    apel/db/records/storage.py on lines 217..221

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

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

            if self.get_field('UserIdentity') is not None:
                user_identity = self.get_field('UserIdentity')
                u_identity = doc.createElement('sr:UserIdentity')
                u_identity.appendChild(doc.createTextNode(user_identity))
                s_identity.appendChild(u_identity)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 118..122
    apel/db/records/storage.py on lines 124..128
    apel/db/records/storage.py on lines 130..134
    apel/db/records/storage.py on lines 136..140
    apel/db/records/storage.py on lines 148..152
    apel/db/records/storage.py on lines 157..161
    apel/db/records/storage.py on lines 163..167
    apel/db/records/storage.py on lines 175..179

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

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

            if self.get_field('StorageClass') is not None:
                storage_class = self.get_field('StorageClass')
                s_class = doc.createElement('sr:StorageClass')
                s_class.appendChild(doc.createTextNode(storage_class))
                ur.appendChild(s_class)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 118..122
    apel/db/records/storage.py on lines 124..128
    apel/db/records/storage.py on lines 130..134
    apel/db/records/storage.py on lines 148..152
    apel/db/records/storage.py on lines 157..161
    apel/db/records/storage.py on lines 163..167
    apel/db/records/storage.py on lines 169..173
    apel/db/records/storage.py on lines 175..179

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

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

            if self.get_field('StorageMedia') is not None:
                storage_media = self.get_field('StorageMedia')
                s_media = doc.createElement('sr:StorageMedia')
                s_media.appendChild(doc.createTextNode(storage_media))
                ur.appendChild(s_media)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 118..122
    apel/db/records/storage.py on lines 124..128
    apel/db/records/storage.py on lines 136..140
    apel/db/records/storage.py on lines 148..152
    apel/db/records/storage.py on lines 157..161
    apel/db/records/storage.py on lines 163..167
    apel/db/records/storage.py on lines 169..173
    apel/db/records/storage.py on lines 175..179

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

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

            if self.get_field('LocalUser') is not None:
                local_user = self.get_field('LocalUser')
                l_user = doc.createElement('sr:LocalUser')
                l_user.appendChild(doc.createTextNode(local_user))
                s_identity.appendChild(l_user)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 118..122
    apel/db/records/storage.py on lines 124..128
    apel/db/records/storage.py on lines 130..134
    apel/db/records/storage.py on lines 136..140
    apel/db/records/storage.py on lines 148..152
    apel/db/records/storage.py on lines 163..167
    apel/db/records/storage.py on lines 169..173
    apel/db/records/storage.py on lines 175..179

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

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

            if self.get_field('Site') is not None:
                site = self.get_field('Site')
                s_site = doc.createElement('sr:Site')
                s_site.appendChild(doc.createTextNode(site))
                ur.appendChild(s_site)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 124..128
    apel/db/records/storage.py on lines 130..134
    apel/db/records/storage.py on lines 136..140
    apel/db/records/storage.py on lines 148..152
    apel/db/records/storage.py on lines 157..161
    apel/db/records/storage.py on lines 163..167
    apel/db/records/storage.py on lines 169..173
    apel/db/records/storage.py on lines 175..179

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

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

            if self.get_field('Group') is not None:
                group_field = self.get_field('Group')
                group_node = doc.createElement('sr:Group')
                group_node.appendChild(doc.createTextNode(group_field))
                s_identity.appendChild(group_node)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 118..122
    apel/db/records/storage.py on lines 124..128
    apel/db/records/storage.py on lines 130..134
    apel/db/records/storage.py on lines 136..140
    apel/db/records/storage.py on lines 148..152
    apel/db/records/storage.py on lines 157..161
    apel/db/records/storage.py on lines 163..167
    apel/db/records/storage.py on lines 169..173

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

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

            if self.get_field('DirectoryPath') is not None:
                directory_path = self.get_field('DirectoryPath')
                d_path = doc.createElement('sr:DirectoryPath')
                d_path.appendChild(doc.createTextNode(directory_path))
                ur.appendChild(d_path)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 118..122
    apel/db/records/storage.py on lines 124..128
    apel/db/records/storage.py on lines 130..134
    apel/db/records/storage.py on lines 136..140
    apel/db/records/storage.py on lines 157..161
    apel/db/records/storage.py on lines 163..167
    apel/db/records/storage.py on lines 169..173
    apel/db/records/storage.py on lines 175..179

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

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

            if self.get_field('LocalGroup') is not None:
                local_group = self.get_field('LocalGroup')
                l_group = doc.createElement('sr:LocalGroup')
                l_group.appendChild(doc.createTextNode(local_group))
                s_identity.appendChild(l_group)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 118..122
    apel/db/records/storage.py on lines 124..128
    apel/db/records/storage.py on lines 130..134
    apel/db/records/storage.py on lines 136..140
    apel/db/records/storage.py on lines 148..152
    apel/db/records/storage.py on lines 157..161
    apel/db/records/storage.py on lines 169..173
    apel/db/records/storage.py on lines 175..179

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

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

            if self.get_field('StorageShare') is not None:
                storage_share = self.get_field('StorageShare')
                s_share = doc.createElement('sr:StorageShare')
                s_share.appendChild(doc.createTextNode(storage_share))
                ur.appendChild(s_share)
    Severity: Major
    Found in apel/db/records/storage.py and 8 other locations - About 3 hrs to fix
    apel/db/records/storage.py on lines 118..122
    apel/db/records/storage.py on lines 130..134
    apel/db/records/storage.py on lines 136..140
    apel/db/records/storage.py on lines 148..152
    apel/db/records/storage.py on lines 157..161
    apel/db/records/storage.py on lines 163..167
    apel/db/records/storage.py on lines 169..173
    apel/db/records/storage.py on lines 175..179

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

    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

    Line too long (116 > 79 characters)
    Open

            self._int_fields = ["FileCount", "ResourceCapacityUsed", "LogicalCapacityUsed", "ResourceCapacityAllocated"]
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (90 > 79 characters)
    Open

            rec_id.setAttribute('sr:createTime', datetime.now().strftime('%Y-%m-%dT%H:%M:%S'))
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Continuation line over-indented for visual indent
    Open

                           "StorageMedia", "StorageClass", "FileCount", "DirectoryPath",
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Continuation lines indentation.

    Continuation lines should align wrapped elements either vertically
    using Python's implicit line joining inside parentheses, brackets
    and braces, or using a hanging indent.
    
    When using a hanging indent these considerations should be applied:
    - there should be no arguments on the first line, and
    - further indentation should be used to clearly distinguish itself
      as a continuation line.
    
    Okay: a = (\n)
    E123: a = (\n    )
    
    Okay: a = (\n    42)
    E121: a = (\n   42)
    E122: a = (\n42)
    E123: a = (\n    42\n    )
    E124: a = (24,\n     42\n)
    E125: if (\n    b):\n    pass
    E126: a = (\n        42)
    E127: a = (24,\n      42)
    E128: a = (24,\n    42)
    E129: if (a or\n    b):\n    pass
    E131: a = (\n    42\n 24)

    Line too long (84 > 79 characters)
    Open

                           "StorageMedia", "StorageClass", "FileCount", "DirectoryPath",
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Expected 2 blank lines, found 1
    Open

    class StorageRecord(Record):
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Separate top-level function and class definitions with two blank lines.

    Method definitions inside a class are separated by a single blank
    line.
    
    Extra blank lines may be used (sparingly) to separate groups of
    related functions.  Blank lines may be omitted between a bunch of
    related one-liners (e.g. a set of dummy implementations).
    
    Use blank lines in functions, sparingly, to indicate logical
    sections.
    
    Okay: def a():\n    pass\n\n\ndef b():\n    pass
    Okay: def a():\n    pass\n\n\nasync def b():\n    pass
    Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
    Okay: default = 1\nfoo = 1
    Okay: classify = 1\nfoo = 1
    
    E301: class Foo:\n    b = 0\n    def bar():\n        pass
    E302: def a():\n    pass\n\ndef b(n):\n    pass
    E302: def a():\n    pass\n\nasync def b(n):\n    pass
    E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
    E303: def a():\n\n\n\n    pass
    E304: @decorator\n\ndef a():\n    pass
    E305: def a():\n    pass\na()
    E306: def a():\n    def b():\n        pass\n    def c():\n        pass

    Continuation line over-indented for visual indent
    Open

                                      "StartTime", "EndTime",
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Continuation lines indentation.

    Continuation lines should align wrapped elements either vertically
    using Python's implicit line joining inside parentheses, brackets
    and braces, or using a hanging indent.
    
    When using a hanging indent these considerations should be applied:
    - there should be no arguments on the first line, and
    - further indentation should be used to clearly distinguish itself
      as a continuation line.
    
    Okay: a = (\n)
    E123: a = (\n    )
    
    Okay: a = (\n    42)
    E121: a = (\n   42)
    E122: a = (\n42)
    E123: a = (\n    42\n    )
    E124: a = (24,\n     42\n)
    E125: if (\n    b):\n    pass
    E126: a = (\n        42)
    E127: a = (24,\n      42)
    E128: a = (24,\n    42)
    E129: if (a or\n    b):\n    pass
    E131: a = (\n    42\n 24)

    Line too long (83 > 79 characters)
    Open

        DB_FIELDS = ["RecordId", "CreateTime", "StorageSystem", "Site", "StorageShare",
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (80 > 79 characters)
    Open

                sub_attr.appendChild(doc.createTextNode(self.get_field('SubGroup')))
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (97 > 79 characters)
    Open

            start_text = time.strftime('%Y-%m-%dT%H:%M:%SZ', self.get_field('StartTime').timetuple())
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (93 > 79 characters)
    Open

            end_text = time.strftime('%Y-%m-%dT%H:%M:%SZ', self.get_field('EndTime').timetuple())
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (98 > 79 characters)
    Open

                r_capacity_allocated.appendChild(doc.createTextNode(str(resource_capacity_allocated)))
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (84 > 79 characters)
    Open

                r_capacity_allocated = doc.createElement('sr:ResourceCapacityAllocated')
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (84 > 79 characters)
    Open

            r_capacity_used.appendChild(doc.createTextNode(str(resource_capacity_used)))
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (87 > 79 characters)
    Open

                l_capacity_used.appendChild(doc.createTextNode(str(logical_capacity_used)))
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (85 > 79 characters)
    Open

                resource_capacity_allocated = self.get_field('ResourceCapacityAllocated')
    Severity: Minor
    Found in apel/db/records/storage.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Wrong continued indentation (remove 6 spaces).
    Open

                           "ResourceCapacityAllocated"]
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    TODO ResourceCapacityAllocated] | ^

    Wrong continued indentation (remove 10 spaces).
    Open

                                      "StartTime", "EndTime",
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    TODO StartTime, EndTime, | ^

    Wrong continued indentation (remove 6 spaces).
    Open

                           "StorageMedia", "StorageClass", "FileCount", "DirectoryPath",
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    TODO StorageMedia, StorageClass, FileCount, DirectoryPath, | ^

    Wrong continued indentation (remove 10 spaces).
    Open

                                      "ResourceCapacityUsed"]
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    TODO ResourceCapacityUsed] | ^

    standard import import time should be placed before from future.builtins import str
    Open

    import time
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when PEP8 import order is not respected (standard imports first, then third-party libraries, then local imports)

    Constant name log doesn't conform to UPPER_CASE naming style
    Open

    log = logging.getLogger(__name__)
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

    Wrong continued indentation (remove 6 spaces).
    Open

                           "Group", "SubGroup", "Role", "StartTime", "EndTime",
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    TODO Group, SubGroup, Role, StartTime, EndTime, | ^

    Wrong continued indentation (remove 6 spaces).
    Open

                           "LocalUser", "LocalGroup", "UserIdentity",
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    TODO LocalUser, LocalGroup, UserIdentity, | ^

    standard import from xml.dom.minidom import Document should be placed before from future.builtins import str
    Open

    from xml.dom.minidom import Document
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when PEP8 import order is not respected (standard imports first, then third-party libraries, then local imports)

    Wrong continued indentation (remove 6 spaces).
    Open

                           "ResourceCapacityUsed", "LogicalCapacityUsed",
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    TODO ResourceCapacityUsed, LogicalCapacityUsed, | ^

    standard import import logging should be placed before from future.builtins import str
    Open

    import logging
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when PEP8 import order is not respected (standard imports first, then third-party libraries, then local imports)

    Variable name ur doesn't conform to snake_case naming style
    Open

            ur = doc.createElement('sr:StorageUsageRecord')
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

    Line too long (116/100)
    Open

            self._int_fields = ["FileCount", "ResourceCapacityUsed", "LogicalCapacityUsed", "ResourceCapacityAllocated"]
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when a line is longer than a given number of characters.

    standard import from datetime import datetime should be placed before from future.builtins import str
    Open

    from datetime import datetime
    Severity: Info
    Found in apel/db/records/storage.py by pylint

    Used when PEP8 import order is not respected (standard imports first, then third-party libraries, then local imports)

    There are no issues that match your filters.

    Category
    Status