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

Add context to Autoinst issues #400

Merged
merged 5 commits into from Oct 31, 2017
Merged

Add context to Autoinst issues #400

merged 5 commits into from Oct 31, 2017

Conversation

imobachgs
Copy link
Contributor

This PR adds some context to Autoinst issues adding the section where they were detected.

  • PartitioningSection, SectionsWithAttributes (and derived classes) and DriveSection have a reference to its parent.
  • Issues hold a reference to the section where the problem was found.
  • Some minor refactoring regarding issues lists tests was performed.

With those changes in place, AutoYaST will benefit when showing errors information to users.

What is missing?

  • Add the parent method to SkipListSection.
  • Improve sections tests, including one (possible shared) to check the parent method.

@imobachgs imobachgs force-pushed the imo-issues-context branch 2 times, most recently from 407c537 to 6ebe68e Compare October 30, 2017 09:03
@yast yast deleted a comment from coveralls Oct 30, 2017
@imobachgs imobachgs force-pushed the imo-issues-context branch 5 times, most recently from 3a4d1d6 to b790204 Compare October 30, 2017 12:15
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 95.56% when pulling c1b5e71 on imo-issues-context into 1ab5982 on master.

@imobachgs imobachgs changed the title [WIP] Add context to Autoinst issues Add context to Autoinst issues Oct 30, 2017
@yast yast deleted a comment from coveralls Oct 30, 2017
@yast yast deleted a comment from coveralls Oct 30, 2017
@yast yast deleted a comment from coveralls Oct 30, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 95.575% when pulling 6ce6595 on imo-issues-context into 1ab5982 on master.

#
# @return [Integer,String,Symbol] Invalid value
def value
section.send(attr)
Copy link
Member

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 }
Copy link
Member

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.

Copy link
Contributor Author

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})
Copy link
Member

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.

Copy link
Member

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?

Copy link
Contributor Author

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/, "")
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 95.575% when pulling 8f3b1ae on imo-issues-context into 315a9c9 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 95.575% when pulling 8f3b1ae on imo-issues-context into 315a9c9 on master.

Copy link
Member

@jreidinger jreidinger left a 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.

@imobachgs
Copy link
Contributor Author

Thanks!

@imobachgs imobachgs merged commit 4f63cf7 into master Oct 31, 2017
@imobachgs imobachgs deleted the imo-issues-context branch October 31, 2017 09:29
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.

None yet

3 participants