Skip to content

Conversation

@edhgoose
Copy link
Contributor

@edhgoose edhgoose commented Jan 1, 2022

When using this annotator, it can be hard to identify what file has caused the issue from the GitHub Actions log output, as we'll get something like this:

Warning: Generic.Metrics.CyclomaticComplexity.TooHigh: Function's cyclomatic complexity (15) exceeds 10; consider refactoring the function
Warning: Squiz.PHP.DisallowMultipleAssignments.Found: Assignments must be the first block of code on a line

The GitHub UI doesn't easily translate those messages to the filename that is affected, which means that on large PRs it can be a little tricky just looking at this output to see what file has changed. I have to trawl through the files changed to find the relevant output.

We would find it useful/beneficial to be able to see the filename in the GitHub Actions log too.

It doesn't appear that you can get just the message (e.g. https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-a-warning-message says it just prints the "message" - not the file).

Therefore, I've added a --prepend-filename arg like the --prepend-source to make finding these a little easier. I appreciate it's probably not for everyone (as it'll also put the filename in the message on the annotation) but thought it might be helpful?

@staabm
Copy link
Owner

staabm commented Jan 2, 2022

Thx for the contribution.

I am not sure I understand your root problem.

The messages appear on the affected files before this PR, no?

i am fine with the PR as is - just want to understand the actual problem first.

@edhgoose
Copy link
Contributor Author

edhgoose commented Jan 2, 2022

Hey @staabm - it might be better illustrated with a screenshot:

If I navigate around GitHub Actions, it's very easy to get to this view which tells me there are warnings (I've obfuscated some file names we have here - nothing else):

CleanShot 2022-01-02 at 16 18 37@2x

Or you can easily see the annotations here:
CleanShot 2022-01-02 at 16 20 44@2x

If I've got 10s or hundreds of files changed, it can be really hard to identify where the annotation actually is without browsing through each line of the Files Changed tab - and if I've gone through and marked the files as "Viewed" in the Files Changed tab, it can be a little tedious to go through and find each one.

Therefore, it would be useful to just output the filename.

I've made a small change subsequently after trying this out for a bit, which is only to append the actual filename rather than the full path as that makes the messaging a little less verbsose and still gives a good clue as to which file is the problem - I've updated the tests accordingly.

@edhgoose
Copy link
Contributor Author

edhgoose commented Jan 2, 2022

Here's an example with the change added:

CleanShot 2022-01-02 at 16 38 22@2x

@staabm staabm merged commit 320cc26 into staabm:master Jan 3, 2022
@staabm
Copy link
Owner

staabm commented Jan 3, 2022

makes sense - thx

@staabm
Copy link
Owner

staabm commented Jan 3, 2022

released in https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/tag/1.8

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 this pull request may close these issues.

2 participants