* Adding CMake script to check if pylint is installed * Adding Pylint config file (to choose the tests that are enabled) * Adding CMake script to samples/python/tutorial_code Testing: bad-indentation, mixed-indentation, unnecessary-semicolon, unused-variablepull/9140/head
parent
9c14a2f0aa
commit
b7fa6d84bc
5 changed files with 73 additions and 1 deletions
@ -0,0 +1,27 @@ |
|||||||
|
# - Find Pylint |
||||||
|
# Find the Pylint executable and extract the version number |
||||||
|
# |
||||||
|
# OUTPUT Variables |
||||||
|
# |
||||||
|
# PYLINT_FOUND |
||||||
|
# True if the pylint package was found |
||||||
|
# PYLINT_EXECUTABLE |
||||||
|
# The pylint executable location |
||||||
|
# PYLINT_VERSION |
||||||
|
# A string denoting the version of pylint that has been found |
||||||
|
|
||||||
|
find_program(PYLINT_EXECUTABLE pylint PATHS /usr/bin) |
||||||
|
|
||||||
|
if(PYLINT_EXECUTABLE) |
||||||
|
execute_process(COMMAND ${PYLINT_EXECUTABLE} --version OUTPUT_VARIABLE PYLINT_VERSION_RAW ERROR_QUIET) |
||||||
|
if (PYLINT_VERSION_RAW) |
||||||
|
string(REGEX REPLACE "^pylint ([0-9]+.[0-9]+.[0-9]+),.*" "\\1" PYLINT_VERSION ${PYLINT_VERSION_RAW}) |
||||||
|
else() |
||||||
|
set(PYLINT_VERSION "unknown") |
||||||
|
endif() |
||||||
|
endif() |
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs) |
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pylint DEFAULT_MSG PYLINT_EXECUTABLE) |
||||||
|
|
||||||
|
mark_as_advanced(PYLINT_EXECUTABLE PYLINT_VERSION) |
@ -0,0 +1,23 @@ |
|||||||
|
# ---------------------------------------------------------------------------- |
||||||
|
# CMake file to run pylint on the tutorial python files. |
||||||
|
# |
||||||
|
# ---------------------------------------------------------------------------- |
||||||
|
include(${CMAKE_SOURCE_DIR}/cmake/FindPylint.cmake) |
||||||
|
|
||||||
|
project(run_pylint_on_tutorials) |
||||||
|
|
||||||
|
if(PYLINT_FOUND) |
||||||
|
message(STATUS "pylint version: ${PYLINT_VERSION}") |
||||||
|
set(curdir "${CMAKE_CURRENT_SOURCE_DIR}") |
||||||
|
file(GLOB_RECURSE PYTHON_SCRIPTS ${curdir}/*.py) |
||||||
|
add_custom_target("${PROJECT_NAME}") |
||||||
|
|
||||||
|
foreach(SCRIPT ${PYTHON_SCRIPTS}) |
||||||
|
get_filename_component(SCRIPT_NAME ${SCRIPT} NAME_WE) |
||||||
|
add_custom_command(TARGET "${PROJECT_NAME}" |
||||||
|
COMMAND ${PYLINT_EXECUTABLE} ${SCRIPT} |
||||||
|
--rcfile=${curdir}/pylintrc |
||||||
|
COMMENT "Running pylint on : ${SCRIPT_NAME}.py" |
||||||
|
) |
||||||
|
endforeach() |
||||||
|
endif() |
@ -0,0 +1,16 @@ |
|||||||
|
[MESSAGES CONTROL] |
||||||
|
|
||||||
|
# Disable all to choose the Tests one by one |
||||||
|
disable=all |
||||||
|
|
||||||
|
# Tests |
||||||
|
enable=bad-indentation, # Used when an unexpected number of indentation’s tabulations or spaces has been found. |
||||||
|
mixed-indentation, # Used when there are some mixed tabs and spaces in a module. |
||||||
|
unnecessary-semicolon, # Used when a statement is ended by a semi-colon (”;”), which isn’t necessary. |
||||||
|
unused-variable # Used when a variable is defined but not used. (Use _var to ignore var). |
||||||
|
|
||||||
|
|
||||||
|
[REPORTS] |
||||||
|
|
||||||
|
# Activate the evaluation score. |
||||||
|
score=no |
Loading…
Reference in new issue