-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from revesansparole/lgtm_option
Lgtm option
- Loading branch information
Showing
11 changed files
with
99 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
lgtm | ||
==== | ||
|
||
This option add the relevant files to let your package use lgtm_, a web service | ||
that will extend pylint_ and check on the validity of your code. This option | ||
install local configuration files but you still need to register by hand. Have a | ||
look at the `Lgtm Documentation`_:: | ||
|
||
(dvlpt)$ pmg add lgtm | ||
(dvlpt)$ pmg rg | ||
|
||
$ git add --all | ||
$ git commit -m"added lgtm support" | ||
$ git push | ||
|
||
|
||
.. _lgtm: https://lgtm.com/ | ||
.. _`Lgtm Documentation`: https://lgtm.com/help/lgtm/about-lgtm | ||
.. _pylint: https://www.pylint.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Lgtm option""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pathlib import Path | ||
|
||
from pkglts.option.doc import fmt_badge | ||
from pkglts.option_object import Option | ||
from pkglts.version import __version__ | ||
|
||
|
||
class OptionLgtm(Option): | ||
def version(self): | ||
return __version__ | ||
|
||
def root_dir(self): | ||
return Path(__file__).parent | ||
|
||
def require_option(self): | ||
return ['github', 'pysetup'] | ||
|
||
def environment_extensions(self, cfg): | ||
owner = cfg['github']['owner'] | ||
project = cfg['github']['project'] | ||
|
||
url = f"https://lgtm.com/projects/g/{owner}/{project}/context:python" | ||
img = f"https://img.shields.io/lgtm/grade/python/g/{owner}/{project}.svg?logo=lgtm&logoWidth=18" | ||
badge = fmt_badge(img, url, "Language grade: Python", cfg['doc']['fmt']) | ||
|
||
return {"badge": badge} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pytest | ||
from pkglts.config_management import Config | ||
from pkglts.option.lgtm.option import OptionLgtm | ||
|
||
|
||
@pytest.fixture() | ||
def opt(): | ||
return OptionLgtm('lgtm') | ||
|
||
|
||
def test_require_option(opt): | ||
assert len(tuple(opt.require_option())) == 2 | ||
|
||
|
||
def test_require(opt): | ||
cfg = Config() | ||
opt.update_parameters(cfg) | ||
|
||
assert len(tuple(opt.require(cfg))) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pkglts.config_management import Config | ||
|
||
|
||
def test_badge(): | ||
cfg = Config(dict(lgtm={}, | ||
doc={'fmt': 'rst'}, | ||
github={'owner': "moi", 'project': "project"})) | ||
cfg.load_extra() | ||
assert ".. image:" in cfg._env.globals['lgtm'].badge |