Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oclint multiple execution and inability to see the output #45

Open
andyinno opened this issue Apr 14, 2022 · 4 comments · May be fixed by #65
Open

oclint multiple execution and inability to see the output #45

andyinno opened this issue Apr 14, 2022 · 4 comments · May be fixed by #65

Comments

@andyinno
Copy link

Hi!

I am trying to configure the pre-commit hook with oclint.

What I am noticing is that while executing the commit the program is executed but...

  • the program seems to run for each file that is changed
  • there's no clear output of what to fix

as an example this is the output that I get from a test application:

oclint...................................................................Failed
- hook id: oclint
- exit code: 5

oclint: error: violations exceed threshold
P1=0[0] P2=0[0] P3=3[0] 

oclint: error: violations exceed threshold
P1=0[0] P2=0[0] P3=2[0] 

oclint: error: violations exceed threshold
P1=0[0] P2=1[0] P3=1[0] 

oclint: error: violations exceed threshold
P1=0[0] P2=0[0] P3=3[0] 

oclint: error: violations exceed threshold
P1=0[0] P2=0[0] P3=4[0] 

oclint: error: violations exceed threshold
P1=0[0] P2=0[0] P3=1[0] 

oclint: error: violations exceed threshold
P1=0[0] P2=2[0] P3=3[0] 

oclint: error: violations exceed threshold
P1=0[0] P2=0[0] P3=1[0]

If I try to attach the html output in the configuration yaml, then the file is always rewritten with the last run. If I execute oclint from command line, then, I have an html file that groups all the outputs from every file.

@pocc
Copy link
Owner

pocc commented Apr 14, 2022

Thanks for reporting this bug. Can you provide an Minimum Reproducible Example, including the .pre-commit-config.yaml?

@andyinno
Copy link
Author

Hi!

sorry for the late reply.
I added a project that reproduce the issue and it is visible here: https://github.com/andyinno/oclind_demo_multiple_run

Things to note:

  • I was unable to reproduce it if I did not added the main.h file.

without the main.h file was added this was the output that I got:

git commit
oclint...................................................................Failed
- hook id: oclint
- exit code: 5

oclint: error: violations exceed threshold
P1=0[0] P2=0[10] P3=2[0]

After the introduction of the main.h file the output changed to this:

oclint...................................................................Failed
- hook id: oclint
- exit code: 5

oclint: error: violations exceed threshold
P1=0[0] P2=0[10] P3=2[0] 

oclint: error: violations exceed threshold
P1=0[0] P2=0[10] P3=1[0]

The commit that was tested was f574e03 so... all the file added to the initial commit.

Does it helps you?

@pocc
Copy link
Owner

pocc commented Apr 16, 2022

So the reason that it goes over every file is that you have fail_fast: false in your .pre-commit-config.yaml.

After running cmake . on your repo, I see this output:

$ oclint *.c *.h Test/*.c -enable-global-analysis -enable-clang-static-analyzer -max-priority-3 0

Clang Static Analyzer Results:

/home/rj/code/oclind_demo_multiple_run/test.c:4:3: Assigned value is garbage or undefined [core.uninitialized.Assign]
/home/rj/code/oclind_demo_multiple_run/test.c:4:7: Value stored to 'a' during its initialization is never read [deadcode.DeadStores]


OCLint Report

Summary: TotalFiles=5 FilesWithViolations=5 P1=0 P2=0 P3=7

/home/rj/code/oclind_demo_multiple_run/main.c:2:10: unused method parameter [unused|P3] The parameter 'argc' is unused.
/home/rj/code/oclind_demo_multiple_run/main.c:2:20: unused method parameter [unused|P3] The parameter 'argv' is unused.
/home/rj/code/oclind_demo_multiple_run/test.c:4:3: short variable name [naming|P3] Length of variable name `a` is 1, which is shorter than the threshold of 3
/home/rj/code/oclind_demo_multiple_run/test2.c:3:11: short variable name [naming|P3] Length of variable name `i` is 1, which is shorter than the threshold of 3
/home/rj/code/oclind_demo_multiple_run/main.h:4:11: short variable name [naming|P3] Length of variable name `i` is 1, which is shorter than the threshold of 3
/home/rj/code/oclind_demo_multiple_run/Test/test_main.c:1:10: unused method parameter [unused|P3] The parameter 'argc' is unused.
/home/rj/code/oclind_demo_multiple_run/Test/test_main.c:1:20: unused method parameter [unused|P3] The parameter 'argv' is unused.

[OCLint (https://oclint.org) v21.05]

oclint: error: violations exceed threshold
P1=0[0] P2=0[10] P3=7[0]

Compare that to pre-commit-hooks, which shows no error output.

$ pre-commit run -a
oclint...................................................................Failed
- hook id: oclint
- exit code: 5

oclint: error: violations exceed threshold
P1=0[0] P2=0[10] P3=2[0]

I should have more time to address this on Sunday.

@andyinno
Copy link
Author

andyinno commented Apr 16, 2022 via email

@djwatson djwatson linked a pull request Oct 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants