How to use the gdtoolkit.linter.lint_code function in gdtoolkit

To help you get started, we’ve selected a few gdtoolkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Scony / godot-gdscript-toolkit / tests / linter / common.py View on Github external
def simple_nok_check(code, check_name, line=2, **kwargs):
    extra_disable = [] if "disable" not in kwargs else kwargs["disable"]
    config_w_disable = DEFAULT_CONFIG.copy()
    config_w_disable.update({"disable": [check_name] + extra_disable})
    assert len(lint_code(code, config_w_disable)) == 0

    config = DEFAULT_CONFIG.copy()
    config.update({"disable": extra_disable})
    outcome = lint_code(code, config)
    assert len(outcome) == 1
    assert outcome[0].name == check_name
    assert outcome[0].line == line
github Scony / godot-gdscript-toolkit / tests / linter / common.py View on Github external
def simple_ok_check(code, **kwargs):
    extra_disable = [] if "disable" not in kwargs else kwargs["disable"]
    config = DEFAULT_CONFIG.copy()
    config.update({"disable": extra_disable})
    outcome = lint_code(code, config)
    assert len(outcome) == 0, outcome
github Scony / godot-gdscript-toolkit / tests / linter / common.py View on Github external
def simple_nok_check(code, check_name, line=2, **kwargs):
    extra_disable = [] if "disable" not in kwargs else kwargs["disable"]
    config_w_disable = DEFAULT_CONFIG.copy()
    config_w_disable.update({"disable": [check_name] + extra_disable})
    assert len(lint_code(code, config_w_disable)) == 0

    config = DEFAULT_CONFIG.copy()
    config.update({"disable": extra_disable})
    outcome = lint_code(code, config)
    assert len(outcome) == 1
    assert outcome[0].name == check_name
    assert outcome[0].line == line
github Scony / godot-gdscript-toolkit / gdtoolkit / linter / __main__.py View on Github external
logging.info("Loaded config:")
    for entry in config.items():
        logging.info(entry)

    for key in DEFAULT_CONFIG:
        if key not in config:
            logging.info(
                "Adding missing entry from defaults: %s", (key, DEFAULT_CONFIG[key])
            )
            config[key] = DEFAULT_CONFIG[key]

    problems_total = 0
    for file_path in arguments[""]:
        with open(file_path, "r") as fh:  # TODO: handle exception
            content = fh.read()
            problems = lint_code(content, config)
            problems_total += len(problems)
            if len(problems) > 0:  # TODO: friendly frontend like in halint
                for problem in problems:
                    print_problem(problem, file_path)

    if problems_total > 0:
        print(
            "Failure: {} problem{} found".format(
                problems_total, "" if problems_total == 1 else "s"
            ),
            file=sys.stderr,
        )
        sys.exit(1)

    print("Success: no problems found")