stvnksslr/dataslate-parser

View on GitHub

Showing 77 of 100 total issues

Identical blocks of code found in 3 locations. Consider refactoring.
Open

    for roster in list_of_rosters:
        parsed_roster = fetch_and_parse_roster(roster_file=base_path / roster)
        parsed_rosters.append(parsed_roster)
Severity: Minor
Found in src/parsers/killteam/killteam_test.py and 2 other locations - About 30 mins to fix
src/parsers/heresy/heresy_test.py on lines 19..21
src/parsers/w40k/w40k_test.py on lines 18..20

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

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 get_stat_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_stat_type(unit_type):
        for category in STAT_BLOCK_TYPES:
            for stat_type in category.get("categories", {}):
                if unit_type == stat_type:
                    return category.get("name", {})
Severity: Minor
Found in src/models/heresy_unit.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 get_psychic has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_psychic(model):
    search_filter = model.find_all("profile", {"typeName": "Psychic Power"})
    formatted_items = {}

    for item in search_filter:
Severity: Minor
Found in src/parsers/w40k/w40k.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 filter_out_non_unit_entries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def filter_out_non_unit_entries(rule_whitelist, selections):
    dict_of_rules = {}
    for rule in rule_whitelist:
        for idx, selection in enumerate(selections):
            name = selection.attrs.get("name").strip()
Severity: Minor
Found in src/parsers/heresy/heresy.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 get_item_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_item_details(model, search_type):
    search_filter = model.parent.parent.find_all("profile", {"typeName": search_type})
    formatted_items = {}

    for item in search_filter:
Severity: Minor
Found in src/parsers/killteam/killteam.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 get_item_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_item_details(model, search_type):
    search_filter = model.find_all("profile", {"typeName": search_type})
    formatted_items = {}

    for item in search_filter:
Severity: Minor
Found in src/parsers/w40k/w40k.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 sort_units_by_statline has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def sort_units_by_statline(squads):
    toughness = []
    armored = []
    hybrid = []
    parsed_squads = []
Severity: Minor
Found in src/parsers/heresy/heresy.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

Line too long (80 > 79 characters)
Open

    contains and HQ with a command squad + a contemptor + several infantry units
Severity: Minor
Found in src/parsers/heresy/heresy_test.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

    template = "icons_" + data.get("template") if use_icons else data.get("template")
Severity: Minor
Found in src/main.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

    list_of_rosters = [file for file in listdir(str(base_path)) if Path.is_file(base_path / file)]
Severity: Minor
Found in src/parsers/heresy/heresy_test.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 (100 > 79 characters)
Open

    "ERROR": f"battlescribe version not supported please upgrade, the current supported version is "
Severity: Minor
Found in src/utils/constants.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

    list_of_rosters = [file for file in listdir(base_path) if Path.is_file(base_path / file)]
Severity: Minor
Found in src/parsers/w40k/w40k_test.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

    list_of_rosters = [file for file in listdir(base_path) if Path.is_file(base_path / file)]
Severity: Minor
Found in src/parsers/killteam/killteam_test.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 (102 > 79 characters)
Open

        data={"multiple_pages": multiple_pages, "summary_page": summary_page, "use_icons": use_icons},
Severity: Minor
Found in src/main_test.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.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert parsed_roster[0].name == "Gunner Veteran"

Either remove or fill this block of code.
Open

                pass

Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.

Noncompliant Code Example

for i in range(3):
    pass

Exceptions

When a block contains a comment, this block is not considered to be empty.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert len(parsed_roster) == 11

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert parsed_roster[0].name == "Aspiring Champion"

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert bool(parsed_roster)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert len(parsed_roster[0].wargear) == 4
Severity: Info
Found in src/parsers/w40k/w40k_test.py by bandit
Severity
Category
Status
Source
Language