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
Rubocop recently landed modules #13261
Rubocop recently landed modules #13261
Conversation
f2be156
to
540b1f1
Compare
version, build = res.headers['Liferay-Portal'].scan( | ||
/^Liferay.*Portal ([\d.]+.*GA\d+).*Build (\d+)/ | ||
).flatten | ||
|
||
unless version && (build = Integer(build) rescue nil) | ||
unless version && (build = begin |
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 formats weirdly IMO. But I think the side effect in a conditional statement that impacts code later on is a bit of a gotcha, and probably lives in the above line to clearly show the side effect that's being made.
Or alternatively I think this can safely be written as (build = build.to_i)
due to the above regex matching only 1 or more digits.
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 agree that to_i
can safely be used here.
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 don't think so:
> nil.to_i
0
Which will return Appears
even when the regex does not match.
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.
Agree that to_i
fix shown above would be better, this one just looks a bit too weird for me imho.
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.
Yeah, I went back and looked at how I wrote this method, and I was grabbing the version and build, simultaneously validating them with the regex, and THEN checking for nil
and any potentially invalid integers (despite regex), all while assigning the build
variable.
My code is getting more dense these days, and I'm getting dumber. I may want to break it up more and comment it better, huh?
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.
Woops didn't see @acammack-r7's feedback before posting mine due to a bug with GitHub not updating whilst I was reviewing. Ignore my comment then.
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 have rather rewritten this section than included RuboCop's terrible formatting.
This conflicts with #13259, which contains manual changes. I would rather run RuboCop against my modules after that lands. Unless your intention is to create more work for me. ;) |
Liferay-Portal: Liferay Community Edition Portal 7.2.0 CE GA1 (Mueller / Build 7200 / June 4, 2019) | ||
[snip] | ||
=end | ||
# Building the Liferay-Portal header: |
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.
Since we're not using block comments, the extra indentation here is even more unnecessary.
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.
Agreed; I think Rubocop was playing it safe here when automatically fixing this.
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 on the fence about block comments, but they're really useful for pasting in structured information.
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.
Also agreed! The docs shed a bit of light on the decision:
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.
Yeah I agree on this one, this seems unnecessary and seems like RuboCop was playing it too safe on this.
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 was not fixed.
* Connection #0 to host 127.0.0.1 left intact | ||
5.0.20wvu@kharak:~$ | ||
=end | ||
# wvu@kharak:~$ curl -vs "http://127.0.0.1:8080/index.php?s=$((RANDOM))" | xmllint --html --xpath 'substring-after(//div[@class = "copyright"]/span[1]/text(), "V")' - |
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.
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.
Not fixed.
uid=33(www-data) gid=33(www-data) groups=33(www-data) | ||
wvu@kharak:~$ | ||
=end | ||
# wvu@kharak:~$ curl -gvs "http://127.0.0.1:8080/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id" | head -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.
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.
Not fixed.
uid=33(www-data) gid=33(www-data) groups=33(www-data) | ||
wvu@kharak:~$ | ||
=end | ||
# wvu@kharak:~$ curl -vsd "_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=id" http://127.0.0.1:8081/index.php?s=captcha | head -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.
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.
Not fixed.
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.
Overall looks good. A few changes I didn't think were right but majority looks good. Sorry for extra comments, most of them were pointing out examples of where I thought things were going right for reference in case anyone wanted to discuss them more.
version, build = res.headers['Liferay-Portal'].scan( | ||
/^Liferay.*Portal ([\d.]+.*GA\d+).*Build (\d+)/ | ||
).flatten | ||
|
||
unless version && (build = Integer(build) rescue nil) | ||
unless version && (build = begin |
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.
Agree that to_i
fix shown above would be better, this one just looks a bit too weird for me imho.
@adfoster-r7: I usually try to maintain some level of consistency between my modules, which leads to situations like #13259. We otherwise don't see much backporting of fixes or changes to old modules. It's seen as risky. If this PR lands, it'll cause a lot of conflicts with the manual work I did in #13259, which I may have to redo. You can either redo the RuboCop run on my modules after the other PR lands, or I can revert your commits to my modules, reapply my changes, and then RuboCop again. I plan to do a RuboCop sweep on my modules, at least the more recent ones we can test, since this train is going to keep rolling. Maybe it'll give me some release. We get more consistency between modules, and I can burn some "foolish consistencies." :) |
Personally I vote for landing the other one first then this one. We get another PR and exploit out, customers are happier, then can go back retrospectively and fix up stuff like this. That other PR has already got a lot of commits as it is so I'd rather land that before it turns into a larger mess than it already is, then apply RuboCop edits after we have finalized the last few sticking points on this PR. Unless we are in favor of doing less PRs in which case it would make sense to do it the other way around and have this land first. |
Thanks, corrected. :) |
We are ready for you, @adfoster-r7. #13259 has landed. :) |
@adfoster-r7 Once merge conflicts are resolved on your end and you've reuploaded, ping me and I'll get this merged into master. |
540b1f1
to
f2c3fc5
Compare
I've rebased + Rubocop'd again 👍 |
@adfoster-r7 Thanks, I'll get this merged into master now :) |
So what was the decision on block comments? Yea or nay? |
I've fixed the outstanding RuboCop mistakes in #13274. Please review and land. |
@wvu-r7 Let's go with nay for now, and if it ends up being a complete pain - we can revise 👍 |
It's actually less of a pain if RuboCop makes the change, haha. Woohoo, automation. |
Let's run Rubocop on recently landed modules to ensure we're still happy with the output. This is a pre-requisite to enabling Rubocop as part of CI runs.
Command ran: