diff --git a/apio/commands/lint.py b/apio/commands/lint.py index 11135d25..ab21cfc2 100644 --- a/apio/commands/lint.py +++ b/apio/commands/lint.py @@ -1,37 +1,48 @@ # -*- coding: utf-8 -*- # -- This file is part of the Apio project -# -- (C) 2016-2019 FPGAwars -# -- Authors Jesús Arroyo, Miodrag Milanovic +# -- (C) 2016-2024 FPGAwars +# -- Authors +# -- * Jesús Arroyo (2016-2019) +# -- * Juan Gonzalez (obijuan) (2019-2024) # -- Licence GPLv2 -"""TODO""" +"""Main implementation of APIO LINT command""" import click - from apio.managers.scons import SCons from apio import util +# ------------------ +# -- CONSTANTS +# ------------------ +CMD = "lint" # -- Comand name +ALL = "all" # -- Option +TOP_MODULE = "top_module" # -- Option +NOSTYLE = "nostyle" # -- Option +NOWARN = "nowarn" # -- Option +WARN = "warn" # -- Option +PROJECT_DIR = "project_dir" # -- Option + -# R0913: Too many arguments (6/5) -# pylint: disable=R0913 -# pylint: disable=W0622 -@click.command("lint", context_settings=util.context_settings()) +@click.command(CMD, context_settings=util.context_settings()) @click.pass_context @click.option( "-a", - "--all", + f"--{ALL}", is_flag=True, help="Enable all warnings, including code style warnings.", ) -@click.option("-t", "--top", type=str, metavar="top", help="Set top module.") -@click.option("--nostyle", is_flag=True, help="Disable all style warnings.") @click.option( - "--nowarn", + "-t", "--top-module", type=str, metavar="str", help="Set top module." +) +@click.option(f"--{NOSTYLE}", is_flag=True, help="Disable all style warnings.") +@click.option( + f"--{NOWARN}", type=str, metavar="nowarn", help="Disable specific warning(s).", ) @click.option( - "--warn", type=str, metavar="warn", help="Enable specific warning(s)." + f"--{WARN}", type=str, metavar="warn", help="Enable specific warning(s)." ) @click.option( "-p", @@ -40,13 +51,26 @@ metavar="path", help="Set the target directory for the project.", ) -def cli(ctx, all, top, nostyle, nowarn, warn, project_dir): +def cli(ctx, **kwargs): + # def cli(ctx, all, top, nostyle, nowarn, warn, project_dir): """Lint the verilog code.""" - exit_code = SCons(project_dir).lint( + # -- Extract the arguments + project_dir = kwargs[PROJECT_DIR] + _all = kwargs[ALL] + top_module = kwargs[TOP_MODULE] + nostyle = kwargs[NOSTYLE] + nowarn = kwargs[NOWARN] + warn = kwargs[WARN] + + # -- Create the scons object + scons = SCons(project_dir) + + # -- Lint the project with the given parameters + exit_code = scons.lint( { - "all": all, - "top": top, + "all": _all, + "top": top_module, "nostyle": nostyle, "nowarn": nowarn, "warn": warn,