-
Notifications
You must be signed in to change notification settings - Fork 352
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
[Linter] check frameworks attribute for invalid frameworks #96
Conversation
@@ -381,7 +382,7 @@ def frameworks_invalid?(frameworks) | |||
# @return [Boolean] true if a library ends with `.a`, `.dylib`, or |
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.
Can you update the comment here like you did above for frameworks?
Just a few small comments but awesome job. Can you make sure to add an entry to the CHANGELOG.md file? |
# | ||
def frameworks_invalid?(frameworks) | ||
frameworks.any? { |framework| framework.end_with?('.framework') } | ||
frameworks.any? { |framework| framework =~ /[^a-zA-Z\d]/ } |
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 may be bad ruby conventions (not the ruby expert here), but it might make sense to make the regex a variable so we can easily modify it we need to add/remove stuff from it.
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 it would help to document the code. E.g.
framework_regex = /[^a-zA-Z\d]/
framework ~= framework_regex
But we'll see how it looks when the old lines are added back in.
👍 some great comments there. Ill action them all tomorrow morning. |
@@ -381,7 +382,7 @@ def frameworks_invalid?(frameworks) | |||
# @return [Boolean] true if a library ends with `.a`, `.dylib`, or | |||
# starts with `lib`. | |||
def libraries_invalid?(libs) | |||
libs.any? { |lib| lib.end_with?('.a', '.dylib') || lib.start_with?('lib') } |
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.
same for this please keep it:
This can be changed to:
libs.any? do |lib|
next true if lib.end_with?('.a', '.dylib')
next true if lib.start_with?('lib')
next true if lib =~ /^(lib)|([^a-zA-Z\d])/
false
end
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 logic is covered by the regex. Anything that starts lib
will be covered by ^(lib)
. While not explicit, the [a-zA-Z\d]
picks up any strings with a file extension.
If you want the old behaviour for documentation purposes, then thats fine, but in terms of a matcher it's possibly redundant.
Sorry, I missed this point... so for me the code is fine as it is (without the duplication). The important is that the different tests cases are preserved to clarify the intent of the code and that the documentation at the top of each method explicits mentions the goals. |
@@ -367,10 +367,11 @@ def _validate_compiler_flags(flags) | |||
# @params frameworks [Array<String>] | |||
# The frameworks to be validated | |||
# | |||
# @return [Boolean] true if a framework ends in `.framework` | |||
# @return [Boolean] true if a framework contains any | |||
# non-alphanumeric character |
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 would prefer to be explicit: ... or includes an extension.
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.
@irrationalfab I agree that is much clearer. I'll add that now.
I did not remove any of the tests which test the old behaviour, as they exercise this new code as well. It's better to have too many tests than not enough!
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.
Looks good to me if @irrationalfab agrees 😸 |
Ace thanks for the patch! |
It was my pleasure! Hopefully I can contribute again soon! Thanks for your support. |
Added regex to fail any frameworks/libraries that allow non-alphanumeric characters. Closes #66