Skip to content

Mattw/bold lint errors#9968

Merged
n1zyy merged 6 commits intomainfrom
mattw/bold-lint-errors
Jan 25, 2024
Merged

Mattw/bold lint errors#9968
n1zyy merged 6 commits intomainfrom
mattw/bold-lint-errors

Conversation

@n1zyy
Copy link
Contributor

@n1zyy n1zyy commented Jan 24, 2024

🎫 Ticket

None. I got annoyed and did this.

🛠 Summary of changes

If this Makefile-implemented linter fails, the error is now in bold red text.

Why? Because it took me way too long to figure out why this run failed when there were no apparent errors.

Notes

  • To demonstrate/test I have an out-of-order method in analytics_events.rb which will be removed before merge (of course).
  • An alternative approach would be to move this whole linter to ruby. I am not volunteering, however.

n1zyy added 3 commits January 24, 2024 11:10
The output is otherwise very easy to miss.

changelog: Internal, Makefile, events ordering linter outputs errors in bold text
def account_delete_visited
track_event('Account Delete visited')
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is moved only to demo the error, and will be undone before merge!

Makefile Outdated
lint_analytics_events_sorted:
@test "$(shell grep '^ def ' app/services/analytics_events.rb)" = "$(shell grep '^ def ' app/services/analytics_events.rb | sort)" \
|| (echo 'Error: methods in analytics_events.rb are not sorted alphabetically' && exit 1)
|| (echo -e '\033[1;31mError: methods in analytics_events.rb are not sorted alphabetically\033[0m' && exit 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

The -e here appears to be output literally in the build output?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But StackOverflow said to use it! :trollface: ;)

I had noticed this locally, and chalked it up to a Mac vs. coreutils issue or something. I wonder if it's actually bash vs. zsh and it's a built-in?

Since it seems extraneous either way I'll remove it!

Are you generally on board with the idea of this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Part of the reason I thought to look is my own history with common commands having different support across OS, so I suspected maybe that's why it wasn't working as expected but could be something that a StackOverflow describes.

Are you generally on board with the idea of this PR?

I think it makes sense if it helps boost visibility of the issue. My main concerns would be (a) applying this ad-hoc rather than across the board, and (b) the color codes hurt the readability of the code. But overall I feel it could be a net-positive 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My main concerns would be (a) applying this ad-hoc rather than across the board, and (b) the color codes hurt the readability of the code. But overall I feel it could be a net-positive 👍

Thanks! I am trying to keep the scope on this as small as I can because I don't have a ton of spare cycles, but I agree with both of these. I was tempted to implement a little echo_red function or something, but it felt a little weird to put that in a Makefile. And making the other echos for errors red should really result in me testing triggering them.

I'll take a screenshot of this without the -e, then back out the change to AnalyticsEvents that was introduced to trigger this, and then merge. If someone is feeling inspired down the road we can extend it.

@n1zyy
Copy link
Contributor Author

n1zyy commented Jan 25, 2024

With the -e removed from echo:

Screenshot 2024-01-24 at 9 07 15 PM

@n1zyy n1zyy merged commit a68df92 into main Jan 25, 2024
@n1zyy n1zyy deleted the mattw/bold-lint-errors branch January 25, 2024 19:35
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