Skip to content

resolves #24 #32

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

Merged
merged 7 commits into from
May 20, 2023
Merged

resolves #24 #32

merged 7 commits into from
May 20, 2023

Conversation

2bndy5
Copy link
Contributor

@2bndy5 2bndy5 commented May 19, 2023

Revised the comments per suggestions from discussion in #24

I also introduced a new --step-summary to allow using GITHUB_STEP_SUMMARY feature. The summary posted has the same content as the --thread-comments feature.

Lastly, pylint has updated their support for python 3.11, so we can now use the latest python version again in CI. I also fixed some other warnings pylint didn't like about using dict(...) instead of literal {...}.

@2bndy5 2bndy5 added the enhancement New feature or request label May 19, 2023
@codecov
Copy link

codecov bot commented May 19, 2023

Codecov Report

Merging #32 (4a5fa3b) into main (35e64f8) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main      #32   +/-   ##
=======================================
  Coverage   81.51%   81.51%           
=======================================
  Files           8        8           
  Lines         714      714           
=======================================
  Hits          582      582           
  Misses        132      132           
Impacted Files Coverage Δ
cpp_linter/thread_comments.py 69.44% <ø> (ø)
cpp_linter/__init__.py 92.95% <100.00%> (+0.10%) ⬆️
cpp_linter/clang_tidy.py 100.00% <100.00%> (ø)
cpp_linter/cli.py 100.00% <100.00%> (ø)
cpp_linter/git.py 78.20% <100.00%> (ø)
cpp_linter/run.py 76.62% <100.00%> (-0.23%) ⬇️

@2bndy5
Copy link
Contributor Author

2bndy5 commented May 19, 2023

The problem that sonar cloud is highlighting is not an easy fix. I need to use regex in that situation. To avoid using regex for that, I would need to replace it with a lot of new code. TBH, I think the warning is a false positive because the pattern is so long.

@shenxianpeng
Copy link
Contributor

Thank you for making #24 happen!!

@shenxianpeng
Copy link
Contributor

shenxianpeng commented May 19, 2023

I have bypassed sonarqube false positive warining, and your chagnes looks good to me. I'd like to test it and see how it looks like in the real repo.

Just one question about naming, should we call it step-summary or job-summary? In this document https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary, the title called job summary, but it used step summary in the example code, your thought?

@2bndy5
Copy link
Contributor Author

2bndy5 commented May 19, 2023

Yeah, I haven't gotten around to running this with the test repo yet... I should've made this PR a draft.

should we call it step-summary or job-summary?

We might not be the only step in the job that uses the GITHUB_STEP_SUMMARY env file. Calling it a "job summary" sounds like cpp-linter is the only step in the job. I chose "step summary" because the MD content that we add to GITHUB_STEP_SUMMARY is output as part of a job's summary.

@shenxianpeng
Copy link
Contributor

It seems the summary is added for job. GITHUB_STEP_SUMMARY is collect each step summary. if in this said might make sense.

image

A example action you shared in #24 https://github.com/EnricoMi/publish-unit-test-result-action#github-actions-job-summary

@2bndy5
Copy link
Contributor Author

2bndy5 commented May 19, 2023

image
It is a single job summary. notice the name of the job is automatically used as a label.

My real point is that other steps can also add content to GITHUB_STEP_SUMMARY that will show up in the same job summary.

example: # the job name
  steps:
    - run: echo "first step" >> $GITHUB_STEP_SUMMARY
    - run: echo "second step" >> $GITHUB_STEP_SUMMARY

This will result in the following job summary:

first step
second step

@shenxianpeng
Copy link
Contributor

Thanks for the detailed reply, it makes more sense now.

@2bndy5
Copy link
Contributor Author

2bndy5 commented May 19, 2023

I'm trying to add a unit test to cover the 1 new line about the "LGTM" comment...

2bndy5 added 2 commits May 19, 2023 07:26
update unit test for added CLI arg
insert blank lines
@2bndy5 2bndy5 force-pushed the issue-24 branch 5 times, most recently from d12d96b to 2fe6b95 Compare May 19, 2023 16:23
@2bndy5
Copy link
Contributor Author

2bndy5 commented May 19, 2023

I think the sonar cloud was trying to say "don't begin regex patterns with .*". But they used so many complex sentences that I had trouble understanding the problem. Its happy now, so I'm back to testing the intentional changes here 😥.

2bndy5 added 2 commits May 19, 2023 10:38
anchor pattern to full line and use more specific pattern
change beginning of patterns
replace regex and fix test code smell
remove duplicate tokens
@2bndy5
Copy link
Contributor Author

2bndy5 commented May 19, 2023

The PR comment looks good. The step-summary is also working as expected.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@shenxianpeng
Copy link
Contributor

The test results look good 👍

Copy link
Contributor Author

@2bndy5 2bndy5 left a comment

Choose a reason for hiding this comment

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

Yeah, I'm ready to move on this. I just went through the changes, and I don't foresee any problems.

@2bndy5 2bndy5 merged commit 5977c76 into main May 20, 2023
@2bndy5 2bndy5 deleted the issue-24 branch May 20, 2023 09:33
@2bndy5
Copy link
Contributor Author

2bndy5 commented May 20, 2023

I'll release minor version bump (v1.6.0) since the step summary is a new feature.

@2bndy5
Copy link
Contributor Author

2bndy5 commented May 20, 2023

The sonar cloud linter is getting a bit ridiculous. It's latest check on main branch failed because:

  1. It doesn't like regex patterns that start with . tokens
  2. Now it says the logger.basicConfig() is a possible security risk.
  3. The "code smells" notes are too strict.

I cannot fix point 1 without a huge rewrite.

NOTE_HEADER = re.compile(r"^(.+):(\d+):(\d+):\s(\w+):(.*)\[(.*)\]$")

The problem with not using .+ to match a filename (and relative path) is that practically any character could be used (which is what . regex token is for). The other .* in this pattern is meant to capture the diagnostic's message which can have any character again. The last .* in this pattern can probably be changed to something more specific since it is supposed to match the tidy-check name.

I can probably fix point 2, but the main concern there is very context specific. I've already review the log usage, so sonar cloud doesn't need to tell me to do it again.

As for point 3, most of warnings are being relaxed via pylint config (like statement counts in a function definition) and others are just not really a problem (like renaming file variable that is namespaced by a function's scope).

TBH, I spent way more time trying to fix things in this PR that were not related to my intentional changes. 👎🏼

@2bndy5 2bndy5 mentioned this pull request Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants