apel/db/loader/xml_parser.py

Summary

Maintainability
A
0 mins
Test Coverage

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

import xml.dom.minidom

Severity: Info
Found in apel/db/loader/xml_parser.py by bandit

Using xml.dom.minidom.parseString to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.dom.minidom.parseString with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Open

    d = xml.dom.minidom.parseString(msg_text)
Severity: Minor
Found in apel/db/loader/xml_parser.py by bandit

Using xml.dom.minidom.parseString to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.dom.minidom.parseString with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Open

        self.doc = xml.dom.minidom.parseString(self.text)
Severity: Minor
Found in apel/db/loader/xml_parser.py by bandit

Class 'XMLParser' inherits from object, can be safely removed from bases in python3
Open

class XMLParser(object):
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

Used when a class inherit from object, which under python3 is implicit, hence can be safely removed from bases.

Unnecessary else after return
Open

        if namespace is None:
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

Used in order to highlight an unnecessary block of code following an if containing a return statement. As such, it will warn when it encounters an else following a chain of ifs, all of them containing a return statement.

Method could be a function
Open

    def getText(self, nodes):
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

Used when a method doesn't use its bound instance, and so could be written as a function.

Unnecessary pass statement
Open

    pass
Severity: Minor
Found in apel/db/loader/xml_parser.py by pylint

Used when a pass statement that can be avoided is encountered.

Line too long (99 > 79 characters)
Open

        data = (''.join([ node.nodeType == node.TEXT_NODE and node.data or '' for node in nodes ]))
Severity: Minor
Found in apel/db/loader/xml_parser.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 XMLParserException(Exception):
Severity: Minor
Found in apel/db/loader/xml_parser.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

Too many blank lines (2)
Open

    def getAttr(self, node, name, namespace=None):
Severity: Minor
Found in apel/db/loader/xml_parser.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

Too many blank lines (2)
Open

    def getText(self, nodes):
Severity: Minor
Found in apel/db/loader/xml_parser.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

Whitespace before ']'
Open

        data = (''.join([ node.nodeType == node.TEXT_NODE and node.data or '' for node in nodes ]))
Severity: Minor
Found in apel/db/loader/xml_parser.py by pep8

Avoid extraneous whitespace.

Avoid extraneous whitespace in these situations:
- Immediately inside parentheses, brackets or braces.
- Immediately before a comma, semicolon, or colon.

Okay: spam(ham[1], {eggs: 2})
E201: spam( ham[1], {eggs: 2})
E201: spam(ham[ 1], {eggs: 2})
E201: spam(ham[1], { eggs: 2})
E202: spam(ham[1], {eggs: 2} )
E202: spam(ham[1 ], {eggs: 2})
E202: spam(ham[1], {eggs: 2 })

E203: if x == 4: print x, y; x, y = y , x
E203: if x == 4: print x, y ; x, y = y, x
E203: if x == 4 : print x, y; x, y = y, x

Whitespace after '['
Open

        data = (''.join([ node.nodeType == node.TEXT_NODE and node.data or '' for node in nodes ]))
Severity: Minor
Found in apel/db/loader/xml_parser.py by pep8

Avoid extraneous whitespace.

Avoid extraneous whitespace in these situations:
- Immediately inside parentheses, brackets or braces.
- Immediately before a comma, semicolon, or colon.

Okay: spam(ham[1], {eggs: 2})
E201: spam( ham[1], {eggs: 2})
E201: spam(ham[ 1], {eggs: 2})
E201: spam(ham[1], { eggs: 2})
E202: spam(ham[1], {eggs: 2} )
E202: spam(ham[1 ], {eggs: 2})
E202: spam(ham[1], {eggs: 2 })

E203: if x == 4: print x, y; x, y = y , x
E203: if x == 4: print x, y ; x, y = y, x
E203: if x == 4 : print x, y; x, y = y, x

Too many blank lines (2)
Open

    def getTagByAttr(self, nodes, name, value, namespace=None):
Severity: Minor
Found in apel/db/loader/xml_parser.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

Expected 2 blank lines, found 1
Open

class XMLParser(object):
Severity: Minor
Found in apel/db/loader/xml_parser.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

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

    d = xml.dom.minidom.parseString(msg_text)
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

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

No space allowed after bracket
Open

        data = (''.join([ node.nodeType == node.TEXT_NODE and node.data or '' for node in nodes ]))
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

Used when a wrong number of spaces is used around an operator, bracket or block opener. data = (''.join([ node.nodeType == node.TEXT_NODE and node.data or '' for node in nodes ])) ^

Method name getAttr doesn't conform to snake_case naming style
Open

    def getAttr(self, node, name, namespace=None):
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

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

No space allowed before bracket
Open

        data = (''.join([ node.nodeType == node.TEXT_NODE and node.data or '' for node in nodes ]))
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

Used when a wrong number of spaces is used around an operator, bracket or block opener. data = (''.join([ node.nodeType == node.TEXT_NODE and node.data or '' for node in nodes ])) ^

Method name getTagByAttr doesn't conform to snake_case naming style
Open

    def getTagByAttr(self, nodes, name, value, namespace=None):
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

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

Method name getText doesn't conform to snake_case naming style
Open

    def getText(self, nodes):
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

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

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

        retList = []
Severity: Info
Found in apel/db/loader/xml_parser.py by pylint

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

There are no issues that match your filters.

Category
Status