Skip to content

Commit a7feed8

Browse files
committed
Initial commit
0 parents  commit a7feed8

26 files changed

+1695
-0
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
9+
build:
10+
11+
strategy:
12+
matrix:
13+
python-version:
14+
- "3.7"
15+
- "3.8"
16+
- "3.9"
17+
18+
name: Python ${{ matrix.python-version }}
19+
runs-on: ubuntu-20.04
20+
21+
steps:
22+
23+
- uses: actions/checkout@v2
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v1
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install flake8 pylint mypy pytest coverage pytest-cov mock
34+
35+
- name: Lint with flake8
36+
run: make flake8
37+
38+
- name: Lint with pylint
39+
run: make pylint
40+
41+
- name: Test with mypy
42+
run: make mypy
43+
44+
- name: Test with pytest
45+
run: make test

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.coverage
2+
*.pyc
3+
*.pyo
4+
build/
5+
dist/
6+
weechat_script_lint.egg-info/

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# weechat-script-lint ChangeLog
2+
3+
## Version 0.1.0 (2021-04-19)
4+
5+
- First release.

LICENSE.txt

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Copyright (C) 2021 Sébastien Helleu <flashcode@flashtux.org>
3+
#
4+
# This file is part of weechat-script-lint.
5+
#
6+
# Weechat-script-lint is free software; you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation; either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Weechat-script-lint is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with weechat-script-lint. If not, see <https://www.gnu.org/licenses/>.
18+
#
19+
20+
all: check
21+
22+
check: lint test
23+
24+
lint: flake8 pylint mypy
25+
26+
flake8:
27+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
28+
flake8 . --count --exit-zero --max-complexity=10 --statistics
29+
30+
pylint:
31+
pylint weechat_script_lint
32+
pylint tests/*.py
33+
34+
mypy:
35+
mypy weechat_script_lint
36+
mypy tests/*.py
37+
38+
test:
39+
pytest -vv --cov-report term-missing --cov=weechat_script_lint tests

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# weechat-script-lint
2+
3+
[![PyPI](https://img.shields.io/pypi/v/weechat-script-lint.svg)](https://pypi.org/project/weechat-script-lint/)
4+
[![Build Status](https://github.com/weechat/weechat-script-lint/workflows/CI/badge.svg)](https://github.com/weechat/weechat-script-lint/actions?query=workflow%3A%22CI%22)
5+
6+
Weechat-script-lint is a static analysis tool for WeeChat scripts.
7+
8+
The script just requires Python ≥ 3.7.
9+
10+
## Installation
11+
12+
```
13+
$ pip install weechat-script-lint
14+
```
15+
16+
## Example
17+
18+
```
19+
$ weechat-script-lint script.py
20+
/path/to/script.py:44: info [url_weechat]: URL http://www.weechat.org should be changed to https://weechat.org
21+
/path/to/script.py:45: warning [sys_exit]: sys.exit() causes WeeChat to exit itself
22+
/path/to/script.py:98: error [python2_bin]: the info python2_bin must not be used any more
23+
/path/to/script.py:167: error [missing_infolist_free]: missing call to infolist_free
24+
```
25+
26+
## Copyright
27+
28+
Copyright © 2021 [Sébastien Helleu](https://github.com/flashcode)
29+
30+
This program is free software; you can redistribute it and/or modify
31+
it under the terms of the GNU General Public License as published by
32+
the Free Software Foundation; either version 3 of the License, or
33+
(at your option) any later version.
34+
35+
This program is distributed in the hope that it will be useful,
36+
but WITHOUT ANY WARRANTY; without even the implied warranty of
37+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38+
GNU General Public License for more details.
39+
40+
You should have received a copy of the GNU General Public License
41+
along with this program. If not, see <https://www.gnu.org/licenses/>.

setup.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright (C) 2021 Sébastien Helleu <flashcode@flashtux.org>
4+
#
5+
# This file is part of weechat-script-lint.
6+
#
7+
# Weechat-script-lint is free software; you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# Weechat-script-lint is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with weechat-script-lint. If not, see <https://www.gnu.org/licenses/>.
19+
#
20+
21+
from codecs import open
22+
from setuptools import setup, find_packages
23+
from weechat_script_lint import __version__ as wsl_version
24+
25+
DESCRIPTION = 'Static analysis tool for WeeChat scripts.'
26+
27+
with open('README.md', 'r', 'utf-8') as f:
28+
readme = f.read()
29+
30+
setup(
31+
name='weechat-script-lint',
32+
version=wsl_version,
33+
description=DESCRIPTION,
34+
long_description=readme,
35+
long_description_content_type='text/markdown',
36+
author='Sébastien Helleu',
37+
author_email='flashcode@flashtux.org',
38+
url='https://github.com/weechat/weechat-script-lint',
39+
license='GPL3',
40+
keywords='static analysis weechat script lint',
41+
classifiers=[
42+
'Development Status :: 5 - Production/Stable',
43+
'Environment :: Console',
44+
'Intended Audience :: Developers',
45+
'License :: OSI Approved :: GNU General Public License v3 '
46+
'or later (GPLv3+)',
47+
'Natural Language :: English',
48+
'Operating System :: OS Independent',
49+
'Programming Language :: Python',
50+
'Programming Language :: Python :: 3',
51+
'Topic :: Software Development',
52+
'Topic :: Utilities',
53+
],
54+
packages=find_packages(),
55+
tests_require=['pytest'],
56+
entry_points={
57+
'console_scripts': ['weechat-script-lint=weechat_script_lint:main'],
58+
}
59+
)

tests/__init__.py

Whitespace-only changes.

tests/scripts/not_a_script.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is not a WeeChat script.

tests/scripts/script_all_errors.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Author: Sébastien Helleu
4+
#
5+
6+
"""A WeeChat script."""
7+
8+
import sys
9+
10+
try:
11+
import weechat
12+
except ImportError:
13+
print('This script must be run under WeeChat: http://www.weechat.org')
14+
15+
if __name__ == '__main__':
16+
if weechat.register('script', 'author', '0.1', 'GPL3', 'desc', '', ''):
17+
infolist = weechat.infolist_get('buffer', '', '')
18+
python2_bin = weechat.info_get('python2_bin', '')
19+
sys.exit(1)

0 commit comments

Comments
 (0)