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

Shebang #345

Merged
merged 1 commit into from
Feb 18, 2018
Merged

Shebang #345

merged 1 commit into from
Feb 18, 2018

Conversation

lorenzwalthert
Copy link
Collaborator

Aims to close #344. @jjramsey do you think the following regex is appropriate to identify hash-bang statements?

"^#![^\\s].*\\s[^\\s]+\\b.*$"

I first thought about including Rscript too but I think commands other than Rscript can be used in hash-bangs that can execute R, right? So it would be too specific. Alternatively, I thought about only looking at the first line of a file, but that seems to complicate things. The prosed regex will result in a few false positives though (see example #!NEED TO REMOVE THIS, which will be treated as hash-bang statement with the proposed regex).

@codecov-io
Copy link

codecov-io commented Feb 5, 2018

Codecov Report

Merging #345 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #345      +/-   ##
==========================================
+ Coverage    91.3%   91.35%   +0.04%     
==========================================
  Files          30       30              
  Lines        1391     1399       +8     
==========================================
+ Hits         1270     1278       +8     
  Misses        121      121
Impacted Files Coverage Δ
R/rules-spacing.R 96.07% <100%> (ø) ⬆️
R/expr-is.R 96.29% <100%> (+1.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 961ac86...b77932c. Read the comment docs.

@lorenzwalthert
Copy link
Collaborator Author

Ok, I think we can do it differently (better and simpler). Since a shebang statement will always be on the first line and hence a top-level expression, it will have pos_id 1 and we can simplify the regex to

^#!

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.

style_file breaks hash-bang statement at top of script
2 participants