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

Add new rule AG0041 for detecting and converting logs to templates #184

Merged
merged 5 commits into from
Oct 13, 2024

Conversation

joeldickson
Copy link
Contributor

resolves #183

Copy link
Member

@szaboopeeter szaboopeeter left a comment

Choose a reason for hiding this comment

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

Should we cover:

  • String.Format?
  • declaration outside of the logger call (something like this):
image

src/Agoda.Analyzers/AgodaCustom/CustomRulesResources.resx Outdated Show resolved Hide resolved
using System;
{testCase.Usings}

namespace TestNamespace
Copy link
Member

@szaboopeeter szaboopeeter Sep 9, 2024

Choose a reason for hiding this comment

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

Just my 2 cents but I would optimize for readability instead of reduced code duplication in this case. I find the test cases a bit difficult to follow when I need to do string temp laying in my head.

Edit: or maybe just inlining all the usings and privates into the template to reduce noise from the test cases might also help.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I go the other way.
I love to use test cases. Just keep the test function itself really straight-forward and it should be basically:
"Setup", "Input", "expectedOutput" type of tests.

Then you can just read the TestDate and understand all the different tests cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i agree about test readability, i'll fix it up in another MR, there's 2 like this now, so I'll come up with a better solution and fix them all in one go

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 79.24528% with 22 lines in your changes missing coverage. Please review.

Project coverage is 74.42%. Comparing base (63f0bc8) to head (5964215).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...Analyzers/AgodaCustom/AG0041LogTemplateAnalyzer.cs 73.68% 3 Missing and 7 partials ⚠️
...c/Agoda.Analyzers/Properties/Resources.Designer.cs 0.00% 9 Missing ⚠️
...oda.Analyzers/AgodaCustom/AG0041CodeFixProvider.cs 96.55% 1 Missing and 1 partial ⚠️
...yzers/AgodaCustom/CustomRulesResources.Designer.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #184      +/-   ##
==========================================
+ Coverage   74.20%   74.42%   +0.22%     
==========================================
  Files          64       67       +3     
  Lines        2322     2428     +106     
  Branches      273      290      +17     
==========================================
+ Hits         1723     1807      +84     
- Misses        537      551      +14     
- Partials       62       70       +8     

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

@joeldickson joeldickson merged commit 5fe7cb1 into master Oct 13, 2024
5 checks passed
@joeldickson joeldickson changed the title Add new rule AG0040 for detecting and converting logs to templates Add new rule AG0041 for detecting and converting logs to templates Oct 13, 2024
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.

String Interpolation used in logs instead of message template
4 participants