Skip to content

dist/tools/vera++: improve C/C++ support and optimize CI call#15709

Merged
miri64 merged 3 commits intoRIOT-OS:masterfrom
jia200x:pr/vera_cpp_checks
Jan 6, 2021
Merged

dist/tools/vera++: improve C/C++ support and optimize CI call#15709
miri64 merged 3 commits intoRIOT-OS:masterfrom
jia200x:pr/vera_cpp_checks

Conversation

@jia200x
Copy link
Copy Markdown
Member

@jia200x jia200x commented Jan 6, 2021

Contribution description

This commit solves some issues and optimizes the check script in order to run Vera++ only once (instead of twice, one for warnings and one for errors).

In concrete, this PR:

  • Adds a "max-line-length-warn" in L004 (Line too long) to warn when line length > 80. This paremeter is configurable from riot_params.txt. Note that this warning is only a "puts" command, so it won't make Vera++ return error code
  • Modifies T003 (some keywoards should be followed by space) in order to differentiate between C and C++ keywords. This should solve vera++: reports "warning: keyword 'new' not followed by a single space" #15626
  • Removes the first call to Vera++ (for warnings) and remove unused files.

Testing procedure

Issues/PRs references

Fixes #15626

I hope I don't have to touch TCL files again in my whole life

@jia200x jia200x requested a review from miri64 January 6, 2021 10:46
@jia200x jia200x changed the title dist/tools/vera++: add C++ specific tests dist/tools/vera++: improve support C/C++ support and optimize CI call Jan 6, 2021
Comment on lines +27 to 30
proc isCPPKeyword {s} {
global cpp_keywords
return [expr [lsearch $cpp_keywords $s] != -1]
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also check for C keywords?

Copy link
Copy Markdown
Member Author

@jia200x jia200x Jan 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I manually defined the CPP keywords above. The trick is in the if below: if the keyword is a pure C kw or the file is C++ and the keywords is a C++ kw_, then the token is marked

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understood that as much. But C keywords are also C++ keywords, so I would have expected something like

Suggested change
proc isCPPKeyword {s} {
global cpp_keywords
return [expr [lsearch $cpp_keywords $s] != -1]
}
proc isCPPKeyword {s} {
global cpp_keywords
return [expr [lsearch $cpp_keywords $s] != -1] || [isCKeyword $s]
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see below

# Check if it's a C++ file
regexp {\.[ch]pp} $f m
# C keywords are valid in C++ but not the other way around
if {[isCKeyword $tokenName] || ([info exists m] && [isCPPKeyword $tokenName])} {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I guess this || has the same effect?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's what I did. It's just the semantics of the isCPPkeyword function :)

@jia200x jia200x added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Area: CI Area: Continuous Integration of RIOT components labels Jan 6, 2021
@miri64
Copy link
Copy Markdown
Member

miri64 commented Jan 6, 2021

For reference:

Here is the output of the static tests in current master: https://github.com/RIOT-OS/RIOT/runs/1656061171
And here is the output of the static tests with this PR merged: https://github.com/miri64/RIOT/actions/runs/465973948

@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 6, 2021
@jia200x jia200x changed the title dist/tools/vera++: improve support C/C++ support and optimize CI call dist/tools/vera++: improve C/C++ support and optimize CI call Jan 6, 2021
@jia200x jia200x force-pushed the pr/vera_cpp_checks branch from a7d764f to 541d21d Compare January 6, 2021 12:04
@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Jan 6, 2021

For reference:

Perfect! Thanks!
Since we are invoking Vera++ with -w, all errors are shown as warnings. Otherwise, the > 80 warning appears with a "warning" prefix.

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp and there are still valid errors, so ACK!

@miri64 miri64 merged commit 7f83c8c into RIOT-OS:master Jan 6, 2021
@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Jan 6, 2021

thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: CI Area: Continuous Integration of RIOT components CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vera++: reports "warning: keyword 'new' not followed by a single space"

2 participants