Skip to content

Conversation

lzap
Copy link
Contributor

@lzap lzap commented Mar 20, 2025

Implements message rule check, this isn't a regexp but I feel that is an overkill. Reason for this is that slog is all about structured logging, if you are doing structured logging into a message field, you are probably doing it wrong :-)

Fixes: #65

Cheers.

Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

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

The idea is good, but I think there are room from improvements

Please accept my feedbacks and reviews

@ccoVeille
Copy link
Contributor

Also, I wouldn't add a boolean to enforce only the lowercase.

But a flag with constants (a iota maybe, or string) to control if log message should start with an uppercase letter (as state in the section about error strings in Go convention), a lowercase letter (what you want to do), or simply do not enforce this (that would be the default behavior).

Please read this for the context

@lzap
Copy link
Contributor Author

lzap commented Mar 20, 2025

Done, how about this?

I like that it is not a boolean anymore, this can be expanded to regular expressions later on, as long as it does not match with upper or lower constants it can be treated that way.

Also added iPhone to the test cases, hope you like it more! Cheers.

@lzap lzap force-pushed the lowercase1 branch 2 times, most recently from 251dbda to 32b184f Compare March 20, 2025 15:57
Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

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

Very good implementation

A few suggestions anyway, feel free to cherry pick them

@lzap
Copy link
Contributor Author

lzap commented Mar 21, 2025

Amended your suggestion without changes (only added two missing curly braces and reformatted). Tests are green, the suggestion was correct well done! :-)

@ccoVeille
Copy link
Contributor

Amended your suggestion without changes (only added two missing curly braces and reformatted). Tests are green, the suggestion was correct well done! :-)

Yeah ! ✌️

Good thing to know, the review and feedbacks I made was done with my phone only. 💪 So I'm pretty amazed it worked directly 😅

Please note, I'm a random Gopher, and compulsive code reviewer. I have huge curiosity about linters. Your PR came to solve issue I'm facing too. That's why I jumped in the PR and made feedbacks because I liked your implementation and I had some feedbacks. I enjoyed you were open to them.

Let's now wait for owner or maintainer feedbacks.

@ccoVeille
Copy link
Contributor

If you liked what I suggested and how I helped you, I would like to suggest you to add a Co-authored-by tag in your commit message.

You can take a look here if you never used it

Also, please note you should consider updating your commit message that only mentions "lowercase" feature you started with. I think you should update it.

@lzap
Copy link
Contributor Author

lzap commented Mar 21, 2025

Let's now wait for owner or maintainer feedbacks.

I swear I thought it was you... :-D Cheers.

@lzap lzap force-pushed the lowercase1 branch 2 times, most recently from c1e9f2d to 4bb58de Compare March 22, 2025 07:57
@tmzane
Copy link
Member

tmzane commented Mar 25, 2025

@lzap hey, thanks for the PR (and @ccoVeille for the review), I'll take a look shortly!

Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.14%. Comparing base (a72e66b) to head (1f0d37e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sloglint.go 94.44% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #76      +/-   ##
==========================================
+ Coverage   84.01%   85.14%   +1.13%     
==========================================
  Files           2        2              
  Lines         269      303      +34     
==========================================
+ Hits          226      258      +32     
- Misses         35       37       +2     
  Partials        8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tmzane tmzane self-requested a review March 25, 2025 22:17
@tmzane
Copy link
Member

tmzane commented Mar 25, 2025

Don't worry about the failing linter check, that's on me to fix.

Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
@tmzane
Copy link
Member

tmzane commented Apr 3, 2025

I'm thinking about the following renames:

  • MsgFormat -> MsgStyle (because we're talking about styleguides in the conversations above)
  • upper -> capitalized (because we're only checking the first character)
  • lower -> lowercased (technically, we're not checking the whole message to be in the lowercase but we might add such check in the future)

With this, we can easily add new style options in the future, such as dotted to check whether the message ends with a dot (uncommon, but might be useful).

@lzap @ccoVeille hope you guys don't mind.

Otherwise, LGTM.

@tmzane tmzane changed the title feat: lowercase message feat: implement -msg-style Apr 3, 2025
@tmzane tmzane merged commit 1a45042 into go-simpler:main Apr 3, 2025
10 checks passed
@tmzane
Copy link
Member

tmzane commented Apr 3, 2025

I just pushed v0.10.0, expected to land in the next golangci-lint release.

@lzap lzap deleted the lowercase1 branch April 5, 2025 23:47
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.

Message case rules
3 participants