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

Give birth to the YANGBear #1428

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

Give birth to the YANGBear #1428

wants to merge 1 commit into from

Conversation

userzimmermann
Copy link
Member

@userzimmermann userzimmermann commented Feb 13, 2017

As new member of https://github.com/OpenNetworkingFoundation I obviously want to add coala code analysis to their repositories :) One of the most important languages there is YANG for data modeling. The new standard for defining network management software functions in future telecommunication infrastructures... But there is no YANGBear yet. Well, here it is...

It uses https://github.com/mbj4668/pyang for linting .yang model files.

It only needs a way to configure if also warnings should be complained about or not, and of course more comprehensive tests, to get out of WIP!

Closes #2032

@sils @Makman2


VALID = requests.get(
"https://raw.githubusercontent.com/OpenNetworkingFoundation/CENTENNIAL"
"/master/models/yang/core-model.yang"
Copy link
Collaborator

Choose a reason for hiding this comment

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

You do not use the preferred quotation marks.

QuotesBear, severity NORMAL, section python.

The issue can be fixed by applying the following patch:

--- a/tests/yang/YANGBearTest.py
+++ b/tests/yang/YANGBearTest.py
@@ -6,7 +6,7 @@
 
 VALID = requests.get(
     "https://raw.githubusercontent.com/OpenNetworkingFoundation/CENTENNIAL"
-    "/master/models/yang/core-model.yang"
+    '/master/models/yang/core-model.yang'
 ).text
 
 



VALID = requests.get(
"https://raw.githubusercontent.com/OpenNetworkingFoundation/CENTENNIAL"
Copy link
Collaborator

Choose a reason for hiding this comment

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

You do not use the preferred quotation marks.

QuotesBear, severity NORMAL, section python.

The issue can be fixed by applying the following patch:

--- a/tests/yang/YANGBearTest.py
+++ b/tests/yang/YANGBearTest.py
@@ -5,7 +5,7 @@
 
 
 VALID = requests.get(
-    "https://raw.githubusercontent.com/OpenNetworkingFoundation/CENTENNIAL"
+    'https://raw.githubusercontent.com/OpenNetworkingFoundation/CENTENNIAL'
     "/master/models/yang/core-model.yang"
 ).text
 

@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!

1 similar comment
@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!

@Makman2
Copy link
Member

Makman2 commented Feb 24, 2017

looks good basically, so why did you mark the PR as WIP? :)

@Makman2
Copy link
Member

Makman2 commented Feb 24, 2017

(sorry btw for not looking at it until now :/ )

@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!

3 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!

@userzimmermann
Copy link
Member Author

@Makman2 I just wanted to add more comprehensive tests and some setting to change the YANG module import search path. But I can also do that in a separate step...

@userzimmermann userzimmermann changed the title WIP: Give birth to the YANGBear Give birth to the YANGBear Mar 19, 2017
@Makman2
Copy link
Member

Makman2 commented Mar 19, 2017

If you think those tests are okay for a first step, then imo it suffices to get a review, and you can add better tests later 👍

@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!

@userzimmermann
Copy link
Member Author

@Makman2 So please review! :)

Meanwhile I also added the new SEE_MORE attribute according to #1136 , coala/coala#3978 , and coala/coala#3979

@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!

Copy link
Member

@jayvdb jayvdb left a comment

Choose a reason for hiding this comment

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

Quite good. I'm a bit worried lxml might become a dependency, but hopefully not before we're made python deps optional.

from coalib.testing.LocalBearTestHelper import verify_local_bear


VALID = requests.get(
Copy link
Member

Choose a reason for hiding this comment

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

Please store this in our repo, or create simple tests if that file cant be licenced as MIT.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jayvdb Or I will create a YANG model for coala itself :D Hmm... Let's see!

Copy link
Member

Choose a reason for hiding this comment

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

still open to address



# several missing module sub-statements
INVALID = """
Copy link
Member

Choose a reason for hiding this comment

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

There will eventually be more than one invalid file. Please give this variable a useful name.

@userzimmermann
Copy link
Member Author

userzimmermann commented Aug 5, 2017

So... Only tests for new yang_search_paths setting missing...

BTW @Makman2 Is this a good setting name? That's a serious question ;) And are there also test helpers for such tasks?

@Makman2
Copy link
Member

Makman2 commented Aug 5, 2017

Looks okay, though what are they used for in YANG? :) A docstring is always good ;)

module coala-model {

namespace "http://coala.io/yang/coala-model";
prefix coala;
Copy link
Member

Choose a reason for hiding this comment

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

These string literals looks ugly....breaks line of flow
Use this https://docs.python.org/2/library/textwrap.html#textwrap.dedent
This is not a compulsory change..It's just a suggestion 😉
Rest LGTM :)

Copy link
Member Author

Choose a reason for hiding this comment

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

@damngamerz It is compulsory! Believe me ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

@damngamerz Actually it's compulsory to move them to separate .yang files! :)

Copy link
Member

@damngamerz damngamerz Sep 7, 2017

Choose a reason for hiding this comment

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

So Im guessing we wont be requiring those string literals...Much better :) 👍

from coalib.testing.LocalBearTestHelper import verify_local_bear


COALA_MODEL = """
Copy link
Member

Choose a reason for hiding this comment

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

capital C :(

Copy link
Member Author

Choose a reason for hiding this comment

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

@meetmangukiya Shame on me! ;P

use_stderr=True,
output_format='regex',
output_regex=r'.*:(?P<line>\d+):\s*(?P<message>.*)')
class YANGBear:
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this class derive from some base bear class ?

Copy link
Member

Choose a reason for hiding this comment

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

Not with @linter ;)

@nemani
Copy link
Member

nemani commented Feb 24, 2018

Hey, tests are failing, should we drop this out of review queue?

@nemani
Copy link
Member

nemani commented Feb 24, 2018

@Makman2 @userzimmermann This PR is almost complete, with just the window part needed to be handled.
I say we mark it as WIP unitill @userzimmermann gets time to finish it :D

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.

9 participants