Skip to content

[Infrastructure] Add O2 linter - #7066

Merged
vkucera merged 96 commits into
AliceO2Group:masterfrom
vkucera:linter
Nov 29, 2024
Merged

vkucera merged 96 commits into
AliceO2Group:masterfrom
vkucera:linter

Conversation

@vkucera

@vkucera vkucera commented Jul 30, 2024 •

Copy link
Copy Markdown
Collaborator

Adds a GitHub action that runs a script that checks for O2-specific issues in the code.
The script can run standalone, taking paths of files as arguments.
When running in the GitHub action on the pull_request event, the script tests files modified by the PR and generates error messages as GitHub annotations which appear as comments on the relevant lines or at the top of the file in case of per-file tests.
When running in the GitHub action on the push event, the script tests files modified in the branch w.r.t. the main branch and does not produce annotations.
False positives should be rare but, if any, they can be silenced per line for most of the tests by adding a comment in a given format.

Implements the following tests.

Bad practice:

  • included iostream
  • importing names from the std namespace
  • using directives in headers
  • missing std:: prefix for common names from the std namespace
  • unnecessary use of ROOT entities
  • use of external pi
  • adding/subtracting of 2 pi
  • multiples/fractions of pi for existing equivalent constants
  • use of TDatabasePDG
  • use of hard-coded PDG codes
  • unnecessary call of Mass() for a known PDG code
  • non-O2 logging
  • not using const refs in range-based for loops
  • not using const refs in process function subscriptions
  • usage of workflow options in defineDataProcessing

Documentation:

  • mandatory documentation of C++ files

Naming conventions:

  • functions
  • variables
  • macros
  • constexpr constants
  • namespaces
  • defined types
  • enumerators
  • classes
  • structs
  • O2 columns
  • O2 tables
  • O2 workflows
  • explicit task names
  • workflow files
  • configurables
  • C++ files
  • Python files

PWG-HF specific conventions:

  • PWGHF: names of structs and classes
  • PWGHF: names of task files
  • PWGHF: order of struct members

@github-actions

Copy link
Copy Markdown

This PR has not been updated in the last 30 days. Is it still needed? Unless further action is taken, it will be closed in 5 days.

@github-actions github-actions Bot added the stale label Sep 14, 2024
@vkucera vkucera removed the stale label Sep 14, 2024
@vkucera
vkucera marked this pull request as draft September 19, 2024 17:37
@github-actions

Copy link
Copy Markdown

This PR has not been updated in the last 30 days. Is it still needed? Unless further action is taken, it will be closed in 5 days.

@github-actions github-actions Bot added the stale label Nov 18, 2024
@vkucera vkucera removed the stale label Nov 18, 2024
@ktf

ktf commented Nov 21, 2024

Copy link
Copy Markdown
Member

I like this, why is it still draft?

@vkucera

vkucera commented Nov 21, 2024

Copy link
Copy Markdown
Collaborator Author

I like this, why is it still draft?

Pending discussion with @ddobrigk about what to enforce and what not.

@github-actions github-actions Bot changed the title Add O2 linter [Infrastructure] Add O2 linter Nov 23, 2024
@victor-gonzalez

Copy link
Copy Markdown
Collaborator

I have been running a previous version (two days old) on a few of my source files and found two things so far which I guess haven't been modified

  • I use process in the name of few functions and that requires all parameter being passed by reference, even int or float. I guess I should use the no lint directive in these lines
  • I use using directives in a header but only inside of inline functions. Is this as well not recommended

Thanks @vkucera for the tremendous work!!!

@vkucera

vkucera commented Nov 28, 2024

Copy link
Copy Markdown
Collaborator Author

I have been running a previous version (two days old) on a few of my source files and found two things so far which I guess haven't been modified

* I use `process` in the name of few functions and that requires all parameter being passed by reference, even `int` or `float`. I guess I should use the `no lint` directive in these lines

* I use `using` directives in a header but only inside of `inline` functions. Is this as well not recommended

Thanks @vkucera for the tremendous work!!!

Hi @victor-gonzalez , thanks a lot for the testing and your report. Can you please send me links to the code in question so that I can have a look and see what the linter should do in those cases?

@vkucera
vkucera marked this pull request as ready for review November 28, 2024 21:03
@vkucera

vkucera commented Nov 28, 2024

Copy link
Copy Markdown
Collaborator Author

@ddobrigk Ready to go!

@ddobrigk

Copy link
Copy Markdown
Collaborator

Merging following also discussion on Monday the 25th November. Thanks @vkucera !

@vkucera
vkucera merged commit 8d5e790 into AliceO2Group:master Nov 29, 2024
joachimckh pushed a commit to joachimckh/O2Physics that referenced this pull request Dec 2, 2024
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
wefeng1110 pushed a commit to wefeng1110/O2Physics that referenced this pull request Dec 6, 2024
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
Archita-Dash pushed a commit to Archita-Dash/O2Physics that referenced this pull request Dec 11, 2024
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
hernasab pushed a commit to hernasab/O2Physics that referenced this pull request Dec 20, 2024
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
feisenhu pushed a commit to feisenhu/O2Physics that referenced this pull request Jan 8, 2025
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
@vkucera
vkucera deleted the linter branch January 9, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants