-
Notifications
You must be signed in to change notification settings - Fork 32
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
Comment out ERB #820
Comment out ERB #820
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #820 +/- ##
==========================================
+ Coverage 72.73% 72.79% +0.05%
==========================================
Files 472 472
Lines 30774 30761 -13
Branches 878 877 -1
==========================================
+ Hits 22384 22393 +9
+ Misses 8295 8275 -20
+ Partials 95 93 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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.
See comment about regex.
Also - This removes the ability to have ERB fill in variables in comments. Is that an acceptable loss? Do we do that anywhere?
openc3/lib/openc3/core_ext/string.rb
Outdated
# If we have a commented out line (starts with #) | ||
# which contains an ERB statement (<% ...) | ||
# then comment out the ERB statement (<%# ...) | ||
if line.strip() =~ /^#.*<%/ |
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.
Should allow whitespace before the # sign.
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.
I'm explicitly not allowing trailing ERB. See comment. Also I added the ability to disable ERB commenting with #%
openc3/lib/openc3/core_ext/string.rb
Outdated
end # class String | ||
def comment_erb | ||
# Split with -1 to avoid stripping empty strings | ||
output = self.split("\n", -1).collect! do |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.
This could just be self.lines instead of split("\n", -1)
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.
I think self.lines
has different behavior than split("\n", -1)
when it comes to empty strings
openc3/lib/openc3/core_ext/string.rb
Outdated
# then comment out the ERB statement (<%# ...). | ||
# We explicitly don't comment out trailing ERB statements | ||
# as that is not typical and is difficult to regex | ||
if line.strip() =~ /^#[^%]*<%/ |
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.
You could also just add \s* to the regex instead of strip. I wonder which is heavier
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
closes #776