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
Add context to Autoinst issues #400
Conversation
407c537
to
6ebe68e
Compare
3a4d1d6
to
b790204
Compare
b790204
to
c1b5e71
Compare
# | ||
# @return [Integer,String,Symbol] Invalid value | ||
def value | ||
section.send(attr) |
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, this allow to also call private methods, which is not so nice from my POV. public_send
is not enough?
# TRANSLATORS: 'value' is a generic value (number or string) 'attr' is an AutoYaST element | ||
# name; 'new_value_message' is a short explanation about what should be done with the value. | ||
_("Invalid value '%{value}' for attribute '%{attr}' (%{new_value_message}).") % | ||
{ value: value, attr: attr, new_value_message: new_value_message } |
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.
rubocop is fine with this? I think it usually suggest to use format, but maybe it is here more benevolent.
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.
Yes, it is fine.
@@ -7,6 +7,9 @@ module AutoinstIssues | |||
class Issue | |||
include Yast::I18n | |||
|
|||
# @return [Object] section where the problem was detected (see {AutoinstProfile}) |
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, to be honest documenting only Object as parent is not much helpful. is there any methods on top of pure Object that it have in common? I think for documentation purpose it would be helpful to have class that define common methods for all sections.
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.
currently it looks like at least parent and section_name is must have, not?
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, that's partially true: these classes will only hold a reference to those objects (to be used by others later). But it's true that maybe something like #parent,#section_name
would be better than Object
.
klass_name = self.class.name.split("::").last | ||
klass_name | ||
.gsub(/([a-z])([A-Z])/, "\\1_\\2").downcase | ||
.gsub(/_section\z/, "") |
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.
gsub here is not needed, it can be simple sub or even better .chomp("_section")
@@ -0,0 +1,35 @@ | |||
# encoding: utf-8 |
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.
why file is called profile_examples, when it is section-examples?
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.
Because the module is called AutoinstProfile.
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.
so it is common behavior for everything in given namespace, right?
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, I have renamed to a hopefully a better name :)
Y2Storage::AutoinstProfile::SectionWithAttributes.new | ||
end | ||
|
||
describe ".new_from_hashes" do |
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.
so common method for all sections?
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 general I see it as problem when you want to create new section.
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.
What I want to test is that the parent
is set always when using new_from_hashes
. About the method itself, we have a new_from_hashes
and new_from_storage
to build sections from the profile or from the storage layer.
What is exactly the problem?
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.
my problem is documentation to see what is important and I have to do when I want to create new section.
07bc51a
to
8f3b1ae
Compare
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.
LGTM, even if documentation for sections can be a bit more newcomers friendly.
Thanks! |
This PR adds some context to Autoinst issues adding the section where they were detected.
PartitioningSection
,SectionsWithAttributes
(and derived classes) andDriveSection
have a reference to its parent.With those changes in place, AutoYaST will benefit when showing errors information to users.
What is missing?
parent
method toSkipListSection
.