Skip to content

Commit efcbe32

Browse files
authored
Resolve various ament_lint linter violations (#360)
We can't add ament_lint linters in ament_cmake in the traditional way without creating a circular dependency between the repositories. Even though we can't automatically enforce linting, it's still a good idea to try to keep conformance where possible. Signed-off-by: Scott K Logan <[email protected]>
1 parent 9bcc813 commit efcbe32

File tree

13 files changed

+24
-18
lines changed

13 files changed

+24
-18
lines changed

ament_cmake_core/ament_cmake_uninstall_target-extras.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ if(AMENT_CMAKE_UNINSTALL_TARGET)
3131
@ONLY
3232
)
3333

34-
if (NOT TARGET uninstall)
34+
if(NOT TARGET uninstall)
3535
add_custom_target(uninstall)
3636
endif()
3737

38-
if (NOT TARGET ${PROJECT_NAME}_uninstall)
38+
if(NOT TARGET ${PROJECT_NAME}_uninstall)
3939
# register uninstall target to run generated CMake script
4040
add_custom_target(${PROJECT_NAME}_uninstall
4141
COMMAND ${CMAKE_COMMAND} -P "${AMENT_CMAKE_UNINSTALL_TARGET_UNINSTALL_SCRIPT}")

ament_cmake_core/cmake/core/get_executable_path.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function(get_executable_path var target_or_path)
5353
# There is a target with this name
5454
get_target_property(type "${target_or_path}" TYPE)
5555
get_target_property(imported "${target_or_path}" IMPORTED)
56-
if ("${type}" STREQUAL "EXECUTABLE")
56+
if("${type}" STREQUAL "EXECUTABLE")
5757
# The target is an executable, grab its LOCATION property
5858
if(ARG_BUILD)
5959
if(imported)

ament_cmake_core/cmake/core/package_xml_2_cmake.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import os
2020
import sys
2121

22-
from catkin_pkg.package import evaluate_condition
2322
from catkin_pkg.package import parse_package_string
2423

2524

ament_cmake_core/cmake/core/python.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
# Example:
1818
# find_package(Python3 3.8 REQUIRED)
1919
# find_package(ament_cmake REQUIRED)
20-
if (NOT TARGET Python3::Interpreter)
20+
if(NOT TARGET Python3::Interpreter)
2121
find_package(Python3 REQUIRED COMPONENTS Interpreter)
2222
endif()

ament_cmake_core/cmake/index/ament_index_register_resource.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function(ament_index_register_resource resource_type)
101101
file(GENERATE OUTPUT "${marker_file}" INPUT "${marker_file}.genexp")
102102
endif()
103103

104-
if (NOT ARG_SKIP_INSTALL)
104+
if(NOT ARG_SKIP_INSTALL)
105105
install(
106106
FILES "${marker_file}"
107107
DESTINATION "${destination}"

ament_cmake_core/cmake/package_templates/templates_2_cmake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def generate_cmake_code():
105105
lines.append('set(ament_cmake_package_templates_%s %s)' % (k, v))
106106
# Ensure backslashes are replaced with forward slashes because CMake cannot
107107
# parse files with backslashes in it.
108-
return [l.replace('\\', '/') for l in lines]
108+
return [line.replace('\\', '/') for line in lines]
109109

110110

111111
if __name__ == '__main__':

ament_cmake_export_dependencies/cmake/ament_cmake_export_dependencies-extras.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ if(NOT _exported_dependencies STREQUAL "")
5656
list(APPEND _libraries "${_imported_location}")
5757
endif()
5858
endif()
59-
endforeach()
59+
endforeach()
6060
endif()
6161

6262
get_target_property(_link_libraries ${_target} INTERFACE_LINK_LIBRARIES)

ament_cmake_export_libraries/cmake/ament_cmake_export_libraries-extras.cmake.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ if(NOT _exported_library_names STREQUAL "")
125125
)
126126
if(NOT _lib)
127127
# warn about not existing library and later ignore it
128-
message(WARNING "Package '@PROJECT_NAME@' exports library '${_library_name}' with LIBRARY_DIRS '${_library_dirs}' which couldn't be found")
128+
message(WARNING
129+
"Package '@PROJECT_NAME@' exports library '${_library_name}' with LIBRARY_DIRS '${_library_dirs}' which couldn't be found")
129130
endif()
130131
endif()
131132
if(_lib)

ament_cmake_google_benchmark/cmake/ament_add_google_benchmark_test.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ function(ament_add_google_benchmark_test target)
6262
endif()
6363

6464
if(AMENT_CMAKE_GOOGLE_BENCHMARK_OVERLAY AND NOT IS_ABSOLUTE ${AMENT_CMAKE_GOOGLE_BENCHMARK_OVERLAY})
65-
get_filename_component(AMENT_CMAKE_GOOGLE_BENCHMARK_OVERLAY ${CMAKE_CURRENT_SOURCE_DIR}/${AMENT_CMAKE_GOOGLE_BENCHMARK_OVERLAY} ABSOLUTE)
65+
get_filename_component(AMENT_CMAKE_GOOGLE_BENCHMARK_OVERLAY
66+
${CMAKE_CURRENT_SOURCE_DIR}/${AMENT_CMAKE_GOOGLE_BENCHMARK_OVERLAY} ABSOLUTE)
6667
set(OVERLAY_ARG "--result-file-overlay" "${AMENT_CMAKE_GOOGLE_BENCHMARK_OVERLAY}")
6768
endif()
6869

ament_cmake_libraries/cmake/ament_libraries_pack_build_configuration.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ macro(ament_libraries_pack_build_configuration VAR)
3333
if("${_lib}" MATCHES "^(debug|optimized|general)$")
3434
math(EXPR _index "${_index} + 1")
3535
if(${_index} EQUAL ${_count})
36-
message(FATAL_ERROR "ament_libraries_pack_build_configuration() the list of libraries '${_argn}' ends with '${_lib}' which is a build configuration keyword and must be followed by a library")
36+
message(FATAL_ERROR
37+
"ament_libraries_pack_build_configuration() the list of libraries '${_argn}' ends with '${_lib}' "
38+
"which is a build configuration keyword and must be followed by a library")
3739
endif()
3840
list(GET _argn ${_index} library)
3941
list(APPEND ${VAR} "${_lib}${AMENT_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}${library}")

ament_cmake_python/cmake/ament_python_install_package.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ function(_ament_cmake_python_install_package package_name)
8686
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_python/${package_name}")
8787

8888
string(CONFIGURE "\
89-
import os
9089
from setuptools import find_packages
9190
from setuptools import setup
9291

ament_cmake_test/ament_cmake_test-extras.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if(BUILD_TESTING)
3333
site_name(SITE)
3434
configure_file(
3535
${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in
36-
${PROJECT_BINARY_DIR}/CTestConfiguration.ini )
36+
${PROJECT_BINARY_DIR}/CTestConfiguration.ini)
3737
endif()
3838

3939
find_package(ament_cmake_core QUIET REQUIRED)

ament_cmake_test/ament_cmake_test/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def log(msg, **kwargs):
194194
encodings = ['utf-8']
195195
if locale.getpreferredencoding(False) not in encodings:
196196
encodings.append(locale.getpreferredencoding(False))
197-
197+
198198
start_time = time.monotonic()
199199

200200
try:
@@ -250,12 +250,15 @@ def log(msg, **kwargs):
250250

251251
if content == failure_result_file:
252252
if args.skip_return_code is not None and args.skip_return_code == rc:
253-
log("-- run_test.py: generate result file '%s' with skipped test" % args.result_file)
253+
log(
254+
'-- run_test.py: generate result file '
255+
"'%s' with skipped test" % args.result_file)
254256
# regenerate result file to indicate that the test was skipped
255257
result_file = _generate_result(args.result_file, skip=True, test_time=test_time)
256258
else:
257-
log("-- run_test.py: generate result file '%s' with failed test" % args.result_file,
258-
file=sys.stderr)
259+
log(
260+
'-- run_test.py: generate result file '
261+
"'%s' with failed test" % args.result_file, file=sys.stderr)
259262
# regenerate result file to include output / exception of the invoked command
260263
result_file = _generate_result(
261264
args.result_file,
@@ -316,7 +319,8 @@ def log(msg, **kwargs):
316319
return rc
317320

318321

319-
def _generate_result(result_file, *, failure_message=None, skip=False, error_message=None, test_time=0):
322+
def _generate_result(result_file, *, failure_message=None, skip=False,
323+
error_message=None, test_time=0):
320324
# the generated result file must be readable
321325
# by any of the Jenkins test result report publishers
322326
pkgname = os.path.basename(os.path.dirname(result_file))

0 commit comments

Comments
 (0)