AngellusMortis/game_server_manager

View on GitHub
gs_manager/servers/specific/ark.py

Summary

Maintainability
D
1 day
Test Coverage

File ark.py has 621 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import struct
import zlib
from typing import Any, Dict, List, Optional, Type
from steamfiles import acf
Severity: Major
Found in gs_manager/servers/specific/ark.py - About 1 day to fix

    Cyclomatic complexity is too high in method workshop_download. (23)
    Open

        @require("workshop_id")
        @single_instance
        @click.command(cls=ServerCommandClass)
        @click.option(
            "-w",
    Severity: Minor
    Found in gs_manager/servers/specific/ark.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

    Cyclomatic complexity is too high in method ark_config. (10)
    Open

        @property
        def ark_config(self) -> Dict[str, dict]:
            if self._ark_config is None:
                config = {
                    "map": self.ark_map,
    Severity: Minor
    Found in gs_manager/servers/specific/ark.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

    Cyclomatic complexity is too high in method _create_mod_file. (9)
    Open

        def _create_mod_file(self, mod_dir, mod_file, mod_id):
            self.logger.debug("createing .mod file for {}...".format(mod_id))
            mod_info_file = os.path.join(mod_dir, "mod.info")
            mod_meta_file = os.path.join(mod_dir, "modmeta.info")
            mod_id = int(mod_id)
    Severity: Minor
    Found in gs_manager/servers/specific/ark.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

    Cyclomatic complexity is too high in method _extract_files. (7)
    Open

        def _extract_files(self, mod_dir):
            for root, dirs, files in os.walk(mod_dir):
                for filename in files:
                    if not filename.endswith(".z"):
                        continue
    Severity: Minor
    Found in gs_manager/servers/specific/ark.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

    Cyclomatic complexity is too high in method _z_unpack. (6)
    Open

        def _z_unpack(self, from_path, to_path):
            """
            unpacks .z files downloaded from Steam workshop
    
            adapted from https://github.com/TheCherry/ark-server-manager/blob/master/src/z_unpack.py
    Severity: Minor
    Found in gs_manager/servers/specific/ark.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 install has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def install(
    Severity: Major
    Found in gs_manager/servers/specific/ark.py - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if last_update_time > last_extract_time:
                                  mods_to_update.append(workshop_item)
                  else:
      Severity: Major
      Found in gs_manager/servers/specific/ark.py - About 45 mins to fix

        Function workshop_download has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def workshop_download(
        Severity: Minor
        Found in gs_manager/servers/specific/ark.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if not os.path.isfile(mod_file) or (
                                      workshop_item
                                      not in manifest["AppWorkshop"][
                                          "WorkshopItemsInstalled"
                                      ]
          Severity: Major
          Found in gs_manager/servers/specific/ark.py - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status