tests/tools/check_source.sh
author Edouard Tisserant
Tue, 21 Feb 2023 11:47:11 +0100
changeset 3732 929276eea252
parent 2547 fc7de3c128cd
permissions -rwxr-xr-x
Runtime: Add RealTime checkbox in Linux target options to enable PREEMPT_RT scheduling.
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     3
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     6
#
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     7
# Copyright (C) 2017: Andrey Skvortsov
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     8
#
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     9
# See COPYING file for copyrights details.
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    10
#
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    11
# This program is free software; you can redistribute it and/or
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    12
# modify it under the terms of the GNU General Public License
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    13
# as published by the Free Software Foundation; either version 2
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    14
# of the License, or (at your option) any later version.
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    15
#
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    16
# This program is distributed in the hope that it will be useful,
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    19
# GNU General Public License for more details.
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    20
#
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    21
# You should have received a copy of the GNU General Public License
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    22
# along with this program; if not, write to the Free Software
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    24
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    25
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    26
exit_code=0
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    27
set_exit_error()
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    28
{
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    29
    if [ $exit_code -eq 0 ]; then
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    30
       exit_code=1
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    31
    fi
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    32
}
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    33
2433
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
    34
version_gt()
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
    35
{
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
    36
    test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
    37
}
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
    38
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    39
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    40
compile_checks()
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    41
{
2016
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
    42
    echo "Syntax checking using python ..."
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
    43
    python --version
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
    44
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    45
    # remove compiled Python files
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    46
    find . -name '*.pyc' -exec rm -f {} \;
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    47
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    48
    for i in $py_files; do
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    49
        # echo $i
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    50
        python -m py_compile $i
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    51
        if [ $? -ne 0 ]; then
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    52
            echo "Syntax error in $i"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    53
            set_exit_error
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    54
        fi
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    55
    done
2016
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
    56
    echo "DONE"
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
    57
    echo ""
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    58
}
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    59
2420
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    60
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    61
python3_compile_checks()
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    62
{
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    63
    echo "Syntax checking using python3 ..."
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    64
    python3 --version
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    65
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    66
    # remove compiled Python files
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    67
    find . -name '*.pyc' -exec rm -f {} \;
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    68
2535
0fab0af57950 Exclude pyjslib.py from python3 syntax correction check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2457
diff changeset
    69
    for i in $py3_files; do
2420
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    70
        # echo $i
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    71
        python3 -m py_compile $i
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    72
        if [ $? -ne 0 ]; then
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    73
            echo "Syntax error in $i"
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    74
            set_exit_error
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    75
        fi
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    76
    done
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    77
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    78
    # remove compiled Python files
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    79
    find . -name '*.pyc' -exec rm -f {} \;
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    80
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    81
    echo "DONE"
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    82
    echo ""
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    83
}
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
    84
2424
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    85
localization_checks()
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    86
{
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    87
    echo "Check correct localization formats"
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    88
    xgettext --version
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    89
    
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    90
    for i in $py_files; do
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    91
        xgettext -s --language=Python --package-name Beremiz --output=/tmp/m.pot $i 2>&1 | grep 'warning'
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    92
        if [ $? -eq 0 ]; then
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    93
            echo "Syntax error in $i"
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    94
            set_exit_error
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    95
        fi
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    96
    done
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    97
    echo "DONE"
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    98
    echo ""
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
    99
}
2420
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
   100
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   101
# pep8 was renamed to pycodestyle
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   102
# detect existed version
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   103
pep8_detect()
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   104
{
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   105
    test -n $pep8 && (which pep8 > /dev/null) && pep8="pep8"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   106
    test -n $pep8 && (which pycodestyle > /dev/null) && pep8="pycodestyle"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   107
    if [ -z $pep8 ]; then
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   108
        echo "pep8/pycodestyle is not found"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   109
        set_exit_error
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   110
    fi
2016
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   111
    echo -n "pep8 version: "
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   112
    $pep8 --version
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   113
}
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   114
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   115
pep8_checks_default()
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   116
{
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   117
    echo "Check basic code-style problems for PEP-8"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   118
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   119
    test -n $pep8 && pep8_detect
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   120
    test -z $pep8 && return
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   121
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   122
    user_ignore=
2438
0f2e5303f212 pep8, ignore W606 'async' and 'await' are reserved keywords starting with Python 3.7
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2437
diff changeset
   123
    user_ignore=$user_ignore,W606  # W606 'async' and 'await' are reserved keywords starting with Python 3.7
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   124
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   125
    # ignored by default,
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   126
    default_ignore=
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   127
    default_ignore=$default_ignore,E121  # E121 continuation line under-indented for hanging indent
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   128
    default_ignore=$default_ignore,E123  # E123 closing bracket does not match indentation of opening bracket’s line
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   129
    default_ignore=$default_ignore,E126  # E126 continuation line over-indented for hanging indent
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   130
    default_ignore=$default_ignore,E133  # E133 closing bracket is missing indentation
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   131
    default_ignore=$default_ignore,E226  # E226 missing whitespace around arithmetic operator
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   132
    default_ignore=$default_ignore,E241  # E241 multiple spaces after ':'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   133
    default_ignore=$default_ignore,E242  # E242 tab after ‘,’
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   134
    default_ignore=$default_ignore,E704  # E704 multiple statements on one line (def)
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   135
    default_ignore=$default_ignore,W503  # W503 line break occurred before a binary operator
2438
0f2e5303f212 pep8, ignore W606 'async' and 'await' are reserved keywords starting with Python 3.7
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2437
diff changeset
   136
    default_ignore=$default_ignore,W504  # W504 line break occurred after a binary operator
0f2e5303f212 pep8, ignore W606 'async' and 'await' are reserved keywords starting with Python 3.7
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2437
diff changeset
   137
    default_ignore=$default_ignore,W505  # W505 doc line too long (82 > 79 characters)
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   138
    ignore=$user_ignore,$default_ignore
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   139
2438
0f2e5303f212 pep8, ignore W606 'async' and 'await' are reserved keywords starting with Python 3.7
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2437
diff changeset
   140
    $pep8 --max-line-length 300 --ignore=$ignore --exclude build $py_files
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   141
    if [ $? -ne 0 ]; then
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   142
        set_exit_error
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   143
    fi
2016
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   144
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   145
    echo "DONE"
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   146
    echo ""
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   147
}
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   148
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   149
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   150
pep8_checks_selected()
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   151
{
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   152
    echo "Check basic code-style problems for PEP-8 (selective)"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   153
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   154
    test -n $pep8 && pep8_detect
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   155
    test -z $pep8 && return
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   156
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   157
    # select checks:
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   158
    user_select=
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   159
    user_select=$user_select,W291   # W291 trailing whitespace
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   160
    user_select=$user_select,E401   # E401 multiple imports on one line
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   161
    user_select=$user_select,E265   # E265 block comment should start with '# '
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   162
    user_select=$user_select,E228   # E228 missing whitespace around modulo operator
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   163
    user_select=$user_select,W293   # W293 blank line contains whitespace
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   164
    user_select=$user_select,E302   # E302 expected 2 blank lines, found 1
2388
13acfd8d33e6 check_source.sh: add E301 check to the list of selected PEP8 errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2251
diff changeset
   165
    user_select=$user_select,E301   # E301 expected 2 blank lines, found 1
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   166
    user_select=$user_select,E261   # E261 at least two spaces before inline comment
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   167
    user_select=$user_select,E271   # E271 multiple spaces after keyword
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   168
    user_select=$user_select,E231   # E231 missing whitespace after ','
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   169
    user_select=$user_select,E303   # E303 too many blank lines (2)
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   170
    user_select=$user_select,E225   # E225 missing whitespace around operator
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   171
    user_select=$user_select,E711   # E711 comparison to None should be 'if cond is not None:'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   172
    user_select=$user_select,E251   # E251 unexpected spaces around keyword / parameter equals
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   173
    user_select=$user_select,E227   # E227 missing whitespace around bitwise or shift operator
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   174
    user_select=$user_select,E202   # E202 whitespace before ')'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   175
    user_select=$user_select,E201   # E201 whitespace after '{'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   176
    user_select=$user_select,W391   # W391 blank line at end of file
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   177
    user_select=$user_select,E305   # E305 expected 2 blank lines after class or function definition, found X
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   178
    user_select=$user_select,E306   # E306 expected 1 blank line before a nested definition, found X
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   179
    user_select=$user_select,E703   # E703 statement ends with a semicolon
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   180
    user_select=$user_select,E701   # E701 multiple statements on one line (colon)
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   181
    user_select=$user_select,E221   # E221 multiple spaces before operator
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   182
    user_select=$user_select,E741   # E741 ambiguous variable name 'l'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   183
    user_select=$user_select,E111   # E111 indentation is not a multiple of four
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   184
    user_select=$user_select,E222   # E222 multiple spaces after operator
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   185
    user_select=$user_select,E712   # E712 comparison to True should be 'if cond is True:' or 'if cond:'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   186
    user_select=$user_select,E262   # E262 inline comment should start with '# '
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   187
    user_select=$user_select,E203   # E203 whitespace before ','
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   188
    user_select=$user_select,E731   # E731 do not assign a lambda expression, use a def
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   189
    user_select=$user_select,W601   # W601 .has_key() is deprecated, use 'in'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   190
    user_select=$user_select,E502   # E502 the backslash is redundant between brackets
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   191
    user_select=$user_select,W602   # W602 deprecated form of raising exception
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   192
    user_select=$user_select,E129   # E129 visually indented line with same indent as next logical line
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   193
    user_select=$user_select,E127   # E127 continuation line over-indented for visual indent
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   194
    user_select=$user_select,E128   # E128 continuation line under-indented for visual indent
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   195
    user_select=$user_select,E125   # E125 continuation line with same indent as next logical line
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   196
    user_select=$user_select,E114   # E114 indentation is not a multiple of four (comment)
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   197
    user_select=$user_select,E211   # E211 whitespace before '['
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   198
    user_select=$user_select,W191   # W191 indentation contains tabs
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   199
    user_select=$user_select,E101   # E101 indentation contains mixed spaces and tabs
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   200
    user_select=$user_select,E124   # E124 closing bracket does not match visual indentation
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   201
    user_select=$user_select,E272   # E272 multiple spaces before keyword
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   202
    user_select=$user_select,E713   # E713 test for membership should be 'not in'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   203
    user_select=$user_select,E122   # E122 continuation line missing indentation or outdented
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   204
    user_select=$user_select,E131   # E131 continuation line unaligned for hanging indent
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   205
    user_select=$user_select,E721   # E721 do not compare types, use 'isinstance()'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   206
    user_select=$user_select,E115   # E115 expected an indented block (comment)
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   207
    user_select=$user_select,E722   # E722 do not use bare except'
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   208
    user_select=$user_select,E266   # E266 too many leading '#' for block comment
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   209
    user_select=$user_select,E402   # E402 module level import not at top of file
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   210
    user_select=$user_select,W503   # W503 line break before binary operator
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   211
2181
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   212
    $pep8 --select $user_select --exclude=build $py_files
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   213
    if [ $? -ne 0 ]; then
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   214
        set_exit_error
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   215
    fi
2016
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   216
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   217
    echo "DONE"
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   218
    echo ""
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   219
}
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   220
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   221
flake8_checks()
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   222
{
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   223
    echo "Check for problems using flake8 ..."
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   224
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   225
    which flake8 > /dev/null
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   226
    if [ $? -ne 0 ]; then
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   227
        echo "flake8 is not found"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   228
        set_exit_error
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   229
        return
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   230
    fi
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   231
2016
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   232
    echo -n "flake8 version: "
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   233
    flake8 --version
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   234
2181
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   235
    flake8 --max-line-length=300  --exclude=build --builtins="_" $py_files
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   236
    if [ $? -ne 0 ]; then
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   237
        set_exit_error
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   238
    fi
2016
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   239
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   240
    echo "DONE"
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   241
    echo ""
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   242
}
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   243
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   244
pylint_checks()
2433
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
   245
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   246
{
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   247
    echo "Check for problems using pylint ..."
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   248
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   249
    which pylint > /dev/null
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   250
    if [ $? -ne 0 ]; then
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   251
        echo "pylint is not found"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   252
        set_exit_error
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   253
        return
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   254
    fi
2016
2a8cd24a14ca Print version information about software used for tests
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
   255
    pylint --version
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   256
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   257
    export PYTHONPATH="$PWD/../CanFestival-3/objdictgen":$PYTHONPATH
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   258
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   259
    disable=
1854
cff5179cc601 fix pylint warning 'C0112(empty-docstring) Empty function docstring'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1853
diff changeset
   260
    # These warnings most likely will not be fixed
cff5179cc601 fix pylint warning 'C0112(empty-docstring) Empty function docstring'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1853
diff changeset
   261
1833
2269739dd098 fix unnecessary lambda and enable corresponding pylint check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1832
diff changeset
   262
    disable=$disable,C0103        # invalid-name
2269739dd098 fix unnecessary lambda and enable corresponding pylint check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1832
diff changeset
   263
    disable=$disable,C0326        # bad whitespace
2269739dd098 fix unnecessary lambda and enable corresponding pylint check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1832
diff changeset
   264
    disable=$disable,W0110        # (deprecated-lambda) map/filter on lambda could be replaced by comprehension
1851
1b8b5324506c fix pylint warning '(old-style-class) Old-style class defined.'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1850
diff changeset
   265
    disable=$disable,W0613        # (unused-argument) Unused argument 'X'
1b8b5324506c fix pylint warning '(old-style-class) Old-style class defined.'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1850
diff changeset
   266
    disable=$disable,W0622        # (redefined-builtin) Redefining built-in
2182
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2181
diff changeset
   267
    disable=$disable,W0621        # (redefined-outer-name) Redefining name 'Y' from outer scope (line X)
1855
f33942053466 fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1854
diff changeset
   268
    disable=$disable,W0122        # (exec-used) Use of exec
f33942053466 fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1854
diff changeset
   269
    disable=$disable,W0123        # (eval-used) Use of eval
1873
e69d7e5aff00 fix pylint warning '(no-init) Class has no __init__ method'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1872
diff changeset
   270
    disable=$disable,I0011        # (locally-disabled) Locally disabling ungrouped-imports (C0412)
1876
995df4804221 fix pylint warning '(expression-not-assigned) Expression "X" is assigned to nothing'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1875
diff changeset
   271
    disable=$disable,R0204        # (redefined-variable-type) Redefinition of current type from X to Y
1878
fb73a6b6622d fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1876
diff changeset
   272
    disable=$disable,R0201        # (no-self-use) Method could be a function
1879
4d81c3bcac82 fix pylint error '(unsubscriptable-object) Value 'X' is unsubscriptable'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1878
diff changeset
   273
    disable=$disable,W0221        # (arguments-differ) Arguments number differs from overridden 'X' method
4d81c3bcac82 fix pylint error '(unsubscriptable-object) Value 'X' is unsubscriptable'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1878
diff changeset
   274
    disable=$disable,C0201        # (consider-iterating-dictionary) Consider iterating the dictionary directly instead of calling .keys()
2410
4e7ebd6ec248 cleanup: pylint, E1310 (bad-str-strip-call) Suspicious argument in str.strip call
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2408
diff changeset
   275
    disable=$disable,W0201        # (attribute-defined-outside-init) Attribute 'X' defined outside __init__
2414
7fad75e5e63d cleanup: pylint, R1701 # (consider-merging-isinstance) Consider merging these isinstance calls to isinstance(CTNLDFLAGS, (str, unicode))
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2413
diff changeset
   276
    disable=$disable,I1101        # (c-extension-no-member) Module 'lxml.etree' has not 'X' member,
7fad75e5e63d cleanup: pylint, R1701 # (consider-merging-isinstance) Consider merging these isinstance calls to isinstance(CTNLDFLAGS, (str, unicode))
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2413
diff changeset
   277
                                  # but source is unavailable. Consider adding this module to extension-pkg-whitelist
7fad75e5e63d cleanup: pylint, R1701 # (consider-merging-isinstance) Consider merging these isinstance calls to isinstance(CTNLDFLAGS, (str, unicode))
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2413
diff changeset
   278
                                  # if you want to perform analysis based on run-time introspection of living objects.
1854
cff5179cc601 fix pylint warning 'C0112(empty-docstring) Empty function docstring'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1853
diff changeset
   279
cff5179cc601 fix pylint warning 'C0112(empty-docstring) Empty function docstring'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1853
diff changeset
   280
    # It'd be nice to fix warnings below some day
cff5179cc601 fix pylint warning 'C0112(empty-docstring) Empty function docstring'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1853
diff changeset
   281
    disable=$disable,C0111        # missing-docstring
cff5179cc601 fix pylint warning 'C0112(empty-docstring) Empty function docstring'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1853
diff changeset
   282
    disable=$disable,W0703        # broad-except
cff5179cc601 fix pylint warning 'C0112(empty-docstring) Empty function docstring'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1853
diff changeset
   283
    disable=$disable,C0301        # Line too long
cff5179cc601 fix pylint warning 'C0112(empty-docstring) Empty function docstring'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1853
diff changeset
   284
    disable=$disable,C0302        # Too many lines in module
2182
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2181
diff changeset
   285
    disable=$disable,W0511        # fixme
1868
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   286
    disable=$disable,R0901        # (too-many-ancestors) Too many ancestors (9/7)
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   287
    disable=$disable,R0902        # (too-many-instance-attributes) Too many instance attributes (10/7)
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   288
    disable=$disable,R0903        # (too-few-public-methods) Too few public methods (0/2)
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   289
    disable=$disable,R0904        # (too-many-public-methods) Too many public methods (41/20)
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   290
    disable=$disable,R0911        # (too-many-return-statements) Too many return statements (7/6)
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   291
    disable=$disable,R0912        # (too-many-branches) Too many branches (61/12)
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   292
    disable=$disable,R0913        # (too-many-arguments) Too many arguments (6/5)
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   293
    disable=$disable,R0914        # (too-many-locals) Too many local variables (18/15)
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   294
    disable=$disable,R0915        # (too-many-statements) Too many statements (57/50)
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   295
    disable=$disable,R0916        # (too-many-boolean-expressions) Too many boolean expressions in if statement (6/5)
1872
866fb3ab8778 fix pylint error "(undefined-variable) Undefined variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1870
diff changeset
   296
    disable=$disable,R0101        # (too-many-nested-blocks) Too many nested blocks (7/5)
1876
995df4804221 fix pylint warning '(expression-not-assigned) Expression "X" is assigned to nothing'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1875
diff changeset
   297
    disable=$disable,R0801        # (duplicate-code) Similar lines in N files
2410
4e7ebd6ec248 cleanup: pylint, E1310 (bad-str-strip-call) Suspicious argument in str.strip call
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2408
diff changeset
   298
    disable=$disable,W0401        # (wildcard-import) Wildcard import 
4e7ebd6ec248 cleanup: pylint, E1310 (bad-str-strip-call) Suspicious argument in str.strip call
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2408
diff changeset
   299
    disable=$disable,W0614        # (unused-wildcard-import), ] Unused import X from wildcard import
4e7ebd6ec248 cleanup: pylint, E1310 (bad-str-strip-call) Suspicious argument in str.strip call
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2408
diff changeset
   300
    disable=$disable,W0212        # (protected-access) Access to a protected member X of a Y class
4e7ebd6ec248 cleanup: pylint, E1310 (bad-str-strip-call) Suspicious argument in str.strip call
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2408
diff changeset
   301
    disable=$disable,E1101        # (no-member) Instance of 'X' has no 'Y' member
4e7ebd6ec248 cleanup: pylint, E1310 (bad-str-strip-call) Suspicious argument in str.strip call
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2408
diff changeset
   302
    
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   303
    enable=
1831
56b48961cc68 fix (old-style-class) Old-style class defined error for most parts of
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1829
diff changeset
   304
    enable=$enable,E1601          # print statement used
2182
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2181
diff changeset
   305
    enable=$enable,C0325          # (superfluous-parens) Unnecessary parens after keyword
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2181
diff changeset
   306
    enable=$enable,W0404          # reimported module
1834
cd42b426028b fix ungrouped imports from package X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1833
diff changeset
   307
    enable=$enable,C0411          # (wrong-import-order) standard import "import x" comes before "import y"
cd42b426028b fix ungrouped imports from package X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1833
diff changeset
   308
    enable=$enable,W0108          # (unnecessary-lambda) Lambda may not be necessary
cd42b426028b fix ungrouped imports from package X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1833
diff changeset
   309
    enable=$enable,C0412          # (ungrouped-imports) Imports from package X are not grouped
1835
7533061a6d82 fix more than one statement on a single line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1834
diff changeset
   310
    enable=$enable,C0321          # (multiple-statements) More than one statement on a single line
1836
d42b6cf00fa6 fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1835
diff changeset
   311
    enable=$enable,W0231          # (super-init-not-called) __init__ method from base class is not called
2182
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2181
diff changeset
   312
    enable=$enable,W0105          # (pointless-string-statement) String statement has no effect
1838
646245c1c0d9 fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1837
diff changeset
   313
    enable=$enable,W0311          # (bad-indentation) Bad indentation. Found 16 spaces, expected 12
1839
a2324624e516 fix pylint warning '(unreachable) Unreachable code'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1838
diff changeset
   314
    enable=$enable,W0101          # (unreachable) Unreachable code
1840
cf5ef4c0deff fix pylint error '(function-redefined) method already defined'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1839
diff changeset
   315
    enable=$enable,E0102          # (function-redefined) method already defined
1841
9fd29e8b1393 fix pylint warning '(global-variable-not-assigned) Using global for 'X' but no assignment is done'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1840
diff changeset
   316
    enable=$enable,W0602          # (global-variable-not-assigned) Using global for 'X' but no assignment is done
1851
1b8b5324506c fix pylint warning '(old-style-class) Old-style class defined.'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1850
diff changeset
   317
    enable=$enable,W0611          # (unused-import) Unused import X
1b8b5324506c fix pylint warning '(old-style-class) Old-style class defined.'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1850
diff changeset
   318
    enable=$enable,C1001          # (old-style-class) Old-style class defined. Problem with PyJS
1852
70c1cc354a8f fix pylint warning '(dangerous-default-value) Dangerous default value {} as argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1851
diff changeset
   319
    enable=$enable,W0102          # (dangerous-default-value) Dangerous default value {} as argument
1854
cff5179cc601 fix pylint warning 'C0112(empty-docstring) Empty function docstring'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1853
diff changeset
   320
    enable=$enable,C0112          # (empty-docstring)
1855
f33942053466 fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1854
diff changeset
   321
    enable=$enable,W0631          # (undefined-loop-variable) Using possibly undefined loop variable 'X'
1856
c2cba67145eb fix error found by pylint 'W0104(pointless-statement) Statement seems to have no effect'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1855
diff changeset
   322
    enable=$enable,W0104          # (pointless-statement) Statement seems to have no effect
1857
524ff4dbb7d9 remove old code useless code found by pylint "(unnecessary-pass) Unnecessary pass statement"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1856
diff changeset
   323
    enable=$enable,W0107          # (unnecessary-pass) Unnecessary pass statement
1858
4c5156dee87a fix pylint warning '(import-self) Module import itself'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1857
diff changeset
   324
    enable=$enable,W0406          # (import-self) Module import itself
1859
1df77c809257 fix pylint warning '(wrong-import-position) Import "import X" should be placed at the top of the module'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1858
diff changeset
   325
    enable=$enable,C0413          # (wrong-import-position) Import "import X" should be placed at the top of the module
1860
4eeddef7f973 fix format string argument error found by pylint '(too-many-format-args) Too many arguments for format string'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1859
diff changeset
   326
    enable=$enable,E1305          # (too-many-format-args) Too many arguments for format string
1861
410a3bcbeb29 fix pylint warning '(misplaced-bare-raise) The raise statement is not inside an except clause'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1860
diff changeset
   327
    enable=$enable,E0704          # (misplaced-bare-raise) The raise statement is not inside an except clause
1862
c4ba411f8c89 fix pylint warning '(unidiomatic-typecheck) Using type() instead of isinstance() for a typecheck'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1861
diff changeset
   328
    enable=$enable,C0123          # (unidiomatic-typecheck) Using type() instead of isinstance() for a typecheck.
1865
0bd5b3099144 fix pylint warning "(no-value-for-parameter) No value for argument 'X' in function call"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1863
diff changeset
   329
    enable=$enable,E0601          # (used-before-assignment) Using variable 'X' before assignment
0bd5b3099144 fix pylint warning "(no-value-for-parameter) No value for argument 'X' in function call"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1863
diff changeset
   330
    enable=$enable,E1120          # (no-value-for-parameter) No value for argument 'X' in function call
1866
9d1e68d557bf fix pylint error '(bad-except-order) Bad except clauses order (X is an ancestor class of Y)'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1865
diff changeset
   331
    enable=$enable,E0701          # (bad-except-order) Bad except clauses order (X is an ancestor class of Y)
1867
418777c1fbc7 fix pylint error "(no-name-in-module) No name 'X' in module 'Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1866
diff changeset
   332
    enable=$enable,E0611          # (no-name-in-module) No name 'X' in module 'Y'
1868
616c3f4bcbcb fix pylint error '(no-self-argument) Method should have "self" as first argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1867
diff changeset
   333
    enable=$enable,E0213          # (no-self-argument) Method should have "self" as first argument
1869
49cdd843c006 fix pylint error '(import-error) Unable to import X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1868
diff changeset
   334
    enable=$enable,E0401          # (import-error) Unable to import 'X'
1870
4d070115b552 fix pylint error '(too-many-function-args) Too many positional arguments for function call'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1869
diff changeset
   335
    enable=$enable,E1121          # (too-many-function-args) Too many positional arguments for function call
1873
e69d7e5aff00 fix pylint warning '(no-init) Class has no __init__ method'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1872
diff changeset
   336
    enable=$enable,W0232          # (no-init) Class has no __init__ method
1875
62aaabbf8812 fix pylint warning '(redefine-in-handler) Redefining name 'X' from outer scope (line Y) in exception handler'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1873
diff changeset
   337
    enable=$enable,W0233          # (non-parent-init-called) __init__ method from a non direct base class 'X' is called
62aaabbf8812 fix pylint warning '(redefine-in-handler) Redefining name 'X' from outer scope (line Y) in exception handler'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1873
diff changeset
   338
    enable=$enable,W0601          # (global-variable-undefined) Global variable 'X' undefined at the module level
2411
3a883a76abe0 cleanup: pylint, W0111 # (assign-to-new-keyword) Name async will become a keyword in Python 3.7
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2410
diff changeset
   339
    enable=$enable,W0111          # (assign-to-new-keyword) Name async will become a keyword in Python 3.7
1875
62aaabbf8812 fix pylint warning '(redefine-in-handler) Redefining name 'X' from outer scope (line Y) in exception handler'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1873
diff changeset
   340
    enable=$enable,W0623          # (redefine-in-handler) Redefining name 'X' from outer scope (line Y) in exception handler
2421
a5994ee1f6a7 cleanup: pylint, W0109 # (duplicate-key) Duplicate key 'X' in dictionary
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2420
diff changeset
   341
    enable=$enable,W0109          # (duplicate-key) Duplicate key 'X' in dictionary
2410
4e7ebd6ec248 cleanup: pylint, E1310 (bad-str-strip-call) Suspicious argument in str.strip call
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2408
diff changeset
   342
    enable=$enable,E1310          # (bad-str-strip-call) Suspicious argument in str.strip call
2412
22b1879a3c15 cleanup: pylint, E1300 # (bad-format-character) Unsupported format character '"' (0x22) at index 17
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2411
diff changeset
   343
    enable=$enable,E1300          # (bad-format-character) Unsupported format character '"' (0x22) at index 17
2413
803daf19a1b5 cleanup: pylint, E1304 # (missing-format-string-key) Missing key 'X_name' in format string dictionary
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2412
diff changeset
   344
    enable=$enable,E1304          # (missing-format-string-key) Missing key 'X_name' in format string dictionary
2414
7fad75e5e63d cleanup: pylint, R1701 # (consider-merging-isinstance) Consider merging these isinstance calls to isinstance(CTNLDFLAGS, (str, unicode))
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2413
diff changeset
   345
    enable=$enable,R1701          # (consider-merging-isinstance) Consider merging these isinstance calls to isinstance(CTNLDFLAGS, (str, unicode))
2415
f7d8891fe708 cleanup: pylint, R1704 # (redefined-argument-from-local) Redefining argument with the local name 'Y'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2414
diff changeset
   346
    enable=$enable,R1704          # (redefined-argument-from-local) Redefining argument with the local name 'Y'
1878
fb73a6b6622d fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1876
diff changeset
   347
    enable=$enable,W0106          # (expression-not-assigned) Expression "X" is assigned to nothing
2408
23978e5b039a enable etherlab checks
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2388
diff changeset
   348
    enable=$enable,E1136          # (unsubscriptable-object) Value 'X' is unsubscriptable
23978e5b039a enable etherlab checks
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2388
diff changeset
   349
    enable=$enable,E0602          # (undefined-variable) Undefined variable 'X'
23978e5b039a enable etherlab checks
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2388
diff changeset
   350
    enable=$enable,W1618          # (no-absolute-import) import missing `from __future__ import absolute_import`
23978e5b039a enable etherlab checks
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2388
diff changeset
   351
    enable=$enable,W0403          # (relative-import) Relative import 'Y', should be 'X.Y '
23978e5b039a enable etherlab checks
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2388
diff changeset
   352
    enable=$enable,W0612          # (unused-variable) Unused variable 'X'
1878
fb73a6b6622d fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1876
diff changeset
   353
    enable=$enable,C0330          # (bad-continuation) Wrong hanging indentation before block
2417
316ee9fff395 cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2415
diff changeset
   354
    enable=$enable,R0123          # (literal-comparison) Comparison to literal
2431
6923074540dd python3 support: pylint, W1648 # (bad-python3-import) Module moved in Python 3
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2424
diff changeset
   355
6923074540dd python3 support: pylint, W1648 # (bad-python3-import) Module moved in Python 3
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2424
diff changeset
   356
    # python3 compatibility checks
6923074540dd python3 support: pylint, W1648 # (bad-python3-import) Module moved in Python 3
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2424
diff changeset
   357
    enable=$enable,W1648          # (bad-python3-import) Module moved in Python 3
2432
dbc065a2f7a5 python3 support: pylint, W1613 # (xrange-builtin) xrange built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2431
diff changeset
   358
    enable=$enable,W1613          # (xrange-builtin) xrange built-in referenced
2434
07f48018b6f5 python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2433
diff changeset
   359
    enable=$enable,W1612          # (unicode-builtin) unicode built-in referenced
2440
45b43f275ca1 python3 support: pylint, W1601 # (apply-builtin) apply built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2438
diff changeset
   360
    enable=$enable,W1619          # (old-division) division w/o __future__ statement
45b43f275ca1 python3 support: pylint, W1601 # (apply-builtin) apply built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2438
diff changeset
   361
    enable=$enable,W1601          # (apply-builtin) apply built-in referenced
2441
c553769a65af python3 support: pylint, W1659 # (xreadlines-attribute) Accessing a removed xreadlines attribute
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2440
diff changeset
   362
    enable=$enable,W1659          # (xreadlines-attribute) Accessing a removed xreadlines attribute
2442
b13f021c68a5 python3 support: pylint, W1607 # (file-builtin) file built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2441
diff changeset
   363
    enable=$enable,W1607          # (file-builtin) file built-in referenced
2443
75a274023970 python3 support: pylint, W1606 # (execfile-builtin) execfile built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2442
diff changeset
   364
    enable=$enable,W1606          # (execfile-builtin) execfile built-in referenced
2444
235f847be37e python3 support: pylint, W1629 # (nonzero-method) __nonzero__ method defined
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2443
diff changeset
   365
    enable=$enable,W1629          # (nonzero-method) __nonzero__ method defined
2445
4f7abbc8506f python3 support: pylint,W1602 # (basestring-builtin) basestring built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2444
diff changeset
   366
    enable=$enable,W1602          # (basestring-builtin) basestring built-in referenced
2446
922f0d84f869 python3 support: pylint, W1646 # (invalid-str-codec) non-text encoding used in str.decode
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2445
diff changeset
   367
    enable=$enable,W1646          # (invalid-str-codec) non-text encoding used in str.decode
2447
1c04a50dc7ff python3 support: pylint, W1645 # (exception-message-attribute) Exception.message removed in Python 3
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2446
diff changeset
   368
    enable=$enable,W1645          # (exception-message-attribute) Exception.message removed in Python 3
2448
1367b796e129 python3 support: pylint, W1649 # (deprecated-string-function) Accessing a deprecated function on the string module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2447
diff changeset
   369
    enable=$enable,W1649          # (deprecated-string-function) Accessing a deprecated function on the string module
2449
b0560adec4b7 python3 support: pylint, W1651 (deprecated-itertools-function) Accessing a deprecated function on the itertools module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2448
diff changeset
   370
    enable=$enable,W1651          # (deprecated-itertools-function) Accessing a deprecated function on the itertools module
2450
5024c19ca8f0 python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2449
diff changeset
   371
    enable=$enable,W1652          # (deprecated-types-field) Accessing a deprecated fields on the types module
2451
6d1bf321fb89 python3 support: pylint, W1611 # (standarderror-builtin) StandardError built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2450
diff changeset
   372
    enable=$enable,W1611          # (standarderror-builtin) StandardError built-in referenced
2452
2f2b2152580f python3 support: pylint, W1624 # (indexing-exception) Indexing exceptions will not work on Python 3
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2451
diff changeset
   373
    enable=$enable,W1624          # (indexing-exception) Indexing exceptions will not work on Python 3
2453
9900a8df922f python3 support: pylint, W1625 # (raising-string) Raising a string exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2452
diff changeset
   374
    enable=$enable,W1625          # (raising-string) Raising a string exception
2454
2e5acbded4a1 python3 support: pylint, W1622 # (next-method-called) Called a next() method on an object
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2453
diff changeset
   375
    enable=$enable,W1622          # (next-method-called) Called a next() method on an object
2455
80b225e9a6b6 python3 support: pylint, W1653 # (next-method-defined) next method defined
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2454
diff changeset
   376
    enable=$enable,W1653          # (next-method-defined) next method defined
2456
7373e3048167 python3 support: pylint,W1610 # (reduce-builtin) reduce built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2455
diff changeset
   377
    enable=$enable,W1610          # (reduce-builtin) reduce built-in referenced
2457
9deec258ab1a python3 support: pylint, W1633 # (round-builtin) round built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2456
diff changeset
   378
    enable=$enable,W1633          # (round-builtin) round built-in referenced
1828
396da88d7b5c fix unnecessary parens after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1827
diff changeset
   379
    # enable=
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   380
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   381
    options=
2433
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
   382
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
   383
    ver=$(pylint --version 2>&1 | grep pylint  | awk '{ print $2 }')
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
   384
    if version_gt $ver '1.6.8'; then
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
   385
	echo "Use multiple threads for pylint"
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
   386
	options="$options --jobs=0 "
2e8bf28a8909 Use multiple processes to speed up pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2432
diff changeset
   387
    fi
1827
b8b47f9b5e56 enable pylint checker
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1786
diff changeset
   388
    options="$options --rcfile=.pylint"
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   389
    # options="$options --py3k"   # report errors for Python 3 porting
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   390
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   391
    if [ -n "$enable" ]; then
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   392
        options="$options --disable=all"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   393
        options="$options --enable=$enable"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   394
    else
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   395
        options="$options --disable=$disable"
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   396
    fi
1827
b8b47f9b5e56 enable pylint checker
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1786
diff changeset
   397
    # echo $options
b8b47f9b5e56 enable pylint checker
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1786
diff changeset
   398
2182
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2181
diff changeset
   399
    echo $py_files | xargs pylint $options
2181
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   400
    if [ $? -ne 0 ]; then
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   401
        set_exit_error
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   402
    fi
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   403
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   404
    echo "DONE"
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   405
    echo ""
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   406
}
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   407
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   408
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   409
get_files_to_check()
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   410
{
2408
23978e5b039a enable etherlab checks
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2388
diff changeset
   411
    py_files=$(find . -name '*.py' -not -path '*/build/*')
2241
e762e234181d Add information how to make shelve command work with check_source.sh called from hg hook
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2184
diff changeset
   412
    if [ -e .hg/skiphook ]; then
e762e234181d Add information how to make shelve command work with check_source.sh called from hg hook
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2184
diff changeset
   413
	echo "Skipping checks in the hook ..."
e762e234181d Add information how to make shelve command work with check_source.sh called from hg hook
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2184
diff changeset
   414
	exit 0
e762e234181d Add information how to make shelve command work with check_source.sh called from hg hook
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2184
diff changeset
   415
    fi
2181
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   416
    if [ "$1" = "--only-changes" ]; then
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   417
        if which hg > /dev/null; then
2184
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   418
            if [ ! -z "$HG_NODE" ]; then
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   419
                hg_change="--change $HG_NODE"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   420
                msg="for commit $HG_NODE"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   421
            else
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   422
                hg_change=""
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   423
                msg="in local repository"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   424
            fi
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   425
            echo "Only changes ${msg} will be checked"
2181
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   426
            echo ""
2184
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   427
            py_files=$(hg status -m -a -n -I '**.py' $hg_change)
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   428
            if [ $? -ne 0 ]; then
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   429
                exit 1;
2183
63591802d3e2 check_source.sh: handle case if there are no files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   430
            fi
63591802d3e2 check_source.sh: handle case if there are no files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   431
       fi
2181
52630996e51b Add command line argument to run linter only on changed files
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2016
diff changeset
   432
    fi
2184
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   433
    if [ "$1" = "--files-to-check" ]; then
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   434
        list="$2"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   435
        if [ -z "$list" ]; then
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   436
            echo "--files-to-check requires filename as argument"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   437
            print_help
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   438
        fi
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   439
        if [ -e "$list" ]; then
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   440
            py_files=$(cat $2 | grep '\.py$')
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   441
        fi
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   442
    fi
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   443
    if [ -z "$py_files" ]; then
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   444
        echo "No files to check"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   445
        exit 0;
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   446
    fi
2535
0fab0af57950 Exclude pyjslib.py from python3 syntax correction check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2457
diff changeset
   447
2547
fc7de3c128cd check_source.sh: fix sed error: -e expression #1, char 25: Invalid range end
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2535
diff changeset
   448
    py3_files=$(echo $py_files | sed 's/ [[:alnum:]_\-\/.]*pyjslib.py//')
2184
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   449
}
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   450
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   451
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   452
print_help()
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   453
{
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   454
    echo "Usage: check_source.sh [--only-changes | --files-to-check <filename> ]"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   455
    echo ""
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   456
    echo "By default without arguments script checks all python source files"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   457
    echo ""
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   458
    echo "--only-changes"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   459
    echo "                only files with local changes are checked. "
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   460
    echo "                If script is called from mercurial pretxncommit hook,"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   461
    echo "                then only commited files are checked"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   462
    echo ""
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   463
    echo "--files-to-check <file.lst>"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   464
    echo "                script read list of files to check from file.lst"
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   465
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   466
    exit 1
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   467
}
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   468
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   469
main()
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   470
{
2184
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   471
    get_files_to_check $@
2420
290b77b72123 Add python3 syntax checking to CI
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2417
diff changeset
   472
    python3_compile_checks
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   473
    compile_checks
2424
dc5554f0c12c Add automatic check for localization strings with multiple unnamed arguments
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2421
diff changeset
   474
    localization_checks
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   475
    pep8_checks_default
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   476
    # pep8_checks_selected
2184
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   477
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   478
    # flake8_checks
1827
b8b47f9b5e56 enable pylint checker
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1786
diff changeset
   479
    pylint_checks
1786
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   480
    exit $exit_code
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   481
}
b6d47158d68a add shell script to test Beremiz python code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   482
2184
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   483
[ "$1" = "--help" -o "$1" = "-h" ] && print_help
bbd2364fbf71 Add argument to set list of source files to check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2183
diff changeset
   484
main $@