ola icon indicating copy to clipboard operation
ola copied to clipboard

Makefile lint target?

Open simark opened this issue 10 years ago • 9 comments

Could we add a "make lint" target that would run cpplint.py with the right parameters? It could also run pep8/flake8 for Python, and others for other languages.

simark avatar Mar 31 '15 12:03 simark

That's a great idea.

We may also want to consider git pre-commit hooks to prevent untidy code from being submitted.

nomis52 avatar Mar 31 '15 14:03 nomis52

@Keeper-of-the-Keys This is a bare minimum prerequisite for dropping linting of generated files, if you're feeling keen, given you seem to keep mentioning it.

peternewman avatar Nov 10 '19 23:11 peternewman

Cool, will see what I can do.

Keeper-of-the-Keys avatar Nov 11 '19 00:11 Keeper-of-the-Keys

@stefansiegfried do you fancy tacking this one in another PR too?

Our cpplint.py config is already in Travis.

peternewman avatar Oct 30 '20 13:10 peternewman

@peternewman I would be happy to take this on

stefangs0x90 avatar Oct 30 '20 13:10 stefangs0x90

@peternewman any thoughts on moving the cpplint command from .travis-ci.sh into its own bash script?


/cpplint.py \
    --filter=-legal/copyright,-readability/streams,-runtime/arrays \
    $(find ./ \( -name "*.h" -or -name "*.cpp" \) -and ! \( \
        -wholename "./common/protocol/Ola.pb.*" -or \
        -wholename "./common/rpc/Rpc.pb.*" -or \
        -wholename "./common/rpc/TestService.pb.*" -or \
        -wholename "./common/rdm/Pids.pb.*" -or \
        -wholename "./config.h" -or \
        -wholename "./plugins/*/messages/*ConfigMessages.pb.*" -or \
        -wholename "./tools/ola_trigger/config.tab.*" -or \
        -wholename "./tools/ola_trigger/lex.yy.cpp" \) | xargs)
  if [[ $? -ne 0 ]]; then
    exit 1;
  fi;

Otherwise, it seems a bit cumbersome to do from the Makefile itself

stefangs0x90 avatar Oct 30 '20 16:10 stefangs0x90

I'd probably rather not ship yet another .sh file if we can help it, it also feels a bit clunky to me if we have to do that.

I think you can probably drop the exit code check, I believe any non-zero code should stop the make command (older cpplint used to return the number of errors as the exit code, newer ones just exit 1 anyway I believe).

Ideally you can do some magic within the Makefile to replace all the find stuff given I'd assume we can get a list of files already as we're compiling the code and we can probably find some clever way to filter these bits out too (e.g. tagging them into custom groups which get included).

If it really isn't working have a look at this as an alternative option: https://github.com/OpenLightingProject/ola/blob/master/tools/ola_trigger/Makefile.mk

peternewman avatar Oct 30 '20 22:10 peternewman

@peternewman I wanted to get in a preliminary implementation before Hacktoberfest ends. It still relies on the external script, but I will continue to iterate on this. If autotools makes the list of sources available somewhere that I can pass to cpplint, they have not made that information easy to find. Regarding the Makefile.mk you linked - was there a specific line(s) you could direct me to?

stefangs0x90 avatar Oct 31 '20 05:10 stefangs0x90

@peternewman I wanted to get in a preliminary implementation before Hacktoberfest ends.

Heh, fair enough.

It still relies on the external script, but I will continue to iterate on this.

Great thanks.

If autotools makes the list of sources available somewhere that I can pass to cpplint, they have not made that information easy to find.

Yeah I'm not surprised. See my builtfiles kludge too for the kind of hoops you might have to jump through: https://github.com/OpenLightingProject/ola/blob/master/Makefile.am#L193-L196

Regarding the Makefile.mk you linked - was there a specific line(s) you could direct me to?

https://github.com/OpenLightingProject/ola/blob/master/tools/ola_trigger/Makefile.mk#L74-L80

peternewman avatar Oct 31 '20 11:10 peternewman