-
Notifications
You must be signed in to change notification settings - Fork 21
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 update #83
rubocop update #83
Conversation
@@ -212,9 +212,9 @@ def set_topology_attributes!(disk, args) | |||
io_size = args["io_size"] | |||
min_grain = args["min_grain"] | |||
align_ofs = args["align_ofs"] | |||
disk.topology.optimal_io_size = io_size.size if io_size && io_size.size > 0 | |||
disk.topology.optimal_io_size = io_size.size if io_size && !io_size.empty? |
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.
Is that really readable? What does empty mean for a size? A house can be empty, but a size?
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.
"empty for a size" ? And what does "size for size" mean as in the original?
Anyway, if something has size greater than zero than it's not empty...
For me it's better readable.
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 size looks strange here, but also as @lslezak mention, io_size.size
It looks like io_size is not good name...maybe it is number of available blocks? what it actually strands for?
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.
io_size is the optimal input/output size of the disk. So it really represents a size. Technically it is a DiskSize
object. The DiskSize
object has a zero?
method but not an empty?
method (which is correct).
AFAIS the change breaks the testsuite:
undefined method `empty?' for <DiskSize 2.00 GiB (2147483648)>:Yast::Storage::DiskSize
LGTM |
LGTM with all checks failing and coverage decreasing by 18%? |
Ouch sorry, overlooked that failures, canceling my LGTM... 😉 |
yep, I know about failing tests. Decrease of coverage is caused by failing tests, but from my initial look, I do not see any obvious reason why it failing, so I plan to wait for storage-ng experts for hints, what that exception and missing methods means as from diff I do not see something wrong. |
Explanation given above, DiskSize has no |
I guess it was changed automatically by Rubocop. So we have two options:
I do not know which one is better in this case... |
yes, automatic one as rubocop expects that when object have |
Assuming I vote to disable that check. |
Um yes, you could define So to get forward - if |
I disabled zero predicate checker and revert change. But it still failing with strange StorageException. Not very helpful to find what exactly failing and why. @ancorgs any idea how to get more info from failed tests? |
The
|
@aschnell ok, I will check all changes for the size |
@jreidinger thanks for updating it. The last unresolved thing is that How should we proceed? I already commented this change above and I do not have a strong opinion here. But I'd probably slightly more prefer the new style with @jreidinger, @aschnell, others... ❓❓ |
Since I'm not the original author of the code I let @shundhammer and @ancorgs have the last word on the |
same for me as long as it is consistent |
BTW, there's a Whatever the rationale behind appending |
@wfeldt rationale behind |
@wfeldt yast, |
@jreidinger, I said I will not comment on |
lngtm, I stongly object to the |
I don't like the |
@@ -300,7 +296,6 @@ def check_param(name, param) | |||
# @param child [String] name of child factory product | |||
# | |||
def check_hierarchy(parent, child) | |||
# rubocop:disable Style/GuardClause |
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.
For consistency, remove also this four lines below
# rubocop:enable Style/GuardClause
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.
it is actually auto correction from rubocop, probably only one half is implemented
end | ||
log.info "Didn't manage to free enough space by resizing Windows" | ||
|
||
log.info "Didn't manage to free enough space by resizing Windows" unless success |
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.
In this method, I think the original version makes the intention of the code more obvious when compared to the modified version. It would be nice if somebody else than @shundhammer or me do the exercise of reading both versions to confirm my feelings.
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.
well, the most readable would be to move whole shrinking to own method, to my taste this method is too long, but I do not like to do big refactoring. BTW I agree with rubocop, that having return inside block is quite tricky workflow, that prevents future refactoring, as moving this block to own method then need special handling for such "long jump".
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.
something like
success = sorted_resizables(parts_by_disk.values.flatten).any?(&:try_shrink)
log.info "Didn't manage to free enough space by resizing Windows" unless success
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.
btw also sorted_resizables(parts_by_disk.values.flatten)
is not nice api, I expect something like disks.partitions_with_windows.reduce(:+).sort_by(&:size).any?
which is more readable for me what it actually probably do ( give me disks, their windows partitions and sort it by size )
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.
Well, it's true that removing the return
from the inner block makes refactoring much easier. You convinced me, let's do the change (we can do the refactoring in a separate PR).
The new syntax won in the case insensitive poll 5:0, so let's use the new syntax. I'm giving my LGTM. The discussion is quite long but it seems everything is resolved now and we can merge it. If I overlooked something then react ASAP please. |
Maybe one more question: Do we agree on the |
Sorry, there was nothing putting me in favor of If you see code where it helps you, fine with me. But I'm against adding it to every constant unconditionally. |
@wfeldt um, it's hard to say where it helps until you actually use it. It's like a But it is still a good practice to have it there as it prevents from programming mistakes when somebody modifies It's the same situation here in Ruby. It's just a bit more tricky because constants are actually not real constants as someone would expect. |
It may not be the most well-argued opinion but... I simply hate that |
@ancorgs: I really like your argument ;-) |
We need an agreement here. I want to merge new code this morning. Should we vote? |
OK, so let's vote, use the reaction button to vote here this way:
|
I'm not much happy about adding the JFYI in the other YaST modules we already switched to the new style, if the old style wins here we might need to update several packages to be consistent... |
To be honest, Ruby constants work as I would have expected (defining an object as a constant does not make it immutable). I can see situations in which, in addition to defining something like a constant, the programmer would want to make explicit that the object is immutable. But making it for every single constant looks overkill (not to say ugly) to me. On the other hand, I don't like to diverge from main style guide. So I'm voting against the change, but in case of draw I could change my vote to break the tie. |
one example where I have to disable it, as I need to modify constant with definining default handler - https://github.com/yast/yast-bootloader/blob/master/src/lib/bootloader/stage1_proposal.rb#L256 |
This aims at changing the ruby language semantics. If and when ruby itself changes, that's another story. But here it's like using And sorry, saying that implementing a change now is ok because it can be easily undone later seems to be a strange kind of argument to me. Moreover, it wouldn't be the first time that people used an anticipated future ruby feature in advance only to be hit by the slightly different real implementation in ruby later. So saying that you can painlessly remove the |
Really, don't we have anything better to do? |
OK, I have disabled the |
lgtm |
On 19.07.2016 13:49, Steffen Winterfeldt wrote:
+1 If this is needed, the interpreter should to it automatically. If it can't do Kind regardsStefan Hundhammer shundhammer@suse.de SUSE Linux GmbH |
@shundhammer interpret will do it automatic from ruby3, but now it is not done due to backward compatibility. |
No description provided.