Using Pylint Tool to Test the python tutorial codes
* 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-variable
This commit is contained in:
@@ -12,6 +12,7 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
|
||||
|
||||
add_subdirectory(cpp)
|
||||
add_subdirectory(java/tutorial_code)
|
||||
add_subdirectory(python/tutorial_code)
|
||||
add_subdirectory(dnn)
|
||||
add_subdirectory(gpu)
|
||||
add_subdirectory(tapi)
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user