-
Notifications
You must be signed in to change notification settings - Fork 152
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
skip warnings on commented out and empty lines #178
Conversation
Codecov Report
@@ Coverage Diff @@
## main #178 +/- ##
==========================================
+ Coverage 69.68% 69.71% +0.03%
==========================================
Files 190 190
Lines 4364 4379 +15
==========================================
+ Hits 3041 3053 +12
- Misses 1082 1086 +4
+ Partials 241 240 -1
|
pkg/filter/driftignore.go
Outdated
continue | ||
} | ||
if nbArgs == 2 { // We want to ignore a resource (type.id) | ||
if nbArgs == 0 || strings.HasPrefix(line, "#") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nbArgs == 0
is not exactly the check we want to ignore, we want to check if the line is empty
Your if directive should be moved just after line := scanner.Text()
.
We do not want to call readDriftIgnoreLine
for ignored lines.
You can also remove the else
directive as you put a continue.
Something like below should do the job :
line := scanner.Text()
+if line == "" || strings.HasPrefix(line, "#") {
+ logrus.WithFields(logrus.Fields{
+ "line": line,
+ }).Debug("Skipped comment or empty line")
+ continue
+}
typeVal := readDriftIgnoreLine(line)
Hi @sfenman thanks a lot for this PR π , could you update the test suite to reflect your changes too ? ππ» |
Hi @eliecharra, thank you for the comments, I will update it shortly. I guess a new testing function is needed to test about empty and commented out lines explicitly right? |
I think you just have to update We do not want to test that no warning are send at the moment as it will imply to use and inject a custom logger in driftignore logic to be able to mock it. So don't spend too much time on this π |
I've made the changes based on your comments, but I couldn't omit the |
You are missing the It will make the code more readable and avoid unnecessary else nesting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks a lot for this fix @sfenman ππ»
@all-contributors please add @sfenman for code |
I've put up a pull request to add @sfenman! π |
Description
Created a condition to skip empty or commented out (starting with # lines) from checking.