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

WIP: XMLBear: Support for style specifications #1187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

namanyadav12
Copy link
Contributor

A format can be specified in the arguments or in the configuration.
The valid args are c14n, c14n11, exc-c14n and oldxml10.
If a style is specified, then the style messages from the bear have MAJOR severity.

Closes #1098

@gitmate-bot
Copy link
Collaborator

Thanks for your contribution!

Reviewing pull requests take really a lot of time and we're all volunteers. Please make sure you go through the following check list and complete them all before pinging someone for a review.

As you learn things over your Pull Request please help others on the chat and on PRs to get their stuff right as well!

xml_schema: path='',
xml_dtd: path_or_url=''):
xml_dtd: path_or_url='',
xml_style: str=''):
Copy link
Member

@jayvdb jayvdb Dec 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of str it should be a restricted list of values checked with a function like path_or_url.

And default should be None, not ''

"""
args = (filename,)
if xml_schema:
args += ('-schema', xml_schema)
if xml_dtd:
args += ('-dtdvalid', xml_dtd)
styles = ('c14n', 'c14n11', 'exc-c14n', 'oldxml10')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONSTANT list, should be a module or class attribute

XMLBear,
valid_files=(valid_xml_file,),
invalid_files=(invalid_xml_chars,),
settings={'xml_style': 'oldxml10'},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This style is not being tested. This test class is identical to XMLBearCorrectedTest , etc.
You need to find an XML style issue, and ensure that the linter bear reports the error that xmllint emits and that its severity is correct.

settings={'xml_style': 'oldxml10'},
tempfile_kwargs={'suffix': '.xml'})

XMLBearInvalidStyleTest = verify_local_bear(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XMLBearInvalidStyleTest -> XMLBearUnrecognisedStyleNameTest

args += ('--' + xml_style,)
self._diff_severity = RESULT_SEVERITY.MAJOR
elif xml_style != '':
self.warn('Invalid xml_style argument ' + xml_style +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be an error -- the user has mistyped the style. coala should not allow invalid configuration.

XMLBear,
valid_files=(valid_xml_file,),
invalid_files=(invalid_xml_chars,),
settings={'xml_style': 'wrong args'},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to confirm that this error is the cause of the failure.
otherwise, some other error could occur and this test look like it has been effective.

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@namanyadav12 namanyadav12 changed the title XMLBear: Support for style specifications [WIP}XMLBear: Support for style specifications Dec 31, 2016
@namanyadav12 namanyadav12 changed the title [WIP}XMLBear: Support for style specifications [WIP]XMLBear: Support for style specifications Dec 31, 2016
@namanyadav12 namanyadav12 changed the title [WIP]XMLBear: Support for style specifications XMLBear: Support for style specifications Dec 31, 2016
"""
style = str(xml_style)
if style not in XMLBear._styles:
logging.error('Unrecognised style ' + style + '. Valid xml'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a warning and you should mention that you just ignore the argument because you're not erroring out, you're just ignoring that part right?

"""
:param xml_schema: ``W3C XML Schema`` file used for validation.
:param xml_dtd: ``Document type Definition (DTD)`` file or
url used for validation.
:param xml_style: ``XML Style Specification`` Relevant args are
c14n, c14n11, exc-c14n and oldxml10.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you include a URL where I can find out more about those cryptic things? Can we maybe ake them less cryptic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to include that info here so the user can find out more about the specs, not me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, ok !! I misunderstood you earlier

"""
args = (filename,)
if xml_schema:
args += ('-schema', xml_schema)
if xml_dtd:
args += ('-dtdvalid', xml_dtd)
if xml_style:
args += (xml_style,)
self._diff_severity = RESULT_SEVERITY.MAJOR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this major? Also if you do this, all the other errors in the diff will have a major severity as well, right? That sounds bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was given in the issue by @jayvdb, you can check it out here #1098

@namanyadav12
Copy link
Contributor Author

@namanyadav12
Copy link
Contributor Author

Also @sils, self._diff_severity = RESULT_SEVERITY.MAJOR is to make sure that If the user has chosen a style in the configuration, the style messages from the bear are treated as "MAJOR" severity errors.
This was given in the issue by @javydb

@NiklasMM
Copy link
Contributor

NiklasMM commented Jan 3, 2017

Please include the links that you gave in the comment, as sils pointet out here

@NiklasMM
Copy link
Contributor

NiklasMM commented Jan 3, 2017

54f9232 needs work

A format can be specified in the arguments or in the configuration.
The valid args are c14n, c14n11, exc-c14n and oldxml10.
If a style is specified, style issues have a MAJOR severity.

Closes coala#1098
@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

7 similar comments
@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@@ -68,7 +91,7 @@ def process_output(self, output, filename, file):
output_regex=self._output_regex),
self.process_output_corrected(
stdout, filename, file,
diff_severity=RESULT_SEVERITY.INFO,
diff_severity=self._diff_severity,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isnt this a thread unsafe operation?
Is that a problem? cc: @Makman2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in praxis it's not (due to python executing everything in several processes), though this is a local variable and shall be used as such. So replace self._diff_severity with just diff_severity 👍

@jayvdb jayvdb changed the title XMLBear: Support for style specifications WIP: XMLBear: Support for style specifications Apr 11, 2017
@jayvdb jayvdb reopened this Apr 11, 2017
@jayvdb
Copy link
Member

jayvdb commented Apr 11, 2017

We've all invested a lot of time into this PR.
Please come back and complete this PR, when you have time.

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

15 similar comments
@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

7 participants