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

Comment out ERB #820

Merged
merged 3 commits into from
Sep 13, 2023
Merged

Comment out ERB #820

merged 3 commits into from
Sep 13, 2023

Conversation

jmthomas
Copy link
Member

closes #776

@jmthomas jmthomas requested a review from ryanmelt September 12, 2023 00:16
@codecov
Copy link

codecov bot commented Sep 12, 2023

Codecov Report

Patch coverage: 85.71% and project coverage change: +0.05% 🎉

Comparison is base (44a09f4) 72.73% compared to head (9588f18) 72.79%.
Report is 14 commits behind head on main.

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     
Flag Coverage Δ
frontend 60.43% <ø> (+0.05%) ⬆️
ruby-api 50.67% <ø> (ø)
ruby-backend 80.61% <85.71%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
openc3/lib/openc3/config/meta_config_parser.rb 82.35% <ø> (ø)
openc3/lib/openc3/models/widget_model.rb 38.80% <0.00%> (ø)
openc3/lib/openc3/models/target_model.rb 72.87% <66.66%> (+0.18%) ⬆️
openc3/lib/openc3/config/config_parser.rb 93.75% <100.00%> (ø)
openc3/lib/openc3/core_ext/string.rb 97.56% <100.00%> (+0.09%) ⬆️
openc3/lib/openc3/models/microservice_model.rb 92.00% <100.00%> (ø)
openc3/lib/openc3/models/tool_model.rb 85.71% <100.00%> (ø)

... and 11 files with indirect coverage changes

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

Copy link
Member

@ryanmelt ryanmelt left a 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?

# If we have a commented out line (starts with #)
# which contains an ERB statement (<% ...)
# then comment out the ERB statement (<%# ...)
if line.strip() =~ /^#.*<%/
Copy link
Member

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.

Copy link
Member Author

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 #%

end # class String
def comment_erb
# Split with -1 to avoid stripping empty strings
output = self.split("\n", -1).collect! do |line|
Copy link
Member

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)

Copy link
Member Author

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

# 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() =~ /^#[^%]*<%/
Copy link
Member

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

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@jmthomas jmthomas merged commit 6bf5558 into main Sep 13, 2023
23 of 24 checks passed
@jmthomas jmthomas deleted the comment_erb branch September 13, 2023 17:59
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.

When commenting out a line with '#', also comment following ERB code '<%#=...%>'
2 participants