Skip to content

Commit

Permalink
Merge pull request #190 from revesansparole/lgtm_option
Browse files Browse the repository at this point in the history
Lgtm option
  • Loading branch information
revesansparole committed Oct 30, 2019
2 parents b9d91fc + bb29f0c commit f01e87c
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 17 deletions.
1 change: 1 addition & 0 deletions .pkglts/pkg_cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"url": "https://github.com/{{ github.owner }}/{{ github.project }}"
},
"landscape": {},
"lgtm": {},
"license": {
"name": "CeCILL-C",
"organization": "OpenAlea",
Expand Down
2 changes: 1 addition & 1 deletion .pkglts/pkg_hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"pysetup": "T0+K8kQXfN7mECB6vXJvk6QJEs6Xo7faTVLCxp8Srjmfd+nUmZAxt35tSIVO3OzPV7vopLZFe6HXGxhYVOONpQ=="
},
"README.rst": {
"doc": "iDN6xYVLM4CQR9BdS4eLSpKDmt0RK1sAdz30NaU2CNBdWl4oKUq52TWdbzCEWuzE/fa4lLfzoUEoWS7NXNfeQg=="
"doc": "vDiY7i9Vzsv5wRcRIO8XLfEWRqURELF9yRbq8l1XfNFGDlM9GgZHihu6UJr69t25xDG6sYYXOLwEx1wnPZoBQA=="
},
"appveyor.yml": {
"appveyor": "5/T0A4182n2Zha7QLgdW4PRGtORCAuPwTw7Fb/sm/DgSRrWuco2aqUpuCV9j9wlmGZ5CM/dnT1zw+Lxn1Iv7Lg=="
Expand Down
1 change: 1 addition & 0 deletions .pkglts/pkg_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"git": "5.1.0",
"github": "5.1.0",
"landscape": "5.1.0",
"lgtm": "5.1.0",
"license": "5.1.0",
"notebook": "5.1.0",
"pypi": "5.1.0",
Expand Down
37 changes: 21 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,44 @@ pkglts
.. {# pkglts, doc
.. image:: https://coveralls.io/repos/github/revesansparole/pkglts/badge.svg?branch=master
:alt: Coverage report status
:target: https://coveralls.io/github/revesansparole/pkglts?branch=master


.. image:: https://readthedocs.org/projects/pkglts/badge/?version=latest
:alt: Documentation status
:target: https://pkglts.readthedocs.io/en/latest/?badge=latest


.. image:: https://travis-ci.org/revesansparole/pkglts.svg?branch=master
:alt: Travis build status
:target: https://travis-ci.org/revesansparole/pkglts


.. image:: https://landscape.io/github/revesansparole/pkglts/master/landscape.svg?style=flat
:alt: Code health status
:target: https://landscape.io/github/revesansparole/pkglts/master


.. image:: https://requires.io/github/revesansparole/pkglts/requirements.svg?branch=master
:alt: Requirements status
:target: https://requires.io/github/revesansparole/pkglts/requirements/?branch=master
.. image:: https://img.shields.io/lgtm/grade/python/g/revesansparole/pkglts.svg?logo=lgtm&logoWidth=18
:alt: Language grade: Python
:target: https://lgtm.com/projects/g/revesansparole/pkglts/context:python


.. image:: https://ci.appveyor.com/api/projects/status/hrwjhn2oe0q4oaf2/branch/master?svg=true
:alt: Appveyor build status
:target: https://ci.appveyor.com/project/revesansparole/pkglts/branch/master


.. image:: https://badge.fury.io/py/pkglts.svg
:alt: PyPI version
:target: https://badge.fury.io/py/pkglts


.. image:: https://ci.appveyor.com/api/projects/status/hrwjhn2oe0q4oaf2/branch/master?svg=true
:alt: Appveyor build status
:target: https://ci.appveyor.com/project/revesansparole/pkglts/branch/master
.. image:: https://requires.io/github/revesansparole/pkglts/requirements.svg?branch=master
:alt: Requirements status
:target: https://requires.io/github/revesansparole/pkglts/requirements/?branch=master


.. image:: https://coveralls.io/repos/github/revesansparole/pkglts/badge.svg?branch=master
:alt: Coverage report status
:target: https://coveralls.io/github/revesansparole/pkglts?branch=master


.. image:: https://travis-ci.org/revesansparole/pkglts.svg?branch=master
:alt: Travis build status
:target: https://travis-ci.org/revesansparole/pkglts
.. #}
.. image:: https://anaconda.org/revesansparole/pkglts/badges/version.svg
Expand Down
19 changes: 19 additions & 0 deletions doc/option/lgtm/main.rst
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/
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
'github = pkglts.option.github.option:OptionGithub',
'gitlab = pkglts.option.gitlab.option:OptionGitlab',
'landscape = pkglts.option.landscape.option:OptionLandscape',
'lgtm = pkglts.option.lgtm.option:OptionLgtm',
'license = pkglts.option.license.option:OptionLicense',
'notebook = pkglts.option.notebook.option:OptionNotebook',
'plugin_project = pkglts.option.plugin_project.option:OptionPluginProject',
Expand Down
1 change: 1 addition & 0 deletions src/pkglts/option/lgtm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Lgtm option"""
26 changes: 26 additions & 0 deletions src/pkglts/option/lgtm/option.py
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.
19 changes: 19 additions & 0 deletions test/test_option/test_lgtm/test_config.py
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
9 changes: 9 additions & 0 deletions test/test_option/test_lgtm/test_handlers.py
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

0 comments on commit f01e87c

Please sign in to comment.