pax_global_header00006660000000000000000000000064142037735650014526gustar00rootroot0000000000000052 comment=39e3b9656ca3c25cfdcf4bad565302f6f78bdc05 ament_lint-0.12.0/000077500000000000000000000000001420377356500137405ustar00rootroot00000000000000ament_lint-0.12.0/.gitignore000066400000000000000000000000141420377356500157230ustar00rootroot00000000000000__pycache__ ament_lint-0.12.0/CONTRIBUTING.md000066400000000000000000000016231420377356500161730ustar00rootroot00000000000000Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). ament_lint-0.12.0/LICENSE000066400000000000000000000261361420377356500147550ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ament_lint-0.12.0/ament_clang_format/000077500000000000000000000000001420377356500175605ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_format/CHANGELOG.rst000066400000000000000000000213121420377356500216000ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_clang_format ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Add clang-format-version option to ament_clang_format (`#282 `_) * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang, Tyler Weaver 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ * Fix new flake8 errors. (`#244 `_) * Contributors: Michel Hidalgo 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * Generate xunit files valid for the junit10.xsd (`#220 `_) * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dirk Thomas, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Convert list comprehension to generator (`#179 `_) Addresses flake8 C412 errors introduced by flake8-comprehension 2.2.0 * Bring clang-format in line with developer guide (`#147 `_) * Bring clang-format in line with developer guide https://index.ros.org/doc/ros2/Contributing/Developer-Guide/#id26 * Fix brace wrapping * Fix indent for initializer continuation * Minor changes to clang-format * Alphabetize options * Contributors: Dan Rose, Dirk Thomas, Scott K Logan 0.7.4 (2019-07-31) ------------------ * Add python3-yaml depends to ament_clang_tidy/format (`#166 `_) depend -> exec_depend Remove whitespace * Add missing pyyaml dependency (`#150 `_) * Contributors: Dan Rose, John 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ * use safe_load instead of deprecated load (`#135 `_) * Contributors: Mikael Arguedas 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ * level setup.py versions to 0.5.1 * Contributors: Mikael Arguedas 0.5.0 (2018-06-18 10:09) ------------------------ * add pytest markers to linter tests * set zip_safe to avoid warning during installation (`#96 `_) * Contributors: Dirk Thomas 0.4.0 (2017-12-08) ------------------ * remove test_suite, add pytest as test_requires * 0.0.3 * Merge pull request `#84 `_ from ament/flake8_plugins update style to satisfy new flake8 plugins * update style to satisfy new flake8 plugins * Merge pull request `#81 `_ from ament/ignore_build_spaces ignore folders with an AMENT_IGNORE file, e.g. build spaces * ignore folders with an AMENT_IGNORE file, e.g. build spaces * 0.0.2 * Merge pull request `#78 `_ from ament/use_flake8 use flake8 instead of pep8 and pyflakes * fix style warnings * use flake8 instead of pep8 and pyflakes * remove __future_\_ imports * update schema url * add schema to manifest files * Merge pull request `#55 `_ from ament/ament_clang_format update clang format * add clang-format binary name for OS X * use config file for clang_format (currently google style) * update ament\_(cmake\_)clang_format * split ament_clang_format into Python and CMake package, plain move / copy without changes * Merge pull request `#50 `_ from ament/ctest_build_testing use CTest BUILD_TESTING * use CTest BUILD_TESTING * Merge pull request `#42 `_ from ament/remove_second_extension remove result type extension from testsuite name * remove result type extension from testsuite name * Merge pull request `#41 `_ from ament/use_message_status avoid using message without STATUS * avoid using message without STATUS * Merge pull request `#30 `_ from ament/test_labels add labels to tests * add labels to tests * Merge pull request `#29 `_ from ament/change_test_dependencies update documentation for linters * update documentation for linters * Merge pull request `#27 `_ from ament/gtest_location add type as extension to test result files * add type as extension to test result files * add explicit build type * apply normpath to prevent './' prefix (fix `#24 `_) * improve error messages * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * move cmake part of ament_pyflakes to ament_cmake_pyflakes * move cmake part of ament_pep8 to ament_cmake_pep8 * move cmake part of ament_lint_cmake to ament_cmake_lint_cmake * disable debug output * add trailing newline to generated test result files * add missing copyright / license information * Merge pull request `#14 `_ from ament/test_runner_windows change test runner to work on windows * change test runner to work on windows * Merge pull request `#9 `_ from ament/docs add docs for linters * add docs for linters * modify generated unit test files for a better hierarchy in Jenkins * improve information in clang_format test result files * fix copy-n-pasted license names * make testname argument optional for all linters * use other linters for the linter packages where possible * Merge pull request `#2 `_ from ament/ament_lint_auto allow linting based on test dependencies only * add ament_lint_auto and ament_lint_common, update all linter packages to implement extension point of ament_lint_auto * improve clang-format output, convert absolute offset to line number and offset-in-line, also show line before and after modification * use project(.. NONE) * update to latest refactoring of ament_cmake * add dependency on ament_cmake_environment * add ament_clang_format * Contributors: Dirk Thomas ament_lint-0.12.0/ament_clang_format/ament_clang_format/000077500000000000000000000000001420377356500234005ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_format/ament_clang_format/__init__.py000066400000000000000000000000001420377356500254770ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_format/ament_clang_format/configuration/000077500000000000000000000000001420377356500262475ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_format/ament_clang_format/configuration/.clang-format000066400000000000000000000006031420377356500306210ustar00rootroot00000000000000--- Language: Cpp BasedOnStyle: Google AccessModifierOffset: -2 AlignAfterOpenBracket: AlwaysBreak BraceWrapping: AfterClass: true AfterFunction: true AfterNamespace: true AfterStruct: true BreakBeforeBraces: Custom ColumnLimit: 100 ConstructorInitializerIndentWidth: 0 ContinuationIndentWidth: 2 DerivePointerAlignment: false PointerAlignment: Middle ReflowComments: false ... ament_lint-0.12.0/ament_clang_format/ament_clang_format/main.py000077500000000000000000000316621420377356500247110ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014-2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import os import subprocess import sys import time from xml.etree import ElementTree from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr import yaml def main(argv=sys.argv[1:]): config_file = os.path.join( os.path.dirname(__file__), 'configuration', '.clang-format') extensions = ['c', 'cc', 'cpp', 'cxx', 'h', 'hh', 'hpp', 'hxx'] parser = argparse.ArgumentParser( description='Check code style using clang_format.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '--config', metavar='path', default=config_file, dest='config_file', help='The config file') parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files ending ' 'in %s will be considered.' % ', '.join(["'.%s'" % e for e in extensions])) parser.add_argument( '--clang-format-version', help='The version of clang-format to use.') parser.add_argument( '--reformat', action='store_true', help='Reformat the files in place') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if not os.path.exists(args.config_file): print("Could not find config file '%s'" % args.config_file, file=sys.stderr) return 1 if args.xunit_file: start_time = time.time() files = get_files(args.paths, extensions) if not files: print('No files found', file=sys.stderr) return 1 bin_names = [ 'clang-format', 'clang-format-3.8', 'clang-format-3.7', 'clang-format-3.6', 'clang-format-3.5', 'clang-format-3.4', 'clang-format-3.3', ] if args.clang_format_version: bin_names = ['clang-format-' + args.clang_format_version] clang_format_bin = find_executable(bin_names) if not clang_format_bin: print('Could not find %s executable' % ' / '.join(["'%s'" % n for n in bin_names]), file=sys.stderr) return 1 report = [] # invoke clang_format with open(args.config_file, 'r') as h: content = h.read() data = yaml.safe_load(content) style = yaml.dump(data, default_flow_style=True, width=float('inf')) cmd = [clang_format_bin, '-output-replacements-xml', '-style=%s' % style] cmd.extend(files) try: output = subprocess.check_output(cmd) except subprocess.CalledProcessError as e: print("The invocation of '%s' failed with error code %d: %s" % (os.path.basename(clang_format_bin), e.returncode, e), file=sys.stderr) return 1 # output errors report = {} for filename in files: report[filename] = [] xmls = output.split(b"")[1:] changed_files = [] for filename, xml in zip(files, xmls): try: root = ElementTree.fromstring(xml) except ElementTree.ParseError as e: print('Invalid XML in clang format output: %s' % str(e), file=sys.stderr) return 1 replacements = root.findall('replacement') if replacements: changed_files.append(filename) if not args.reformat: print("Code style divergence in file '%s':" % filename, file=sys.stderr) print('', file=sys.stderr) else: print("%d code style divergences in file '%s': reformatted " 'file' % (len(replacements), filename)) with open(filename, 'r') as h: content = h.read() for replacement in replacements: data = { 'offset': int(replacement.get('offset')), 'length': int(replacement.get('length')), 'replacement': replacement.text or '', } # to-be-replaced snippet data['original'] = content[ data['offset']:data['offset'] + data['length']] # map global offset to line number and offset in line index_of_line_start = find_index_of_line_start( content, data['offset']) index_of_line_end = find_index_of_line_end( content, data['offset'] + data['length']) data['line_no'] = get_line_number(content, index_of_line_start) data['offset_in_line'] = data['offset'] - index_of_line_start # generate diff like changes subcontent = content[ index_of_line_start:index_of_line_end] data['deletion'] = subcontent data['addition'] = subcontent[0:data['offset_in_line']] + \ data['replacement'] + \ subcontent[data['offset_in_line'] + data['length']:] # make common control characters visible mapping = {'\n': '\\n', '\r': '\\r', '\t': '\\t'} for old, new in mapping.items(): data['replacement'] = data['replacement'].replace(old, new) data['original'] = data['original'].replace(old, new) mapping = {'\r': '\n'} for old, new in mapping.items(): data['deletion'] = data['deletion'].replace(old, new) data['addition'] = data['addition'].replace(old, new) # format deletion / addition as unified diff data['deletion'] = '\n'.join( ['- ' + line for line in data['deletion'].split('\n')]) data['addition'] = '\n'.join( ['+ ' + line for line in data['addition'].split('\n')]) report[filename].append(data) if not args.reformat: data = dict(data) data['filename'] = filename print('[%(filename)s:%(line_no)d:%(offset_in_line)d]: ' 'Replace [%(original)s] with [%(replacement)s]' % data, file=sys.stderr) print(data['deletion'], file=sys.stderr) print(data['addition'], file=sys.stderr) if not args.reformat: print('', file=sys.stderr) else: print("No code style divergence in file '%s'" % filename) if not args.reformat: print('') # overwrite original with reformatted files if args.reformat and changed_files: cmd = [clang_format_bin, '-i', '-style=%s' % style] cmd.extend(files) try: subprocess.check_call(cmd) except subprocess.CalledProcessError as e: print("The invocation of '%s' failed with error code %d: %s" % (os.path.basename(clang_format_bin), e.returncode, e), file=sys.stderr) return 1 # output summary file_count = sum(1 if report[k] else 0 for k in report.keys()) replacement_count = sum(len(r) for r in report.values()) if not file_count: print('No problems found') rc = 0 else: print('%d files with %d code style divergences' % (file_count, replacement_count), file=sys.stderr) rc = 1 # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return rc def find_executable(file_names): paths = os.getenv('PATH').split(os.path.pathsep) for file_name in file_names: for path in paths: file_path = os.path.join(path, file_name) if os.path.isfile(file_path) and os.access(file_path, os.X_OK): return file_path return None def get_files(paths, extensions): files = [] for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] dirnames.sort() # select files by extension for filename in sorted(filenames): _, ext = os.path.splitext(filename) if ext in ('.%s' % e for e in extensions): files.append(os.path.join(dirpath, filename)) if os.path.isfile(path): files.append(path) return [os.path.normpath(f) for f in files] def find_index_of_line_start(data, offset): index_1 = data.rfind('\n', 0, offset) + 1 index_2 = data.rfind('\r', 0, offset) + 1 return max(index_1, index_2) def find_index_of_line_end(data, offset): index_1 = data.find('\n', offset) if index_1 == -1: index_1 = len(data) index_2 = data.find('\r', offset) if index_2 == -1: index_2 = len(data) return min(index_1, index_2) def get_line_number(data, offset): return data[0:offset].count('\n') + data[0:offset].count('\r') + 1 def get_xunit_content(report, testname, elapsed): test_count = sum(max(len(r), 1) for r in report.values()) error_count = sum(len(r) for r in report.values()) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for filename in sorted(report.keys()): replacements = report[filename] if replacements: # report each replacement as a failing testcase for replacement in replacements: data = { 'quoted_location': quoteattr( '%s:%d:%d' % ( filename, replacement['line_no'], replacement['offset_in_line'])), 'testname': testname, 'quoted_message': quoteattr( 'Replace [%s] with [%s]' % (replacement['original'], replacement['replacement'])), 'cdata': '\n'.join([ '%s:%d:%d' % ( filename, replacement['line_no'], replacement['offset_in_line']), replacement['deletion'], replacement['addition'], ]), } xml += """ """ % data else: # if there are no replacements report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % r for r in sorted(report.keys())])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_clang_format/doc/000077500000000000000000000000001420377356500203255ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_format/doc/index.rst000066400000000000000000000025141420377356500221700ustar00rootroot00000000000000ament_clang_format ================== Checks the code style of C / C++ source files using `ClangFormat `_. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_clang_format [-h] [--config path] [--clang-format-version CLANG_FORMAT_VERSION] [--reformat] [--xunit-file XUNIT_FILE] [paths [paths ...]] ``paths`` are directories to recursively search for files to run clang-format on. If no ``paths`` option is set the current directory will be used. The ``--config`` allows you to set the path to the .clang-format file to use. The ``--clang-format-version`` enables you to set a different version of clang-format to use. When using the option ``--reformat`` the proposed changes are applied in place. The ``--xunit-file`` option is used to generate a xunit output file. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_clang_format `_. ament_lint-0.12.0/ament_clang_format/package.xml000066400000000000000000000020121420377356500216700ustar00rootroot00000000000000 ament_clang_format 0.12.0 The ability to check code against style conventions using clang-format and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas clang-format python3-yaml ament_copyright ament_flake8 ament_pep257 python3-pytest ament_python ament_lint-0.12.0/ament_clang_format/pytest.ini000066400000000000000000000000351420377356500216070ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_clang_format/resource/000077500000000000000000000000001420377356500214075ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_format/resource/ament_clang_format000066400000000000000000000000001420377356500251400ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_format/setup.py000066400000000000000000000027021420377356500212730ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_clang_format' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools', 'pyyaml'], package_data={'': [ 'configuration/.clang-format', ]}, zip_safe=False, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check C++ code style using clang-format.', long_description="""\ The ability to check code against style conventions using clang-format and generate xUnit test result files.""", license='Apache License, Version 2.0, BSD', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_clang_format = ament_clang_format.main:main', ], }, ) ament_lint-0.12.0/ament_clang_format/test/000077500000000000000000000000001420377356500205375ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_format/test/test_copyright.py000066400000000000000000000014471420377356500241660ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_copyright.main import main import pytest @pytest.mark.copyright @pytest.mark.linter def test_copyright(): rc = main(argv=['ament_clang_format', 'test']) assert rc == 0, 'Found errors' ament_lint-0.12.0/ament_clang_format/test/test_flake8.py000066400000000000000000000015641420377356500233300ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_clang_format/test/test_pep257.py000066400000000000000000000014551420377356500231770ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pep257.main import main import pytest @pytest.mark.linter @pytest.mark.pep257 def test_pep257(): rc = main(argv=['ament_clang_format', 'test']) assert rc == 0, 'Found docblock style errors' ament_lint-0.12.0/ament_clang_tidy/000077500000000000000000000000001420377356500172415ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_tidy/CHANGELOG.rst000066400000000000000000000125331420377356500212660ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_clang_tidy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * remove google style from clang-tidy default settings, removing need for default config file (`#337 `_) * Improvements to ament_lint_clang_tidy. (`#316 `_) * Contributors: Audrow Nash, Steven! Ragnarök, William Woodall 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Add multiprocessing support to ament_clang_tidy (`#288 `_) * add multiprocessing support * fix stylistic lint issues * Contributors: Audrow Nash, M. Mei 0.10.1 (2021-01-25) ------------------- * Add --packages-select argument to ament_clang_tidy (`#287 `_) Add comment explaining handling quoted list of space separated package names Update documentation for ament_clang_tidy * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang, Tyler Weaver 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Merge pull request `#213 `_ from mm318/master Fix ament_clang_tidy * fix KeyError crash in ament_clang_tidy script * put back "checked files" section of xunit output file * fix bug in constructing arguments for clang-tidy command * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * fix flake8 linter issue * reduce amount of changes in pull request again * reduce amount of changes in pull request * put back --fix-errors and --header-filter options (--fix-errors is still a no-op) * fix python lint issues * remove some unsupported features * fix ament_clang_tidy * Generate xunit files valid for the junit10.xsd (`#220 `_) * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Claire Wang, Dirk Thomas, Jose Luis Rivero, Miaofei 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Convert list comprehension to generator (`#179 `_) Addresses flake8 C412 errors introduced by flake8-comprehension 2.2.0 * Contributors: Dirk Thomas, Scott K Logan 0.7.4 (2019-07-31) ------------------ * Fix version num for release (`#169 `_) * Add python3-yaml depends to ament_clang_tidy/format (`#166 `_) depend -> exec_depend Remove whitespace * Add error output, header out option, fix null error (`#163 `_) * Add error output, header out option, fix null error * Add quiet option to `ament_clang_tidy` * Add header filter and system header option * Add clang tidy to ament linters (`#155 `_) * Basic clang-lint functionality * Add clang tidy cmake dir * Add Google/default config file * Add xunit output * Add lint tests * Update copyright, maintainer, verbiage * Contributors: John 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_clang_tidy/ament_clang_tidy/000077500000000000000000000000001420377356500225425ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_tidy/ament_clang_tidy/__init__.py000066400000000000000000000000001420377356500246410ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_tidy/ament_clang_tidy/main.py000077500000000000000000000313771420377356500240560ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse from collections import defaultdict import copy import json from multiprocessing.pool import ThreadPool import os import re import subprocess import sys import time from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr import yaml def main(argv=sys.argv[1:]): extensions = ['c', 'cc', 'cpp', 'cxx', 'h', 'hh', 'hpp', 'hxx'] parser = argparse.ArgumentParser( description='Check code style using clang_tidy.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '--config', metavar='path', default=None, dest='config_file', help='The config file') parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='If is a directory, ament_clang_tidy will recursively search it for' ' "compile_commands.json" files. If is a file, ament_clang_tidy will' ' treat it as a "compile_commands.json" file') parser.add_argument( '--jobs', type=int, default=1, help='number of clang-tidy jobs to run in parallel') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--explain-config', action='store_true', help='Explain the enabled checks') parser.add_argument( '--export-fixes', help='Generate a DAT file of recorded fixes') parser.add_argument( '--fix-errors', action='store_true', help='Fix the suggested changes') parser.add_argument( '--header-filter', help='Accepts a regex and displays errors from the specified non-system headers') parser.add_argument( '--quiet', action='store_true', help='Suppresses printing statistics about ignored warnings ' 'and warnings treated as errors') parser.add_argument( '--system-headers', action='store_true', help='Displays errors from all system headers') parser.add_argument( '--packages-select', nargs='*', metavar='PKG_NAME', help='Only process a subset of packages') parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if args.config_file is not None and not os.path.exists(args.config_file): print("Could not find config file '%s'" % args.config_file, file=sys.stderr) return 1 if args.xunit_file: start_time = time.time() compilation_dbs = get_compilation_db_files(args.paths) if args.packages_select is not None: # Handle the case of a quoted list of space separated package names if len(args.packages_select) == 1: args.packages_select = args.packages_select[0].strip().split() compilation_dbs = filter_packages_select(compilation_dbs, args.packages_select) if not compilation_dbs: print('No compilation database files found', file=sys.stderr) return 1 bin_names = [ 'clang-tidy', 'clang-tidy-10', 'clang-tidy-11', 'clang-tidy-6.0', ] clang_tidy_bin = find_executable(bin_names) if not clang_tidy_bin: print('Could not find %s executable' % ' / '.join(["'%s'" % n for n in bin_names]), file=sys.stderr) return 1 pool = ThreadPool(args.jobs) def invoke_clang_tidy(compilation_db_path): package_dir = os.path.dirname(compilation_db_path) package_name = os.path.basename(package_dir) cmd = [clang_tidy_bin, '-p', package_dir] if args.config_file is not None: with open(args.config_file, 'r') as h: content = h.read() data = yaml.safe_load(content) style = yaml.dump(data, default_flow_style=True, width=float('inf')) cmd.append('--config=%s' % style) if args.explain_config: cmd.append('--explain-config') if args.export_fixes: cmd.append('--export-fixes') cmd.append(args.export_fixes) if args.fix_errors: cmd.append('--fix-errors') cmd.append('--header-filter') if args.header_filter: cmd.append(args.header_filter) else: cmd.append('include/%s/.*' % package_name) if args.quiet: cmd.append('--quiet') if args.system_headers: cmd.append('--system-headers') def is_gtest_source(file_name): if(file_name == 'gtest_main.cc' or file_name == 'gtest-all.cc' or file_name == 'gmock_main.cc' or file_name == 'gmock-all.cc'): return True return False def is_unittest_source(package, file_path): return ('%s/test/' % package) in file_path def start_subprocess(full_cmd): output = '' try: output = subprocess.check_output(full_cmd, stderr=subprocess.DEVNULL).strip().decode() except subprocess.CalledProcessError as e: print('The invocation of "%s" failed with error code %d: %s' % (os.path.basename(clang_tidy_bin), e.returncode, e), file=sys.stderr) return output files = [] async_outputs = [] db = json.load(open(compilation_db_path)) for item in db: # exclude gtest sources from being checked by clang-tidy if is_gtest_source(os.path.basename(item['file'])): continue # exclude unit test sources from being checked by clang-tidy # because gtest macros are problematic if is_unittest_source(package_name, item['file']): continue files.append(item['file']) full_cmd = cmd + [item['file']] async_outputs.append(pool.apply_async(start_subprocess, (full_cmd,))) output = '' for async_output in async_outputs: output += async_output.get() return (files, output) files = [] outputs = [] for compilation_db in compilation_dbs: package_dir = os.path.dirname(compilation_db) package_name = os.path.basename(package_dir) print('found compilation database for package "%s"...' % package_name) (source_files, output) = invoke_clang_tidy(compilation_db) files += source_files outputs.append(output) pool.close() pool.join() # output errors report = defaultdict(list) for filename in files: report[filename] = [] error_re = re.compile('(/.*?\\.(?:%s)):(\\d+):(\\d+): (?:warning:|error:)' % '|'.join(extensions)) current_file = None new_file = None data = {} for output in outputs: print(output) for line in output.splitlines(): # error found match = error_re.search(line) if match: new_file = match.group(1) if current_file is not None: report[current_file].append(copy.deepcopy(data)) data.clear() current_file = new_file line_num = match.group(2) col_num = match.group(3) error_msg = find_error_message(line) data['line_no'] = line_num data['offset_in_line'] = col_num data['error_msg'] = error_msg else: data['code_correct_rec'] = data.get('code_correct_rec', '') + line + '\n' if current_file is not None: report[current_file].append(copy.deepcopy(data)) if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) def find_executable(file_names): paths = os.getenv('PATH').split(os.path.pathsep) for file_name in file_names: for path in paths: file_path = os.path.join(path, file_name) if os.path.isfile(file_path) and os.access(file_path, os.X_OK): return file_path return None def get_compilation_db_files(paths): files = [] for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] dirnames.sort() # select files by extension for filename in filenames: if filename == 'compile_commands.json': files.append(os.path.join(dirpath, filename)) elif os.path.isfile(path): files.append(path) return [os.path.normpath(f) for f in files] def filter_packages_select(compilation_db_paths, packages): def package_test(compilation_db_paths): package_name = os.path.basename(os.path.dirname(compilation_db_paths)) return (package_name in packages) return list(filter(package_test, compilation_db_paths)) def find_error_message(data): return data[data.rfind(':') + 2:] def get_xunit_content(report, testname, elapsed): test_count = sum(max(len(r), 1) for r in report.values()) error_count = sum(len(r) for r in report.values()) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for filename in sorted(report.keys()): errors = report[filename] if errors: # report each replacement as a failing testcase for error in errors: data = { 'quoted_location': quoteattr( '%s:%d:%d' % ( filename, int(error['line_no']), int(error['offset_in_line']))), 'testname': testname, 'quoted_message': quoteattr( '%s' % error['error_msg']), 'cdata': '\n'.join([ '%s:%d:%d' % ( filename, int(error['line_no']), int(error['offset_in_line']))]) } if 'code_correct_rec' in data: data['cdata'] += '\n' data['cdata'] += data['code_correct_rec'] xml += """ """ % data else: # if there are no errors report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape( ''.join(['\n* %s' % r for r in sorted(map( os.path.relpath, report.keys() ))])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_clang_tidy/doc/000077500000000000000000000000001420377356500200065ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_tidy/doc/index.rst000066400000000000000000000051261420377356500216530ustar00rootroot00000000000000ament_clang_tidy ================== Checks the code style of C / C++ source files using `Clang-Tidy `_. Files with the following extensions are considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- *Prerequisites*: ``clang-tidy-6.0``, ``clang-tools-6.0``, and ``python-yaml`` packages should have already been installed. ``compile_commands.json`` files should have already been generated (e.g.: workspace built with ``colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON``). .. code:: sh ament_clang_tidy [-h] [--config path] [--explain-config] [--export-fixes EXPORT_FIXES] [--fix-errors] [--header-filter HEADER_FILTER] [--quiet] [--system-headers] [--jobs N] [--packages-select [PKG_NAME [PKG_NAME ...]]] [--xunit-file XUNIT_FILE] [paths [paths ...]] If ```` is a directory, it will be recursively searched for "compile_commands.json" files (this is usually the ``build`` directory of a ``colcon`` workspace). If ```` is a file, it will be treated as a "compile_commands.json" file. The ``--config`` allows you to set the path to the .clang-tidy file to use. The ``--explain-config`` option will explain the origin of the enabled configuration checks. The ``--header-filter`` option will accept a regex and display errors from the specified non-system header files. To display errors from all non-system header, use ``--header-filter='.*'``. The ``--quiet`` option will suppress printing statistics about ignored warnings and warnings treated as errors. The ``--export-fixes`` option will generate a DAT file of the recorded fixes when supplied with a file name. When using the option ``--fix-errors`` the proposed changes are applied in place. The ``--system-headers`` option will display errors from all system header files. The ``--jobs`` option will control the number of clang-tidy jobs to run in parallel. The ``--packages-select`` option will filter the "compile_commands.json" files to just those generated by specific ROS packages. The ``--xunit-file`` option will generate a xunit compliant XML file when supplied with a file name. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_clang_tidy `_. ament_lint-0.12.0/ament_clang_tidy/package.xml000066400000000000000000000017451420377356500213650ustar00rootroot00000000000000 ament_clang_tidy 0.12.0 The ability to check code against style conventions using clang-tidy and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang clang-tidy python3-yaml ament_copyright ament_flake8 ament_pep257 python3-pytest ament_python ament_lint-0.12.0/ament_clang_tidy/pytest.ini000066400000000000000000000000351420377356500212700ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_clang_tidy/resource/000077500000000000000000000000001420377356500210705ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_tidy/resource/ament_clang_tidy000066400000000000000000000000001420377356500243020ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_tidy/setup.py000066400000000000000000000026641420377356500207630ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_clang_tidy' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools', 'pyyaml'], package_data={'': [ 'configuration/.clang-tidy', ]}, zip_safe=False, author='John Shepherd', author_email='john@openrobotics.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check C++ code style using clang-tidy.', long_description="""\ The ability to check code against style conventions using clang-tidy and generate xUnit test result files.""", license='Apache License, Version 2.0, BSD', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_clang_tidy = ament_clang_tidy.main:main', ], }, ) ament_lint-0.12.0/ament_clang_tidy/test/000077500000000000000000000000001420377356500202205ustar00rootroot00000000000000ament_lint-0.12.0/ament_clang_tidy/test/test_copyright.py000066400000000000000000000014451420377356500236450ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_copyright.main import main import pytest @pytest.mark.copyright @pytest.mark.linter def test_copyright(): rc = main(argv=['ament_clang_tidy', 'test']) assert rc == 0, 'Found errors' ament_lint-0.12.0/ament_clang_tidy/test/test_flake8.py000066400000000000000000000015641420377356500230110ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_clang_tidy/test/test_pep257.py000066400000000000000000000014531420377356500226560ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pep257.main import main import pytest @pytest.mark.linter @pytest.mark.pep257 def test_pep257(): rc = main(argv=['ament_clang_tidy', 'test']) assert rc == 0, 'Found docblock style errors' ament_lint-0.12.0/ament_cmake_clang_format/000077500000000000000000000000001420377356500207205ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_clang_format/CHANGELOG.rst000066400000000000000000000071641420377356500227510ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_clang_format ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ * Fix append error * Contributors: John 0.7.4 (2019-07-31) ------------------ * Remove build failing whitespace (`#162 `_) * Remove whitespace from clang-format and clang-tidy * Add custom config file support for clang-format (`#153 `_) * Add custom config file support for clang-format * Add global arg into cmake function, update documentation * Fix package to find (`#156 `_) * Contributors: John 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ * fix name of included CMake file for cmake_clang_format (`#128 `_) * fix name of included CMake file for cmake_clang_format * fix ament_clang_format_BIN * Contributors: Dirk Thomas 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#55 `_ from ament/ament_clang_format update clang format * update ament\_(cmake\_)clang_format * split ament_clang_format into Python and CMake package, plain move / copy without changes * Contributors: Dirk Thomas ament_lint-0.12.0/ament_cmake_clang_format/CMakeLists.txt000066400000000000000000000007151420377356500234630ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_clang_format NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_clang_format-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_clang_format/ament_cmake_clang_format-extras.cmake000066400000000000000000000016231420377356500302100ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_clang_format/ament_cmake_clang_format-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_clang_format_DIR}/ament_clang_format.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_clang_format" "ament_cmake_clang_format_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_clang_format/cmake/000077500000000000000000000000001420377356500220005ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_clang_format/cmake/ament_clang_format.cmake000066400000000000000000000050541420377356500266260ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check the code for compliance with clang_format. # # The default configuration file used for clang-format is located at # configuration/.clang-format within the ament_clang_format directory # The default configuration file can be either overridden by the # argument 'CONFIG_FILE' or by a global variable named # 'ament_cmake_clang_format_CONFIG_FILE' # The 'CONFIG_FILE' argument takes priority over # 'ament_cmake_clang_format_CONFIG_FILE' if both are defined # # :param TESTNAME: the name of the test, default: "clang_format" # :type TESTNAME: string # :param CONFIG_FILE: the path of the configuration file for # clang-format to consider # :type CONFIG_FILE: string # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_clang_format) cmake_parse_arguments(ARG "" "TESTNAME;CONFIG_FILE" "" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "clang_format") endif() find_program(ament_clang_format_BIN NAMES "ament_clang_format") if(NOT ament_clang_format_BIN) message(FATAL_ERROR "ament_clang_format() variable 'ament_clang_format_BIN' must not be empty") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_clang_format_BIN}" "--xunit-file" "${result_file}") list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) if(ARG_CONFIG_FILE) list(APPEND cmd "--config" "${ARG_CONFIG_FILE}") elseif(DEFINED ament_cmake_clang_format_CONFIG_FILE) list(APPEND cmd "--config" "${ament_cmake_clang_format_CONFIG_FILE}") endif() file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_clang_format") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_clang_format/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "clang_format;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_clang_format/cmake/ament_cmake_clang_format_lint_hook.cmake000066400000000000000000000015211420377356500320270ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" ) if(_source_files) message(STATUS "Added test 'clang_format' to check C / C++ code style") ament_clang_format() endif() ament_lint-0.12.0/ament_cmake_clang_format/doc/000077500000000000000000000000001420377356500214655ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_clang_format/doc/index.rst000066400000000000000000000024641420377356500233340ustar00rootroot00000000000000ament_cmake_clang_format ======================== Checks the code style of C / C++ source files using `ClangFormat `_. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_clang_format `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_clang_format ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_clang_format REQUIRED) ament_clang_format() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_clang_format/package.xml000066400000000000000000000021241420377356500230340ustar00rootroot00000000000000 ament_cmake_clang_format 0.12.0 The CMake API for ament_clang_format to lint C / C++ code using clang format. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_clang_format ament_cmake_test ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_clang_tidy/000077500000000000000000000000001420377356500204015ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_clang_tidy/CHANGELOG.rst000066400000000000000000000062221420377356500224240ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_clang_tidy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Improvements to ament_lint_clang_tidy. (`#316 `_) * Contributors: Audrow Nash, Steven! Ragnarök 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * add TIMEOUT argument to ament_cmake_clang_tidy (`#298 `_) * Contributors: Audrow Nash, M. Mei 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Contributors: Audrow Nash 0.10.1 (2021-01-25) ------------------- * Fix documentation for ament_cmake_clang_tidy (`#285 `_) * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang, Tyler Weaver 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ * Fix append error * Contributors: John 0.7.4 (2019-07-31) ------------------ * Remove build failing whitespace (`#162 `_) * Remove whitespace from clang-format and clang-tidy * Add custom config file support (`#159 `_) * Add clang tidy to ament linters (`#155 `_) * Basic clang-lint functionality * Add clang tidy cmake dir * Add Google/default config file * Add xunit output * Add lint tests * Update copyright, maintainer, verbiage * Contributors: John 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_cmake_clang_tidy/CMakeLists.txt000066400000000000000000000007111420377356500231400ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_clang_tidy NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_clang_tidy-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_clang_tidy/ament_cmake_clang_tidy-extras.cmake000066400000000000000000000016021420377356500273470ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_clang_tidy/ament_cmake_clang_tidy-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_clang_tidy_DIR}/ament_clang_tidy.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_clang_tidy" "ament_cmake_clang_tidy_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_clang_tidy/cmake/000077500000000000000000000000001420377356500214615ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_clang_tidy/cmake/ament_clang_tidy.cmake000066400000000000000000000052271420377356500257720ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check the code for compliance with clang_tidy. # # The default configuration file for clang-tidy is located at # configuration/.clang-tidy within the ament_clang_tidy directory # The default configuration file can be either overridden by the # argument 'CONFIG_FILE' or by a global variable named # 'ament_cmake_clang_tidy_CONFIG_FILE' # The 'CONFIG_FILE' argument takes priority over # 'ament_cmake_clang_tidy_CONFIG_FILE' if both are defined # # :param TESTNAME: the name of the test, default: "clang_tidy" # :type TESTNAME: string # :param CONFIG_FILE: the path of the configuration file for clang-tidy to consider # :type CONFIG_FILE: string # :param ARGN: the files or directories to check # :type ARGN: list of strings # :param TIMEOUT: the test timeout in seconds, default: 300 # :type TIMEOUT: integer # # @public # function(ament_clang_tidy) cmake_parse_arguments(ARG "" "TESTNAME;CONFIG_FILE;TIMEOUT" "" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "clang_tidy") endif() find_program(ament_clang_tidy_BIN NAMES "ament_clang_tidy") if(NOT ament_clang_tidy_BIN) message(FATAL_ERROR "ament_clang_tidy() variable 'ament_clang_tidy_BIN' must not be empty") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_clang_tidy_BIN}" "--xunit-file" "${result_file}") list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) if(ARG_CONFIG_FILE) list(APPEND cmd "--config" "${ARG_CONFIG_FILE}") elseif(DEFINED ament_cmake_clang_tidy_CONFIG_FILE) list(APPEND cmd "--config" "${ament_cmake_clang_tidy_CONFIG_FILE}") endif() if(NOT ARG_TIMEOUT) set(ARG_TIMEOUT 300) endif() file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_clang_tidy") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_clang_tidy/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" TIMEOUT "${ARG_TIMEOUT}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "clang_tidy;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_clang_tidy/cmake/ament_cmake_clang_tidy_lint_hook.cmake000066400000000000000000000015521420377356500311750ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" ) if(_source_files) message(STATUS "Added test 'clang_tidy' to check C / C++ code style") ament_clang_tidy("${CMAKE_CURRENT_BINARY_DIR}") endif() ament_lint-0.12.0/ament_cmake_clang_tidy/doc/000077500000000000000000000000001420377356500211465ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_clang_tidy/doc/index.rst000066400000000000000000000024571420377356500230170ustar00rootroot00000000000000ament_cmake_clang_tidy ======================== Diagnose and fix typical programming errors with `Clang-Tidy `_. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_clang_tidy `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_clang_tidy ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_clang_tidy REQUIRED) ament_clang_tidy(${CMAKE_BINARY_DIR}) endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_clang_tidy/package.xml000066400000000000000000000020551420377356500225200ustar00rootroot00000000000000 ament_cmake_clang_tidy 0.12.0 The CMake API for ament_clang_tidy to lint C / C++ code using clang tidy. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang ament_cmake_core ament_cmake_test ament_clang_tidy ament_cmake_test ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_copyright/000077500000000000000000000000001420377356500202745ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_copyright/CHANGELOG.rst000066400000000000000000000123601420377356500223170ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_copyright ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * [ament_cmake_copyright] Add file exclusion support (`#328 `_) * [ament_cmake_copyright] Add file exclusion support In the `ament_copyright` CMake function, the optional list argument `EXCLUDE` can now be used as an exclusion specifier. * [ament_cmake_copyright] Fix function header typo Remove reference to `cppcheck` in the `EXCLUDE` arg description. * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Abrar Rahman Protyasha, Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * increase default timeout for CMake copyright linter to 120s (`#261 `_) * Contributors: Dirk Thomas 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ * Remove check of source files done in lint hook (`#247 `_) * Remove check of source files done in lint hook * Reformat to match <= 80 chars line * Contributors: Jorge Perez 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Update index.rst (`#199 `_) fix function name * Contributors: Chris Lalancette, Dan Rose 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#50 `_ from ament/ctest_build_testing use CTest BUILD_TESTING * use CTest BUILD_TESTING * Merge pull request `#41 `_ from ament/use_message_status avoid using message without STATUS * avoid using message without STATUS * Merge pull request `#30 `_ from ament/test_labels add labels to tests * add labels to tests * Merge pull request `#29 `_ from ament/change_test_dependencies update documentation for linters * update documentation for linters * Merge pull request `#27 `_ from ament/gtest_location add type as extension to test result files * add type as extension to test result files * add explicit build type * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * make use of python linter packages * move cmake part of ament_lint_cmake to ament_cmake_lint_cmake * disable debug output * add missing copyright / license information * Merge pull request `#14 `_ from ament/test_runner_windows change test runner to work on windows * change test runner to work on windows * Merge pull request `#9 `_ from ament/docs add docs for linters * add docs for linters * Merge pull request `#8 `_ from ament/ament_copyright add more options to ament_copyright * update package description * add more options to ament_copyright * Contributors: Dirk Thomas ament_lint-0.12.0/ament_cmake_copyright/CMakeLists.txt000066400000000000000000000011041420377356500230300ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_copyright NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) # include CMake functions of this package set(ament_cmake_copyright_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include("ament_cmake_copyright-extras.cmake" NO_POLICY_SCOPE) ament_package( CONFIG_EXTRAS "ament_cmake_copyright-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() ament_copyright() endif() ament_lint-0.12.0/ament_cmake_copyright/ament_cmake_copyright-extras.cmake000066400000000000000000000016031420377356500271360ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_copyright/ament_cmake_copyright-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_copyright_DIR}/ament_copyright.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_copyright" "ament_cmake_copyright_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_copyright/cmake/000077500000000000000000000000001420377356500213545ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_copyright/cmake/ament_cmake_copyright_lint_hook.cmake000066400000000000000000000013061420377356500307600ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. message( STATUS "Added test 'copyright' to check source files copyright and LICENSE") ament_copyright() ament_lint-0.12.0/ament_cmake_copyright/cmake/ament_copyright.cmake000066400000000000000000000041541420377356500255560ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check the code for compliance with copyright. # # :param TESTNAME: the name of the test, default: "copyright" # :type TESTNAME: string # :param TIMEOUT: the test timeout in seconds, default: 120 # :type TIMEOUT: integer # :param EXCLUDE: an optional list of exclude files or directories for copyright check # :type EXCLUDE: list # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_copyright) cmake_parse_arguments(ARG "" "TESTNAME;TIMEOUT" "EXCLUDE" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "copyright") endif() if(NOT ARG_TIMEOUT) set(ARG_TIMEOUT 120) endif() find_program(ament_copyright_BIN NAMES "ament_copyright") if(NOT ament_copyright_BIN) message(FATAL_ERROR "ament_copyright() could not find program 'ament_copyright'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_copyright_BIN}" "--xunit-file" "${result_file}") if(ARG_EXCLUDE) list(APPEND cmd "--exclude" "${ARG_EXCLUDE}") endif() list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_copyright") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_copyright/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" TIMEOUT "${ARG_TIMEOUT}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "copyright;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_copyright/doc/000077500000000000000000000000001420377356500210415ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_copyright/doc/index.rst000066400000000000000000000024331420377356500227040ustar00rootroot00000000000000ament_cmake_copyright ===================== Checks C / C++ / CMake / Python source files for the existance of a copyright notice. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``, ``.cmake``, ``.py``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_copyright `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_copyright ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_copyright/package.xml000066400000000000000000000021271420377356500224130ustar00rootroot00000000000000 ament_cmake_copyright 0.12.0 The CMake API for ament_copyright to check every source file contains copyright reference. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_copyright ament_cmake_test ament_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_cppcheck/000077500000000000000000000000001420377356500200445ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_cppcheck/CHANGELOG.rst000066400000000000000000000206011420377356500220640ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_cppcheck ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * [ament_cmake_cppcheck] Fix file exclusion behavior (`#329 `_) The `EXCLUDE` argument of the `ament_cppcheck` CMake function is a list, i.e. a multi-value keyword. As such, it needs to be placed out of the one-value keywords from the `cmake_parse_arguments` function call. * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Add cppcheck libraries option (`#323 `_) * adding ament_cppcheck libraries option * pass libraries option via CMake Co-authored-by: William Wedler * Contributors: Abrar Rahman Protyasha, Audrow Nash, Will 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Increase the ament_cppcheck timeout to 5 minutes. (`#271 `_) This will avoid timeouts on some slower platforms that we've started to see. * parse LANGUAGE argument case insensitive (`#255 `_) * Contributors: Chris Lalancette, Karsten Knese 0.9.4 (2020-05-26) ------------------ * Allow to configure language in cppcheck with a global var (`#239 `_) * Allow to configure language in cppcheck with a global var * Added feedback * added feedback * added feedback * Added feedback * Fixed cpplint * Print language message if it's not empty * fixed language message * Improved comment * Contributors: Alejandro Hernández Cordero 0.9.3 (2020-05-18) ------------------ * Fix lint_cmake errors (`#245 `_) * Updated cpplint and cppcheck to exclude directories and files (`#234 `_) * UPted cpplint and cppcheck to exclude directories and files * setting a global variable to configure automatic linting * Fixed cmake docbloc * Added feedback * Allowed cpplint to exclude files * Restored cpplint.py * Contributors: Alejandro Hernández Cordero, Michel Hidalgo 0.9.2 (2020-05-08) ------------------ * Increase timeout for cppcheck runs. (`#229 `_) On some platforms the cppcheck for the test_rclcpp package is hitting the timeout. Bumping the timeout on those platforms shows that the build takes about 130 seconds. So 180 should be sufficient room to grow without raising it too high. * Contributors: Steven! Ragnarök 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Behave better in multi-project cmake (`#198 `_) If a sub-project uses ament_lint, don't apply it to the top-level project headers * Contributors: Chris Lalancette, Dan Rose 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ * Alternate approach to avoiding cppcheck 1.88 (`#175 `_) This approach does not require cppcheck to be present at build time. * avoid cppcheck version 1.88 due to performance issues (`#168 `_) * avoid cppcheck version 1.88 due to performance issues * downgrade to status from warning when skipping * Contributors: Scott K Logan, William Woodall 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ * use globally defined varible for cppcheck include dirs (`#125 `_) * use globally defined varible for cppcheck include dirs * update docblock period * Contributors: Karsten Knese 0.6.3 (2019-01-14) ------------------ * Account for INTERFACE libraries when getting target include directories (`#121 `_) * Account for INTERFACE libraries when getting target include directories CMake does not allow getting the INCLUDE_DIRECTORIES property from INTERFACE libraries. Instead, first check if the property exists, if it does not then try to get the INTERFACE_INCLUDE_DIRECTORIES property. Note, if INTERFACE_INCLUDE_DIRECTORIES is not defined an empty list is returned, but we cannot assume the target is not an interface. This is why the implementation is conditional on INCLUDE_DIRECTORIES instead. * Use target type property as a condition on what include directories property to use * Increase cppcheck test timeout to 120s * Pass include paths to cppcheck (`#117 `_) * Use BUILDSYSTEM_TARGETS list for getting include directories * Only pass include directories that are subdirectories of the package being tested This eliminates the need for a longer test timeout and avoids cppcheck from testing external files. Reverted prior changes accordingly. * Handle case when cppcheck reports error in filename with arbitrary path * Add find_package and dependency tag for ament_cmake_core * Contributors: Jacob Perron 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * opt to pass the language through to cppcheck (`#79 `_) * opt to pass the language through to cppcheck * add explicit LANGUAGE argument * alpha ordering on arguments and typo * fixup * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#50 `_ from ament/ctest_build_testing use CTest BUILD_TESTING * use CTest BUILD_TESTING * Merge pull request `#41 `_ from ament/use_message_status avoid using message without STATUS * avoid using message without STATUS * Merge pull request `#30 `_ from ament/test_labels add labels to tests * add labels to tests * Merge pull request `#29 `_ from ament/change_test_dependencies update documentation for linters * update documentation for linters * Merge pull request `#27 `_ from ament/gtest_location add type as extension to test result files * add type as extension to test result files * add explicit build type * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * make use of python linter packages * move cmake part of ament_lint_cmake to ament_cmake_lint_cmake * move cmake part of ament_cppcheck to ament_cmake_cppcheck * Contributors: Dirk Thomas, William Woodall ament_lint-0.12.0/ament_cmake_cppcheck/CMakeLists.txt000066400000000000000000000007051420377356500226060ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_cppcheck NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_cppcheck-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_cppcheck/ament_cmake_cppcheck-extras.cmake000066400000000000000000000015751420377356500264660ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_cppcheck/ament_cmake_cppcheck-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_cppcheck_DIR}/ament_cppcheck.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_cppcheck" "ament_cmake_cppcheck_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_cppcheck/cmake/000077500000000000000000000000001420377356500211245ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_cppcheck/cmake/ament_cmake_cppcheck_lint_hook.cmake000066400000000000000000000067401420377356500303070ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. find_package(ament_cmake_core REQUIRED) file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" ) if(_source_files) message(STATUS "Added test 'cppcheck' to perform static code analysis on C / C++ code") # Get include paths for added targets set(_all_include_dirs "") if(DEFINED ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS) list(APPEND _all_include_dirs ${ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS}) endif() # Forces cppcheck to consider ament_cmake_cppcheck_LANGUAGE as the given language if defined set(_language "") if(DEFINED ament_cmake_cppcheck_LANGUAGE) set(_language LANGUAGE ${ament_cmake_cppcheck_LANGUAGE}) message(STATUS "Configured cppcheck language: ${ament_cmake_cppcheck_LANGUAGE}") endif() # Get exclude paths for added targets set(_all_exclude "") if(DEFINED ament_cmake_cppcheck_ADDITIONAL_EXCLUDE) list(APPEND _all_exclude ${ament_cmake_cppcheck_ADDITIONAL_EXCLUDE}) endif() # BUILDSYSTEM_TARGETS only supported in CMake >= 3.7 if(NOT CMAKE_VERSION VERSION_LESS "3.7.0") get_directory_property(_build_targets DIRECTORY ${PROJECT_SOURCE_DIR} BUILDSYSTEM_TARGETS) foreach(_target ${_build_targets}) # Include directories property is different for INTERFACE libraries get_target_property(_target_type ${_target} TYPE) if(${_target_type} STREQUAL "INTERFACE_LIBRARY") get_target_property(_include_dirs ${_target} INTERFACE_INCLUDE_DIRECTORIES) else() get_target_property(_include_dirs ${_target} INCLUDE_DIRECTORIES) endif() # Only append include directories that are from the package being tested # This accomplishes two things: # 1. Reduces execution time (less include directories to search) # 2. cppcheck will not check for errors in external packages foreach(_include_dir ${_include_dirs}) # TODO(jacobperron): Escape special regex characters in PROJECT_SOURCE_DIR # Related CMake feature request: https://gitlab.kitware.com/cmake/cmake/issues/18409 # Check if include directory is a subdirectory of the source directory string(REGEX MATCH "^${PROJECT_SOURCE_DIR}/.*" _is_subdirectory ${_include_dir}) # Check if include directory is part of a generator expression (e.g. $) string(REGEX MATCH "^\\$<.*:${PROJECT_SOURCE_DIR}/.*>$" _is_genexp_subdirectory "${_include_dir}") if(_is_subdirectory OR _is_genexp_subdirectory) list_append_unique(_all_include_dirs ${_include_dir}) endif() endforeach() endforeach() endif() message(STATUS "Configured cppcheck include dirs: ${_all_include_dirs}") message( STATUS "Configured cppcheck exclude dirs and/or files: ${_all_exclude}" ) ament_cppcheck( ${_language} INCLUDE_DIRS ${_all_include_dirs} EXCLUDE ${_all_exclude} ) endif() ament_lint-0.12.0/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake000066400000000000000000000053551420377356500251020ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to perform static code analysis with cppcheck. # # The include dirs for cppcheck to consider can either be set by the function # parameter 'INCLUDE_DIRS` or by a global variable called # 'ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS'. # # :param TESTNAME: the name of the test, default: "cppcheck" # :type TESTNAME: string # :param LANGUAGE: the language argument for cppcheck, either 'c' or 'c++' # :type LANGUAGE: string # :param LIBRARIES: an optional list of library configs for cppcheck to load # :type LIBRARIES: list # :param EXCLUDE: an optional list of exclude files or directories for cppcheck # :type EXCLUDE: list # :param INCLUDE_DIRS: an optional list of include paths for cppcheck # :type INCLUDE_DIRS: list # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_cppcheck) cmake_parse_arguments(ARG "" "LANGUAGE;TESTNAME" "EXCLUDE;LIBRARIES;INCLUDE_DIRS" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "cppcheck") endif() find_program(ament_cppcheck_BIN NAMES "ament_cppcheck") if(NOT ament_cppcheck_BIN) message(FATAL_ERROR "ament_cppcheck() could not find program 'ament_cppcheck'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_cppcheck_BIN}" "--xunit-file" "${result_file}") list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) if(ARG_EXCLUDE) list(APPEND cmd "--exclude" "${ARG_EXCLUDE}") endif() if(ARG_LANGUAGE) string(TOLOWER ${ARG_LANGUAGE} ARG_LANGUAGE) list(APPEND cmd "--language" "${ARG_LANGUAGE}") endif() if(ARG_LIBRARIES) list(APPEND cmd "--libraries" "${ARG_LIBRARIES}") endif() if(ARG_INCLUDE_DIRS) list(APPEND cmd "--include_dirs" "${ARG_INCLUDE_DIRS}") endif() file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_cppcheck") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} TIMEOUT 300 OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_cppcheck/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "cppcheck;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_cppcheck/doc/000077500000000000000000000000001420377356500206115ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_cppcheck/doc/index.rst000066400000000000000000000024141420377356500224530ustar00rootroot00000000000000ament_cppcheck ============== Performs a static code analysis of C / C++ source files using `CppCheck `_. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_cppcheck `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_cppcheck ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_cppcheck REQUIRED) ament_cppcheck() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_cppcheck/package.xml000066400000000000000000000022471420377356500221660ustar00rootroot00000000000000 ament_cmake_cppcheck 0.12.0 The CMake API for ament_cppcheck to perform static code analysis on C/C++ code using Cppcheck. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_cmake_core ament_cmake_test ament_cppcheck ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_cpplint/000077500000000000000000000000001420377356500177355ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_cpplint/CHANGELOG.rst000066400000000000000000000103141420377356500217550ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_cpplint ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ * Updated cpplint and cppcheck to exclude directories and files (`#234 `_) * UPted cpplint and cppcheck to exclude directories and files * setting a global variable to configure automatic linting * Fixed cmake docbloc * Added feedback * Allowed cpplint to exclude files * Restored cpplint.py * Contributors: Alejandro Hernández Cordero 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * Increase cpplint timeout (`#90 `_) * increase cpplint timeout to 120 seconds * expose timeout and use 120 as default rather than hard coding it * copy-n-paste * add filters argument to cpplint (`#87 `_) * add filters argument to cpplint * full ellipsis * string -> strings * 0.0.3 * 0.0.2 * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#51 `_ from ament/lint_generated_code extend linter API to allow overriding the max line length * add CMake argument to override max line length for linters as well as the root for cpplint * Merge pull request `#50 `_ from ament/ctest_build_testing use CTest BUILD_TESTING * use CTest BUILD_TESTING * Merge pull request `#41 `_ from ament/use_message_status avoid using message without STATUS * avoid using message without STATUS * Merge pull request `#39 `_ from ament/cpplint_python3 use Python 3 for cpplint and split into Python and CMake package * refactor ament_cpplint into Python and CMake package * Contributors: Dirk Thomas, Mikael Arguedas ament_lint-0.12.0/ament_cmake_cpplint/CMakeLists.txt000066400000000000000000000007031420377356500224750ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_cpplint NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_cpplint-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_cpplint/ament_cmake_cpplint-extras.cmake000066400000000000000000000015671420377356500262510ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_cpplint/ament_cmake_cpplint-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_cpplint_DIR}/ament_cpplint.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_cpplint" "ament_cmake_cpplint_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_cpplint/cmake/000077500000000000000000000000001420377356500210155ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_cpplint/cmake/ament_cmake_cpplint_lint_hook.cmake000066400000000000000000000022131420377356500300600ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" ) if(_source_files) message(STATUS "Added test 'cpplint' to check C / C++ code against the Google style") # Get exclude paths for added targets set(_all_exclude "") if(DEFINED ament_cmake_cpplint_ADDITIONAL_EXCLUDE) list(APPEND _all_exclude ${ament_cmake_cpplint_ADDITIONAL_EXCLUDE}) endif() message(STATUS "Configured cpplint exclude dirs and/or files: ${_all_exclude}") ament_cpplint(EXCLUDE ${_all_exclude}) endif() ament_lint-0.12.0/ament_cmake_cpplint/cmake/ament_cpplint.cmake000066400000000000000000000052621420377356500246610ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check the code for compliance with cpplint. # # :param TESTNAME: the name of the test, default: "cpplint" # :type TESTNAME: string # :param FILTERS: list of category filters to apply # :type FILTERS: list of strings # :param MAX_LINE_LENGTH: override the maximum line length, # the default is defined in ament_cpplint # :type MAX_LINE_LENGTH: integer # :param ROOT: override the --root option of cpplint # :type ROOT: string # :param TIMEOUT: the test timeout in seconds, default: 120 # :type TIMEOUT: integer # :param EXCLUDE: an optional list of exclude directories or files for cpplint # :type EXCLUDE: list # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_cpplint) cmake_parse_arguments(ARG "" "EXCLUDE;MAX_LINE_LENGTH;ROOT;TESTNAME;TIMEOUT" "FILTERS" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "cpplint") endif() find_program(ament_cpplint_BIN NAMES "ament_cpplint") if(NOT ament_cpplint_BIN) message(FATAL_ERROR "ament_cpplint() could not find program 'ament_cpplint'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_cpplint_BIN}" "--xunit-file" "${result_file}") if(ARG_EXCLUDE) list(APPEND cmd "--exclude" "${ARG_EXCLUDE}") endif() if(ARG_FILTERS) string(REPLACE ";" "," filters "${ARG_FILTERS}") list(APPEND cmd "--filters=${filters}") endif() if(ARG_MAX_LINE_LENGTH) list(APPEND cmd "--linelength" "${ARG_MAX_LINE_LENGTH}") endif() if(ARG_ROOT) list(APPEND cmd "--root" "${ARG_ROOT}") endif() list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) if(NOT ARG_TIMEOUT) set(ARG_TIMEOUT 120) endif() file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_cpplint") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_cpplint/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" TIMEOUT "${ARG_TIMEOUT}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "cpplint;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_cpplint/doc/000077500000000000000000000000001420377356500205025ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_cpplint/doc/index.rst000066400000000000000000000024131420377356500223430ustar00rootroot00000000000000ament_cmake_cpplint =================== Checks the code style of C / C++ source files using `cpplint `_. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_cpplint `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_cpplint ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_cpplint REQUIRED) ament_cpplint() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_cpplint/package.xml000066400000000000000000000021001420377356500220430ustar00rootroot00000000000000 ament_cmake_cpplint 0.12.0 The CMake API for ament_cpplint to lint C / C++ code using cpplint. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_cmake_test ament_cpplint ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_flake8/000077500000000000000000000000001420377356500174365ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_flake8/CHANGELOG.rst000066400000000000000000000075131420377356500214650ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_flake8 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Add custom config file support for flake8 (`#331 `_) * Contributors: Audrow Nash, Kenji Miyake 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Contributors: Audrow Nash 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ * Change spelling of maintainer name. (`#115 `_) This is causing failures in CI at the moment. Until I figure out where the issue lies let's just mispell it to unbreak CI. * Contributors: Steven! Ragnarök 0.6.1 (2018-11-15) ------------------ * Update maintainer for ament{,_cmake}_flake8. (`#114 `_) * Contributors: Steven! Ragnarök 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * Test python module import order using flake8 (`#63 `_) * Add flake8 linter * Don't deal with flake8-import-order just yet * Debugging prints * Reinstate import order rule * Fix reporting bug by using the inner flake8 style guide * Fixup * Add comment on wrapper StyleGuide use * use flake8 v3 (`#1 `_) * Reorder package.xml * Get the filenames from the file checkers because input_file isn't called by flake8 anymore * Output count of all error types * Get flake8 to use the config file The current implementation of get_style_guide does not process the config file correctly. * Error when flake8 v2 found * Print errors like pep8 * remove __future_\_ imports * add schema to manifest files * Support flake8 v2 as well as v3 * Output checked files otherwise it's not present in xunit files for tests run directly with nose (not ament_cmake_flake8) * Prevent v2 imports from happening on systems with v3 * Flake8 replaces pep8+pyflakes * Contributors: Dirk Thomas, dhood ament_lint-0.12.0/ament_cmake_flake8/CMakeLists.txt000066400000000000000000000007011420377356500221740ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_flake8 NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_flake8-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_flake8/ament_cmake_flake8-extras.cmake000066400000000000000000000015541420377356500254470ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_flake8/ament_cmake_flake8-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_flake8_DIR}/ament_flake8.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_flake8" "ament_cmake_flake8_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_flake8/cmake/000077500000000000000000000000001420377356500205165ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_flake8/cmake/ament_cmake_flake8_lint_hook.cmake000066400000000000000000000014271420377356500272700ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _python_files FOLLOW_SYMLINKS "*.py") if(_python_files) message(STATUS "Added test 'flake8' to check Python code syntax and style conventions") ament_flake8() endif() ament_lint-0.12.0/ament_cmake_flake8/cmake/ament_flake8.cmake000066400000000000000000000052431420377356500240620ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check the Python code for syntax and style compliance # using flake8. # # The default configuration file for flake8 is located at # configuration/ament_flake8.ini within the ament_flake8 directory # The default configuration file can be either overridden by the # argument 'CONFIG_FILE' or by a global variable named # 'ament_cmake_flake8_CONFIG_FILE' # The 'CONFIG_FILE' argument takes priority over # 'ament_cmake_flake8_CONFIG_FILE' if both are defined # # :param TESTNAME: the name of the test, default: "flake8" # :type TESTNAME: string # :param CONFIG_FILE: the path of the configuration file for flake8 to consider # :type CONFIG_FILE: string # :param MAX_LINE_LENGTH: override the maximum line length, # the default is defined in ament_flake8 # :type MAX_LINE_LENGTH: integer # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_flake8) cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME;CONFIG_FILE" "" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "flake8") endif() find_program(ament_flake8_BIN NAMES "ament_flake8") if(NOT ament_flake8_BIN) message(FATAL_ERROR "ament_flake8() could not find program 'ament_flake8'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_flake8_BIN}" "--xunit-file" "${result_file}") if(ARG_CONFIG_FILE) list(APPEND cmd "--config" "${ARG_CONFIG_FILE}") elseif(DEFINED ament_cmake_flake8_CONFIG_FILE) list(APPEND cmd "--config" "${ament_cmake_flake8_CONFIG_FILE}") endif() if(ARG_MAX_LINE_LENGTH) list(APPEND cmd "--linelength" "${ARG_MAX_LINE_LENGTH}") endif() list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_flake8") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_flake8/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "flake8;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_flake8/doc/000077500000000000000000000000001420377356500202035ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_flake8/doc/index.rst000066400000000000000000000023071420377356500220460ustar00rootroot00000000000000ament_cmake_flake8 ================== Checks the code syntax and style of Python source files using `flake8 `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_flake8 `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_flake8 ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_flake8 REQUIRED) ament_flake8() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_flake8/package.xml000066400000000000000000000021211420377356500215470ustar00rootroot00000000000000 ament_cmake_flake8 0.12.0 The CMake API for ament_flake8 to check code syntax and style conventions with flake8. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang D. Hood ament_cmake_core ament_cmake_test ament_cmake_test ament_flake8 ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_lint_cmake/000077500000000000000000000000001420377356500203725ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_lint_cmake/CHANGELOG.rst000066400000000000000000000105651420377356500224220ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_lint_cmake ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- * ament_lint_cmake: default linelength in argumentparser for consistency (`#306 `_) * Contributors: Emerson Knapp 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Fix ament_lint_cmake line length expression (`#236 `_) This regular expression is using the re.VERBOSE flag, meaning that characters after an un-escaped '#' character are interpreted as a comment and are not part of the expression. Also set the default maximum line length to 140 columns. * Add Audrow as a maintainer (`#294 `_) * Make CMake linter line length configurable (`#235 `_) Co-authored-by: Miaofei * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#50 `_ from ament/ctest_build_testing use CTest BUILD_TESTING * use CTest BUILD_TESTING * Merge pull request `#41 `_ from ament/use_message_status avoid using message without STATUS * avoid using message without STATUS * Merge pull request `#30 `_ from ament/test_labels add labels to tests * add labels to tests * Merge pull request `#29 `_ from ament/change_test_dependencies update documentation for linters * update documentation for linters * Merge pull request `#27 `_ from ament/gtest_location add type as extension to test result files * add type as extension to test result files * add explicit build type * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * move cmake part of ament_lint_cmake to ament_cmake_lint_cmake * Contributors: Dirk Thomas ament_lint-0.12.0/ament_cmake_lint_cmake/CMakeLists.txt000066400000000000000000000010031420377356500231240ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_lint_cmake NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) # include CMake functions of this package set(ament_cmake_lint_cmake_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include("ament_cmake_lint_cmake-extras.cmake" NO_POLICY_SCOPE) ament_package( CONFIG_EXTRAS "ament_cmake_lint_cmake-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_lint_cmake/ament_cmake_lint_cmake-extras.cmake000066400000000000000000000016111420377356500273310ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_lint_cmake/ament_cmake_lint_cmake-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_lint_cmake_DIR}/ament_lint_cmake.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_lint_cmake" "ament_cmake_lint_cmake_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_lint_cmake/cmake/000077500000000000000000000000001420377356500214525ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_lint_cmake/cmake/ament_cmake_lint_cmake_lint_hook.cmake000066400000000000000000000014361420377356500311600ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _cmake_files FOLLOW_SYMLINKS "CMakeLists.txt" "*.cmake" ) if(_cmake_files) message(STATUS "Added test 'lint_cmake' to check CMake code style") ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_lint_cmake/cmake/ament_lint_cmake.cmake000066400000000000000000000037571420377356500257620ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to lint the CMake code. # # :param TESTNAME: the name of the test, default: "lint_cmake" # :type TESTNAME: string # :param MAX_LINE_LENGTH: override the maximum line length, # the default is defined in ament_lint_cmake # :type MAX_LINE_LENGTH: integer # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_lint_cmake) cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME" "" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "lint_cmake") endif() find_program(ament_lint_cmake_BIN NAMES "ament_lint_cmake") if(NOT ament_lint_cmake_BIN) message(FATAL_ERROR "ament_lint_cmake() could not find program 'ament_lint_cmake'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_lint_cmake_BIN}" "--xunit-file" "${result_file}") if(DEFINED ARG_MAX_LINE_LENGTH) list(APPEND cmd "--linelength" "${ARG_MAX_LINE_LENGTH}") endif() list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_lint_cmake") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_lint_cmake/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "lint_cmake;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_lint_cmake/doc/000077500000000000000000000000001420377356500211375ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_lint_cmake/doc/index.rst000066400000000000000000000023471420377356500230060ustar00rootroot00000000000000ament_lint_cmake ================ Checks the code style of CMake files using `CMakeLint `_. Files with the following names / extensions are being considered: ``CMakeLists.txt``, ``.cmake``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_lint_cmake `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_lint_cmake ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_lint_cmake/package.xml000066400000000000000000000020311420377356500225030ustar00rootroot00000000000000 ament_cmake_lint_cmake 0.12.0 The CMake API for ament_lint_cmake to lint CMake code using cmakelint. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_lint_cmake ament_cmake_test ament_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_mypy/000077500000000000000000000000001420377356500172625ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_mypy/CHANGELOG.rst000066400000000000000000000065411420377356500213110ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_mypy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Contributors: Audrow Nash 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ * fix cmake plugin to use correct config file argument keyword (`#181 `_) * add mypy support for linters/testing (`#154 `_) * add mypy support for linters/testing * Update ament_cmake_mypy/doc/index.rst Co-Authored-By: Kyle Fazzari * fix whitespace in file and in generated xml * fixes, package versioning, and test suite * fix wrong separator in cmake file * readd copied from comment * Update ament_mypy/ament_mypy/main.py Co-Authored-By: Kyle Fazzari * remove mypypath auto populating * add default configuration ignoring missing imports * update test to remove MYPYPATH check, default config check * remove extraneous path insert statement * remove extraneous path insert statement * update test cases for default config file change * added tests for error code forwarding, fixed linter errors * linter failures relating to quotes and docs * add handling for notes * remove ament_lint dep * update regex to match drive letter on windows * Contributors: Ted Kern 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_cmake_mypy/CMakeLists.txt000066400000000000000000000006751420377356500220320ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_mypy NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_mypy-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_mypy/ament_cmake_mypy-extras.cmake000066400000000000000000000014141420377356500251120ustar00rootroot00000000000000# Copyright 2019 Canonical, Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_mypy_DIR}/ament_mypy.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_mypy" "ament_cmake_mypy_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_mypy/cmake/000077500000000000000000000000001420377356500203425ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_mypy/cmake/ament_cmake_mypy_lint_hook.cmake000066400000000000000000000014601420377356500267350ustar00rootroot00000000000000# Copyright 2019 Canonical, Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # copied from ament_cmake_mypy/ament_cmake_mypy-extras.cmake file(GLOB_RECURSE _python_files FOLLOW_SYMLINKS "*.py") if(_python_files) message(STATUS "Added test 'mypy' to statically type check Python code.") ament_mypy() endif() ament_lint-0.12.0/ament_cmake_mypy/cmake/ament_mypy.cmake000066400000000000000000000035321420377356500235310ustar00rootroot00000000000000# Copyright 2019 Canonical, Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to statically check Python types using mypy. # # :param CONFIG_FILE: the name of the config file to use, if any # :type CONFIG_FILE: string # :param TESTNAME: the name of the test, default: "mypy" # :type TESTNAME: string # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_mypy) cmake_parse_arguments(ARG "" "CONFIG_FILE;TESTNAME" "" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "mypy") endif() find_program(ament_mypy_BIN NAMES "ament_mypy") if(NOT ament_mypy_BIN) message(FATAL_ERROR "ament_mypy() could not find program 'ament_mypy'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_mypy_BIN}" "--xunit-file" "${result_file}") if(ARG_CONFIG_FILE) list(APPEND cmd "--config" "${ARG_CONFIG_FILE}") endif() list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_mypy") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_mypy/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "mypy;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_mypy/doc/000077500000000000000000000000001420377356500200275ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_mypy/doc/index.rst000066400000000000000000000022701420377356500216710ustar00rootroot00000000000000ament_cmake_mypy ================== Checks the code syntax and style of Python source files using `mypy `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_mypy `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_mypy ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_mypy REQUIRED) ament_mypy() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_mypy/package.xml000066400000000000000000000021551420377356500214020ustar00rootroot00000000000000 ament_cmake_mypy 0.12.0 The CMake API for ament_mypy to perform static type analysis on python code with mypy. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Ted Kern ament_cmake_core ament_cmake_test ament_cmake_test ament_mypy ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_pclint/000077500000000000000000000000001420377356500175555ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pclint/CHANGELOG.rst000066400000000000000000000070171420377356500216030ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_pclint ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ * Improvements to ament_pclint configuration (`#112 `_) * Improvements to ament_pclint configuration * Improvement to ament_cmake_pclint * Contributors: jpsamper2009 0.5.2 (2018-06-27) ------------------ * Add ament_pclint and ament_cmake_pclint packages (`#101 `_) * Add ament_pclint and ament_cmake_pclint packages * Skip pclint creation if pclint executable not found * Update license to Apache 2.0 - Use config file with permissive license: http://www.gimpel.com/html/pub90/au-misra3.lnt * Fixing copyright and formatting issues. * Add test dependencies * Fix remaining copyright/license notices. * Version Bump to 0.5.1 for pclint packages. * Contributors: Michael Carroll 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ * Revert "Add ament package for pclint" (`#100 `_) * Merge pull request `#98 `_ from jpsamper2009/ament_pclint Add ament package for pclint * Skip pclint creation if pclint executable not found * Add ament_pclint and ament_cmake_pclint packages * Contributors: Juan Pablo Samper, Michael Carroll 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_cmake_pclint/CMakeLists.txt000066400000000000000000000007011420377356500223130ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_pclint NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_pclint-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_pclint/ament_cmake_pclint-extras.cmake000066400000000000000000000015231420377356500257010ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # Copyright 2017-2018 Apex.AI, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_pclint_DIR}/ament_pclint.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_pclint" "ament_cmake_pclint_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_pclint/cmake/000077500000000000000000000000001420377356500206355ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pclint/cmake/ament_cmake_pclint_lint_hook.cmake000066400000000000000000000015421420377356500275240ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # Copyright 2017-2018 Apex.AI, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS "*.c" "*.cc" "*.cpp" "*.cxx" "*.c++" ) if(_source_files) message(STATUS "Added test 'pclint' to perform static code analysis on C / C++ code") ament_pclint() endif() ament_lint-0.12.0/ament_cmake_pclint/cmake/ament_pclint.cmake000066400000000000000000000072751420377356500243270ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # Copyright 2017-2018 Apex.AI, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Add a test to perform static code analysis with pclint. # # :param TESTNAME: the name of the test, default: "pclint" # :type TESTNAME: string # :param LANGUAGE: force analysis to a specific language. Either "c" or "cpp" # :type LANGUAGE: string # :param LNT_FILE: Full-path of a custom lnt file. # :type LNT_FILE: string # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public function(ament_pclint) cmake_parse_arguments(ARG "" "LANGUAGE;TESTNAME;LNT_FILE" "INCLUDE_DIRS;COMPILE_DEFS" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "pclint") endif() find_program(ament_pclint_BIN NAMES "ament_pclint") if(NOT ament_pclint_BIN) message(FATAL_ERROR "ament_pclint() could not find program 'ament_pclint'") endif() set(cmd "${ament_pclint_BIN}" ${ARG_UNPARSED_ARGUMENTS}) get_property(INCLUDED_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) if(INCLUDED_DIRS) list(APPEND cmd "--include-directories" ${INCLUDED_DIRS}) set(_INCLUDE_DIRS_FLAG_SET "Found") endif() # Include 'include' folders in AMENT_PREFIX_PATH if(ARG_INCLUDE_DIRS) if(NOT _INCLUDE_DIRS_FLAG_SET) list(APPEND cmd "--include-directories") set(_INCLUDED_DIRS_FLAG_SET "Found") endif() foreach(path ${ARG_INCLUDE_DIRS}) list(APPEND cmd "${path}/include") endforeach() endif() get_directory_property(COMPILE_DEFS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) if(COMPILE_DEFS) list(APPEND cmd "--compiler-definitions" "${COMPILE_DEFS}") set(_COMPILE_DEFS_FLAG_SET "Found") endif() # Add user-specificied compiler-definitions if(ARG_COMPILE_DEFS) if(NOT _COMPILE_DEFS_FLAG_SET) list(APPEND cmd "--compiler-definitions") set(_COMPILE_DEFS_FLAG_SET "Found") endif() foreach(def ${ARG_COMPILE_DEFS}) list(APPEND cmd "${def}") endforeach() endif() if(ARG_LANGUAGE) list(APPEND cmd "--language" "${ARG_LANGUAGE}") endif() if(ARG_LNT_FILE) list(APPEND cmd "--pclint-config-file" ${ARG_LNT_FILE}) endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") list(APPEND cmd "--xunit-file" "${result_file}") file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_pclint") set(pclint_exec "pclp64") # Windows executable name if(APPLE) set(pclint_exec "${pclint_exec}_osx") elseif(UNIX) # i.e. UNIX AND NOT APPLE set(pclint_exec "${pclint_exec}_linux") endif() find_program(pclint_BIN NAMES "${pclint_exec}") if(pclint_BIN) ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_pclint/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" TIMEOUT 120) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "pclint;linter" ) else() message(WARNING "WARNING: ${pclint_exec} not found, skipping pclint test creation") endif() endfunction() ament_lint-0.12.0/ament_cmake_pclint/doc/000077500000000000000000000000001420377356500203225ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pclint/doc/index.rst000066400000000000000000000021311420377356500221600ustar00rootroot00000000000000ament_pclint ============== Performs a static code analysis of C / C++ source files using `PCLint `_. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_pclint`_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_pclint ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_pclint REQUIRED) ament_pclint() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_pclint/package.xml000066400000000000000000000021711420377356500216730ustar00rootroot00000000000000 ament_cmake_pclint 0.12.0 The CMake API for ament_pclint to perform static code analysis on C/C++ code using PCLint. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Juan Pablo Samper ament_cmake_core ament_cmake_test ament_cmake_test ament_pclint ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_pep257/000077500000000000000000000000001420377356500173065ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pep257/CHANGELOG.rst000066400000000000000000000066671420377356500213460ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_pep257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#50 `_ from ament/ctest_build_testing use CTest BUILD_TESTING * use CTest BUILD_TESTING * Merge pull request `#41 `_ from ament/use_message_status avoid using message without STATUS * avoid using message without STATUS * Merge pull request `#30 `_ from ament/test_labels add labels to tests * add labels to tests * Merge pull request `#29 `_ from ament/change_test_dependencies update documentation for linters * update documentation for linters * Merge pull request `#28 `_ from ament/pep257 add packages to check pep257 compliance * add ament_cmake_pep257 package * Contributors: Dirk Thomas ament_lint-0.12.0/ament_cmake_pep257/CMakeLists.txt000066400000000000000000000007011420377356500220440ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_pep257 NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_pep257-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_pep257/ament_cmake_pep257-extras.cmake000066400000000000000000000015541420377356500251670ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_pep257/ament_cmake_pep257-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_pep257_DIR}/ament_pep257.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_pep257" "ament_cmake_pep257_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_pep257/cmake/000077500000000000000000000000001420377356500203665ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pep257/cmake/ament_cmake_pep257_lint_hook.cmake000066400000000000000000000014531420377356500270070ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _python_files FOLLOW_SYMLINKS "*.py") if(_python_files) message(STATUS "Added test 'pep257' to check Python code against some of the style conventions in PEP 257") ament_pep257() endif() ament_lint-0.12.0/ament_cmake_pep257/cmake/ament_pep257.cmake000066400000000000000000000033271420377356500236030ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check the Python docblocks for compliance with PEP257. # # :param TESTNAME: the name of the test, default: "pep257" # :type TESTNAME: string # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_pep257) cmake_parse_arguments(ARG "" "TESTNAME" "" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "pep257") endif() find_program(ament_pep257_BIN NAMES "ament_pep257") if(NOT ament_pep257_BIN) message(FATAL_ERROR "ament_pep257() could not find program 'ament_pep257'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_pep257_BIN}" "--xunit-file" "${result_file}") list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_pep257") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_pep257/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "pep257;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_pep257/doc/000077500000000000000000000000001420377356500200535ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pep257/doc/index.rst000066400000000000000000000022601420377356500217140ustar00rootroot00000000000000ament_pep257 ============ Checks the code style of Python source files using `pep257 `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_pep257 `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_pep257 ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_pep257 REQUIRED) ament_pep257() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_pep257/package.xml000066400000000000000000000021251420377356500214230ustar00rootroot00000000000000 ament_cmake_pep257 0.12.0 The CMake API for ament_pep257 to check code against the style conventions in PEP 257. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_cmake_test ament_pep257 ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_pycodestyle/000077500000000000000000000000001420377356500206305ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pycodestyle/CHANGELOG.rst000066400000000000000000000056441420377356500226620ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_pycodestyle ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Rename pep8 packages to pycodestyle (part 2 of 2) The python package 'pep8' has been renamed to 'pycodestyle'. This change follows suit by renaming ament_pep8 and ament_cmake_pep8 to ament_pycodestyle and ament_cmake_pycodestyle respectively. * Rename pep8 packages to pycodestyle (part 1 of 2) The python package 'pep8' has been renamed to 'pycodestyle'. This change follows suit by renaming ament_pep8 and ament_cmake_pep8 to ament_pycodestyle and ament_cmake_pycodestyle respectively. * Contributors: Chris Lalancette, Scott K Logan 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_cmake_pycodestyle/CMakeLists.txt000066400000000000000000000007131420377356500233710ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_pycodestyle NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_pycodestyle-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_pycodestyle/ament_cmake_pycodestyle-extras.cmake000066400000000000000000000016251420377356500300320ustar00rootroot00000000000000# Copyright 2014-2015, 2020 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_pycodestyle/ament_cmake_pycodestyle-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_pycodestyle_DIR}/ament_pycodestyle.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_pycodestyle" "ament_cmake_pycodestyle_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_pycodestyle/cmake/000077500000000000000000000000001420377356500217105ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pycodestyle/cmake/ament_cmake_pycodestyle_lint_hook.cmake000066400000000000000000000014711420377356500316530ustar00rootroot00000000000000# Copyright 2015, 2020 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _python_files FOLLOW_SYMLINKS "*.py") if(_python_files) message(STATUS "Added test 'pycodestyle' to check Python code against some of the style conventions in PEP 8") ament_pycodestyle() endif() ament_lint-0.12.0/ament_cmake_pycodestyle/cmake/ament_pycodestyle.cmake000066400000000000000000000040261420377356500264440ustar00rootroot00000000000000# Copyright 2014-2015, 2020 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check the Python code for compliance with PEP8. # # :param TESTNAME: the name of the test, default: "pycodestyle" # :type TESTNAME: string # :param MAX_LINE_LENGTH: override the maximum line length, # the default is defined in ament_cpplint # :type MAX_LINE_LENGTH: integer # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_pycodestyle) cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME" "" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "pycodestyle") endif() find_program(ament_pycodestyle_BIN NAMES "ament_pycodestyle") if(NOT ament_pycodestyle_BIN) message(FATAL_ERROR "ament_pycodestyle() could not find program 'ament_pycodestyle'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_pycodestyle_BIN}" "--xunit-file" "${result_file}") if(ARG_MAX_LINE_LENGTH) list(APPEND cmd "--linelength" "${ARG_MAX_LINE_LENGTH}") endif() list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_pycodestyle") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_pycodestyle/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "pep8;pycodestyle;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_pycodestyle/doc/000077500000000000000000000000001420377356500213755ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pycodestyle/doc/index.rst000066400000000000000000000023441420377356500232410ustar00rootroot00000000000000ament_cmake_pycodestyle ======================= Checks the code style of Python source files using `pycodestyle `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_pycodestyle `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_pycodestyle ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_pycodestyle REQUIRED) ament_pycodestyle() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_pycodestyle/package.xml000066400000000000000000000021421420377356500227440ustar00rootroot00000000000000 ament_cmake_pycodestyle 0.12.0 The CMake API for ament_pycodestyle to check code against the style conventions in PEP 8. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_cmake_test ament_pycodestyle ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_pyflakes/000077500000000000000000000000001420377356500201025ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pyflakes/CHANGELOG.rst000066400000000000000000000073741420377356500221360ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_pyflakes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#50 `_ from ament/ctest_build_testing use CTest BUILD_TESTING * use CTest BUILD_TESTING * Merge pull request `#41 `_ from ament/use_message_status avoid using message without STATUS * avoid using message without STATUS * Merge pull request `#30 `_ from ament/test_labels add labels to tests * add labels to tests * Merge pull request `#29 `_ from ament/change_test_dependencies update documentation for linters * update documentation for linters * Merge pull request `#27 `_ from ament/gtest_location add type as extension to test result files * add type as extension to test result files * add explicit build type * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * make use of python linter packages * move cmake part of ament_pyflakes to ament_cmake_pyflakes * Contributors: Dirk Thomas ament_lint-0.12.0/ament_cmake_pyflakes/CMakeLists.txt000066400000000000000000000007051420377356500226440ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_pyflakes NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_pyflakes-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_pyflakes/ament_cmake_pyflakes-extras.cmake000066400000000000000000000015751420377356500265620ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_pyflakes/ament_cmake_pyflakes-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_pyflakes_DIR}/ament_pyflakes.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_pyflakes" "ament_cmake_pyflakes_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_pyflakes/cmake/000077500000000000000000000000001420377356500211625ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pyflakes/cmake/ament_cmake_pyflakes_lint_hook.cmake000066400000000000000000000014301420377356500303720ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _python_files FOLLOW_SYMLINKS "*.py") if(_python_files) message(STATUS "Added test 'pyflakes' to perform static code analysis on Python code") ament_pyflakes() endif() ament_lint-0.12.0/ament_cmake_pyflakes/cmake/ament_pyflakes.cmake000066400000000000000000000033521420377356500251710ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check the code for compliance with pyflakes. # # :param TESTNAME: the name of the test, default: "pyflakes" # :type TESTNAME: string # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_pyflakes) cmake_parse_arguments(ARG "" "TESTNAME" "" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "pyflakes") endif() find_program(ament_pyflakes_BIN NAMES "ament_pyflakes") if(NOT ament_pyflakes_BIN) message(FATAL_ERROR "ament_pyflakes() could not find program 'ament_pyflakes'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_pyflakes_BIN}" "--xunit-file" "${result_file}") list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_pyflakes") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_pyflakes/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "pyflakes;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_pyflakes/doc/000077500000000000000000000000001420377356500206475ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_pyflakes/doc/index.rst000066400000000000000000000022761420377356500225170ustar00rootroot00000000000000ament_pyflakes ============== Checks the code style of Python source files using `Pyflakes `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_pyflakes `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_pyflakes ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_pyflakes REQUIRED) ament_pyflakes() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_pyflakes/package.xml000066400000000000000000000020751420377356500222230ustar00rootroot00000000000000 ament_cmake_pyflakes 0.12.0 The CMake API for ament_pyflakes to check code using pyflakes. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_cmake_test ament_pyflakes ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_uncrustify/000077500000000000000000000000001420377356500204775ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_uncrustify/CHANGELOG.rst000066400000000000000000000141011420377356500225150ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_uncrustify ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * [ament_cmake_uncrustify] Add file exclude support (`#330 `_) In the `ament_uncrustify` CMake function, the optional list argument `EXCLUDE` can now be used as an exclusion specifier. * Contributors: Abrar Rahman Protyasha, Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * parse LANGUAGE argument case insensitive (`#255 `_) * Contributors: Karsten Knese 0.9.4 (2020-05-26) ------------------ * aditional -> additional (`#250 `_) * Contributors: Chris Lalancette 0.9.3 (2020-05-18) ------------------ * Updated cpplint and cppcheck to exclude directories and files (`#234 `_) * UPted cpplint and cppcheck to exclude directories and files * setting a global variable to configure automatic linting * Fixed cmake docbloc * Added feedback * Allowed cpplint to exclude files * Restored cpplint.py * Contributors: Alejandro Hernández Cordero 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * add ament_lint_common doc (`#218 `_) * adding ament_lint_common doc * add links to common linters * change ament_uncrustify link * pass explicit language to uncrustify (`#214 `_) * pass explicitl language to uncrustify * remove dst before renaming file to work on Windows * use dict comprehension * conditionally pass -l in both commands * remove unncessary line * fix comprehension * fix dict after fiddling with comprehension * add CMake option for force specific language for uncrustify * feedback about help message * Allow custom config file for ament_uncrustify (`#200 `_) * parse arguements for CONFIG_FILE and append to cmd * removed newline * fixed description * corrected location of default configuration file in docblock * fixed alignment in docblock * reverted deletion of empty line after copyright header * Contributors: Chris Lalancette, Dirk Thomas, Marya Belanger, Yadu 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ * [ament_uncrustify] Account for zero value in line length cmake arg A zero value will cause uncrustify to ignore line length. * Contributors: Jacob Perron 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#51 `_ from ament/lint_generated_code extend linter API to allow overriding the max line length * add CMake argument to override max line length for linters as well as the root for cpplint * Merge pull request `#50 `_ from ament/ctest_build_testing use CTest BUILD_TESTING * use CTest BUILD_TESTING * Merge pull request `#41 `_ from ament/use_message_status avoid using message without STATUS * avoid using message without STATUS * Merge pull request `#30 `_ from ament/test_labels add labels to tests * add labels to tests * Merge pull request `#29 `_ from ament/change_test_dependencies update documentation for linters * update documentation for linters * Merge pull request `#27 `_ from ament/gtest_location add type as extension to test result files * add type as extension to test result files * add explicit build type * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * make use of python linter packages * move cmake part of ament_uncrustify to ament_cmake_uncrustify * Contributors: Dirk Thomas ament_lint-0.12.0/ament_cmake_uncrustify/CMakeLists.txt000066400000000000000000000007111420377356500232360ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_uncrustify NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_uncrustify-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_uncrustify/ament_cmake_uncrustify-extras.cmake000066400000000000000000000016111420377356500275430ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_uncrustify/ament_cmake_uncrustify-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_uncrustify_DIR}/ament_uncrustify.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_uncrustify" "ament_cmake_uncrustify_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_uncrustify/cmake/000077500000000000000000000000001420377356500215575ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_uncrustify/cmake/ament_cmake_uncrustify_lint_hook.cmake000066400000000000000000000020601420377356500313640ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" ) if(_source_files) message(STATUS "Added test 'uncrustify' to check C / C++ code style") set(_args "") if(DEFINED ament_cmake_uncrustify_ADDITIONAL_ARGS) list(APPEND _args ${ament_cmake_uncrustify_ADDITIONAL_ARGS}) endif() message(STATUS "Configured uncrustify additional arguments: ${_args}") ament_uncrustify(${_args}) endif() ament_lint-0.12.0/ament_cmake_uncrustify/cmake/ament_uncrustify.cmake000066400000000000000000000056571420377356500261750ustar00rootroot00000000000000# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check the code for compliance with uncrustify. # # The default configuration file used for uncrustify is located at # configuration/ament_code_style.cfg within the ament_uncrustify directory. # The default configuration file can be overridden by the # argument 'CONFIG_FILE'. # # :param TESTNAME: the name of the test, default: "uncrustify" # :type TESTNAME: string # :param CONFIG_FILE: the path of the configuration file for # uncrustify to consider # :type CONFIG_FILE: string # :param MAX_LINE_LENGTH: override the maximum line length, # the default is defined in ament_uncrustify # :type MAX_LINE_LENGTH: integer # :param LANGUAGE: a specific language argument for uncrustify instead of # deriving the language from the file extension, either 'C' or 'C++' # :type LANGUAGE: string # :param EXCLUDE: an optional list of exclude files or directories for uncrustify # :type EXCLUDE: list # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_uncrustify) cmake_parse_arguments(ARG "" "CONFIG_FILE;LANGUAGE;MAX_LINE_LENGTH;TESTNAME" "EXCLUDE" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "uncrustify") endif() find_program(ament_uncrustify_BIN NAMES "ament_uncrustify") if(NOT ament_uncrustify_BIN) message(FATAL_ERROR "ament_uncrustify() could not find program 'ament_uncrustify'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_uncrustify_BIN}" "--xunit-file" "${result_file}") if(DEFINED ARG_MAX_LINE_LENGTH) list(APPEND cmd "--linelength" "${ARG_MAX_LINE_LENGTH}") endif() if(ARG_CONFIG_FILE) list(APPEND cmd "-c" "${ARG_CONFIG_FILE}") endif() if(ARG_LANGUAGE) string(TOUPPER ${ARG_LANGUAGE} ARG_LANGUAGE) list(APPEND cmd "--language" "${ARG_LANGUAGE}") endif() if(ARG_EXCLUDE) list(APPEND cmd "--exclude" "${ARG_EXCLUDE}") endif() list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_uncrustify") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_uncrustify/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "uncrustify;linter" ) endfunction() ament_lint-0.12.0/ament_cmake_uncrustify/doc/000077500000000000000000000000001420377356500212445ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_uncrustify/doc/index.rst000066400000000000000000000030011420377356500230770ustar00rootroot00000000000000ament_uncrustify ================ Checks the code style of C / C++ source files using `Uncrustify `_. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_uncrustify `_. Note that ament_uncrustify comes with a command line tool which can automatically reformat the code according to the style guide by calling .. code:: sh ament_uncrustify --reformat How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_uncrustify ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_uncrustify REQUIRED) ament_uncrustify() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_uncrustify/package.xml000066400000000000000000000021421420377356500226130ustar00rootroot00000000000000 ament_cmake_uncrustify 0.12.0 The CMake API for ament_uncrustify to check code against styleconventions using uncrustify. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_cmake_test ament_uncrustify ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_cmake_xmllint/000077500000000000000000000000001420377356500177535ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_xmllint/CHANGELOG.rst000066400000000000000000000051611420377356500217770ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cmake_xmllint ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ * add ament\_(cmake\_)xmllint packages (`#104 `_) * add ament\_(cmake\_)xmllint packages * consider xsi:noNamespaceSchemaLocation of root tag * Contributors: Dirk Thomas 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_cmake_xmllint/CMakeLists.txt000066400000000000000000000007031420377356500225130ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_cmake_xmllint NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_test REQUIRED) ament_package( CONFIG_EXTRAS "ament_cmake_xmllint-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) if(BUILD_TESTING) find_package(ament_cmake_copyright REQUIRED) ament_copyright() find_package(ament_cmake_lint_cmake REQUIRED) ament_lint_cmake() endif() ament_lint-0.12.0/ament_cmake_xmllint/ament_cmake_xmllint-extras.cmake000066400000000000000000000015671420377356500263050ustar00rootroot00000000000000# Copyright 2014-2018 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_cmake_xmllint/ament_cmake_xmllint-extras.cmake find_package(ament_cmake_test QUIET REQUIRED) include("${ament_cmake_xmllint_DIR}/ament_xmllint.cmake") ament_register_extension("ament_lint_auto" "ament_cmake_xmllint" "ament_cmake_xmllint_lint_hook.cmake") ament_lint-0.12.0/ament_cmake_xmllint/cmake/000077500000000000000000000000001420377356500210335ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_xmllint/cmake/ament_cmake_xmllint_lint_hook.cmake000066400000000000000000000014071420377356500301200ustar00rootroot00000000000000# Copyright 2015-2018 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS "*.xml") if(_source_files) message(STATUS "Added test 'xmllint' to check XML markup files") ament_xmllint() endif() ament_lint-0.12.0/ament_cmake_xmllint/cmake/ament_xmllint.cmake000066400000000000000000000041261420377356500247130ustar00rootroot00000000000000# Copyright 2014-2018 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Add a test to check XML files for validity with xmllint. # # :param TESTNAME: the name of the test, default: "xmllint" # :type TESTNAME: string # :param ARGN: the files or directories to check # :type ARGN: list of strings # # @public # function(ament_xmllint) cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME" "" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "xmllint") endif() find_program(ament_xmllint_BIN NAMES "ament_xmllint") if(NOT ament_xmllint_BIN) message(FATAL_ERROR "ament_xmllint() could not find program 'ament_xmllint'") endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") set(cmd "${ament_xmllint_BIN}" "--xunit-file" "${result_file}") list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) find_program(xmllint_BIN NAMES "xmllint") if(NOT xmllint_BIN) if(${CMAKE_VERSION} VERSION_LESS "3.8.0") message(WARNING "WARNING: 'xmllint' not found, skipping xmllint test creation") return() endif() endif() file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_xmllint") ament_add_test( "${ARG_TESTNAME}" COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_xmllint/${ARG_TESTNAME}.txt" RESULT_FILE "${result_file}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES LABELS "xmllint;linter" ) if(NOT xmllint_BIN) set_tests_properties( "${ARG_TESTNAME}" PROPERTIES DISABLED TRUE ) endif() endfunction() ament_lint-0.12.0/ament_cmake_xmllint/doc/000077500000000000000000000000001420377356500205205ustar00rootroot00000000000000ament_lint-0.12.0/ament_cmake_xmllint/doc/index.rst000066400000000000000000000022441420377356500223630ustar00rootroot00000000000000ament_xmllint ============= Checks XML markup files using `xmllint `_. Files with the following extensions are being considered: ``.xml``. How to run the check from the command line? ------------------------------------------- The command line tool is provided by the package `ament_xmllint `_. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- ``package.xml``: .. code:: xml ament_cmake ament_cmake_xmllint ``CMakeLists.txt``: .. code:: cmake find_package(ament_cmake REQUIRED) if(BUILD_TESTING) find_package(ament_cmake_xmllint REQUIRED) ament_xmllint() endif() When running multiple linters as part of the CMake tests the documentation of the package `ament_lint_auto `_ might contain some useful information. The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_cmake_xmllint/package.xml000066400000000000000000000020751420377356500220740ustar00rootroot00000000000000 ament_cmake_xmllint 0.12.0 The CMake API for ament_xmllint to check XML file using xmmlint. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_cmake_test ament_xmllint ament_cmake_copyright ament_cmake_lint_cmake ament_cmake ament_lint-0.12.0/ament_copyright/000077500000000000000000000000001420377356500171345ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/CHANGELOG.rst000066400000000000000000000357561420377356500211750ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_copyright ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * [ament_copyright] Fix file exclusion behavior (`#327 `_) * [ament_copyright] Fix file exclusion behavior This commit fixes the faulty file exclusion behavior reported in https://github.com/ament/ament_lint/issues/326. Specifically, the exclusion list is matched against traversed files in the `crawler` module. Changes inspired by https://github.com/ament/ament_lint/pull/299/. * Update excluded file path in copyright tests Since file names are not indiscriminately matched throughout the search tree anymore, the excluded files listed in the copyright tests need to be updated relative to the root of the package. * Add test cases to check exclusion behavior Specifically, these tests check for: - Incorrect exclusion of single filenames. - Correct exclusion of relatively/absolutely addressed filenames. - Correct exclusion of wildcarded paths. * Add unit tests for crawler module These unit tests make sure both search and exclusion behaviors are correctly demonstrated by the `ament_copyright.crawler` module. * Contributors: Abrar Rahman Protyasha, Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- * Add SPDX identifiers to the licenses. (`#315 `_) * Contributors: Chris Lalancette 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- * Use non-blind except for open() (`#307 `_) * Add optional file header style (`#304 `_) * Add optional file header style * Fix test on ament_copyright * Contributors: Alfi Maulana, Christophe Bedard 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * add mit-0 as a valid license to ament_copyright (`#284 `_) * Support Python 3.8-provided importlib.metadata (`#290 `_) The importlib_metadata package is a backport of the importlib.metadata module from Python 3.8. Fedora (and possibly others) no longer package importlib_metadata because they ship Python versions which have the functionality built-in. * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang, M. Mei, Scott K Logan 0.10.0 (2020-09-18) ------------------- * added bsd 2 clause simplified license to ament_copyright (`#267 `_) * added bsd 2 clause simplified license to ament_copyright * Remove use of pkg_resources from ament_lint. (`#260 `_) Replace it with the use of the more modern importlib_metadata library. There are a couple of reasons to do this: 1. pkg_resources is quite slow to import; on my machine, just firing up the python interpreter takes ~35ms, while firing up the python interpreter and importing pkg_resources takes ~175ms. Firing up the python interpreter and importing importlib_metadata takes ~70ms. Removing 100ms per invocation of the command-line both makes it speedier for users, and will speed up our tests (which call out to the command-line quite a lot). 2. pkg_resources is somewhat deprecated and being replaced by importlib. https://importlib-metadata.readthedocs.io/en/latest/using.html describes some of it Note: By itself, this change is not enough to completely remove our dependence on pkg_resources. We'll also have to do something about the console_scripts that setup.py generates. That will be a separate effort. * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette, Evan Flynn 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ * Remove output on stderr for case that is not an error (`#248 `_) * Remove output on stderr for case that is not an error * Remove early return to generate xml result file * Contributors: Jorge Perez 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * Generate xunit files valid for the junit10.xsd (`#220 `_) * remove status attribute from result XML (`#212 `_) * Add test case for Apache 2 (`#208 `_) * Add support for Boost Software License in ament_copyright package (`#207 `_) * Add support for the Boost Software License v1 * Add tests for boost1 license * Add support for the 3-Clause BSD license (`#205 `_) * Add support for the 3-Clause BSD license * Add missing entry setup.py file for the added license * Add test cases for .cpp and .py files * Add a newline to increase readability * Fix missing addition needed to use 3-clause bsd tests * Remove line not usable * Fix bug, allows using ament_copyright with bsd3 (`#206 `_) * Fix bug, allows using ament_copyright with bsd3 In the bs2 headers, exists a "{copyright_holder}" text that causes a problem when using the command ament_copyright to add headers to a source file. This fix adds a default value for that key, to match the original 3-Clause BSD text, and allowing to use the tool. * Add copyright_name if template includes copyright_holder reference * Revert comma addition * Contributors: Chris Lalancette, Dirk Thomas, Jacob Perron, Jorge Perez, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Convert list comprehension to generator (`#179 `_) Addresses flake8 C412 errors introduced by flake8-comprehension 2.2.0 * Contributors: Dirk Thomas, Scott K Logan 0.7.4 (2019-07-31) ------------------ * declare pytest markers (`#164 `_) * declare pytest markers * add markers to ament_xmllint tests * Match copyright templates with differing whitespace (`#160 `_) This change makes the template matching tolerant to more whitespace differences. In particular, it makes it tolerant in the presence of tabs, consecutive spaces (such as indentation) and EOL differences. * Contributors: Dirk Thomas, Scott K Logan 0.7.3 (2019-05-09 14:08) ------------------------ * handle BOM properly (`#142 `_) * Contributors: Dirk Thomas 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * fix encoding of copyright result file (`#139 `_) * use explicit encoding when reading files (`#138 `_) * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ * Adding GPL (and LGPL) (`#126 `_) Tested with: ros2 pkg create foobargpl --license GPLv3 --cpp-library-name foobargpl ament_copyright ./foobargpl/ foobargpl/include/foobargpl/foobargpl.hpp: could not find copyright notice foobargpl/include/foobargpl/visibility_control.h: could not find copyright notice foobargpl/src/foobargpl.cpp: could not find copyright notice 3 errors, checked 3 files Manually copied header to `foobargpl/include/foobargpl/foobargpl.hpp`. foobargpl/include/foobargpl/visibility_control.h: could not find copyright notice foobargpl/src/foobargpl.cpp: could not find copyright notice 2 errors, checked 3 files ament_copyright ./foobargpl/ --add-missing "Copyright 2019, FooBar, Ltd." gplv3 ament_copyright ./foobargpl/ No errors, checked 3 files * Contributors: Joshua Whitley 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ * Fix lint warnings from invalid escape sequences (`#111 `_) Use raw strings for regex patterns to avoid warnings. * Extend copyright checker to allow for doxygen-style copyright (`#108 `_) * Bsd clause3 fixup (`#106 `_) * relax clause 3 matching by removing 'the' in front og the copyright holding entity * copyright holder doesn't have to be a company * Adding MIT license templates. (`#105 `_) * Adding MIT license templates. * Ommitting 'All Rights Reserved' not in actual license. * Contributors: Jacob Perron, Joshua Whitley, Mikael Arguedas, jpsamper2009 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ * level setup.py versions to 0.5.1 * Contributors: Mikael Arguedas 0.5.0 (2018-06-18 10:09) ------------------------ * add pytest markers to linter tests * fix flake8 warning (`#99 `_) * Avoid use of builtin 'license' as variable name (`#97 `_) * set zip_safe to avoid warning during installation (`#96 `_) * Contributors: Dirk Thomas, dhood 0.4.0 (2017-12-08) ------------------ * remove test_suite, add pytest as test_requires * 0.0.3 * Merge pull request `#84 `_ from ament/flake8_plugins update style to satisfy new flake8 plugins * update style to satisfy new flake8 plugins * implicitly inherit from object (only in files not copied from somewhe… (`#83 `_) * implicitly inherit from object (only in files not copied from somewhere else) * don't modify file copied from elsewhere * Merge pull request `#81 `_ from ament/ignore_build_spaces ignore folders with an AMENT_IGNORE file, e.g. build spaces * ignore folders with an AMENT_IGNORE file, e.g. build spaces * 0.0.2 * use OSI website as reference for license (`#80 `_) * Merge pull request `#78 `_ from ament/use_flake8 use flake8 instead of pep8 and pyflakes * use flake8 instead of pep8 and pyflakes * Add in support for the BSD2 license. This allows ament_copyright to properly support the BSD2 license when doing copyright checking. * Change the copyright regex to allow a (c) after the "Copyright" word. This is what is recommended by the BSD license. * Change the copyright regex to allow a comma after the year(s). * remove __future_\_ imports * Merge pull request `#66 `_ from ament/multiple_copyrights support multiple copyright lines * support multiple copyright lines * update schema url * add schema to manifest files * Merge pull request `#42 `_ from ament/remove_second_extension remove result type extension from testsuite name * remove result type extension from testsuite name * Merge pull request `#28 `_ from ament/pep257 add packages to check pep257 compliance * use ament_pep257 * remove debug output * apply normpath to prevent './' prefix (fix `#24 `_) * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * make use of python linter packages * support excluding filenames from copyright, pep8, pyflakes check * fix variable name * Merge pull request `#15 `_ from ament/ament_copyright_reloaded add support for licenses * update doc * move apache2 snippets into separate files * add support for licenses * add trailing newline to generated test result files * Merge pull request `#9 `_ from ament/docs add docs for linters * add docs for linters * Merge pull request `#8 `_ from ament/ament_copyright add more options to ament_copyright * also handle \r\n newline * remove python3 dependencies * update url * update package description * add more options to ament_copyright * modify generated unit test files for a better hierarchy in Jenkins * make testname argument optional for all linters * use other linters for the linter packages where possible * Merge pull request `#3 `_ from ament/copyright_headers adding copyright headers, which are failing this module * adding copyright headers, which are failing this module * run ament_copyright and ament_pyflakes with Python 3 * Merge pull request `#2 `_ from ament/ament_lint_auto allow linting based on test dependencies only * add ament_lint_auto and ament_lint_common, update all linter packages to implement extension point of ament_lint_auto * use project(.. NONE) * update to latest refactoring of ament_cmake * add dependency on ament_cmake_environment * add ament_copyright * Contributors: Chris Lalancette, Dirk Thomas, Mikael Arguedas, Tully Foote ament_lint-0.12.0/ament_copyright/ament_copyright/000077500000000000000000000000001420377356500223305ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/ament_copyright/__init__.py000066400000000000000000000033611420377356500244440ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. try: import importlib.metadata as importlib_metadata except ModuleNotFoundError: import importlib_metadata COPYRIGHT_GROUP = 'ament_copyright.copyright_name' LICENSE_GROUP = 'ament_copyright.license' SOURCE_FILETYPE = 1 CONTRIBUTING_FILENAME = 'CONTRIBUTING.md' CONTRIBUTING_FILETYPE = 2 LICENSE_FILENAME = 'LICENSE' LICENSE_FILETYPE = 3 ALL_FILETYPES = { SOURCE_FILETYPE: None, CONTRIBUTING_FILETYPE: CONTRIBUTING_FILENAME, LICENSE_FILETYPE: LICENSE_FILENAME, } UNKNOWN_IDENTIFIER = '' def get_copyright_names(): names = {} for entry_point in importlib_metadata.entry_points().get(COPYRIGHT_GROUP, []): assert entry_point.name != UNKNOWN_IDENTIFIER, \ "Invalid entry point name '%s'" % entry_point.name name = entry_point.load() names[entry_point.name] = name return names def get_licenses(): licenses = {} for entry_point in importlib_metadata.entry_points().get(LICENSE_GROUP, []): assert entry_point.name != UNKNOWN_IDENTIFIER, \ "Invalid entry point name '%s'" % entry_point.name licenses[entry_point.name] = entry_point.load() return licenses ament_lint-0.12.0/ament_copyright/ament_copyright/copyright_names.py000066400000000000000000000014251420377356500260770ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # to add more copyright holder names do not extend this file # instead create a separate package and register custom names as entry points osrf = 'Open Source Robotics Foundation, Inc.' ament_lint-0.12.0/ament_copyright/ament_copyright/crawler.py000066400000000000000000000066001420377356500243430ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import glob import os from ament_copyright import ALL_FILETYPES from ament_copyright import SOURCE_FILETYPE def get_files(paths, extensions, exclude_patterns, skip_package_level_setup_py=True): excludes = [] for exclude_pattern in exclude_patterns: excludes.extend(glob.glob(exclude_pattern)) excludes = {os.path.realpath(x) for x in excludes} files = {} for path in paths: if os.path.isdir(path): if is_repository_root(path): add_files_for_all_filetypes(path, files) for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue if is_repository_root(dirpath): add_files_for_all_filetypes(dirpath, files) # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] dirnames.sort() # select files by extension for filename in sorted(filenames): # skip package level setup.py file if ( skip_package_level_setup_py and filename == 'setup.py' and os.path.exists(os.path.join(dirpath, 'package.xml')) ): continue if match_filename(filename, extensions): filepath = os.path.join(dirpath, filename) if os.path.realpath(filepath) not in excludes: files[os.path.join(dirpath, filename)] = SOURCE_FILETYPE if os.path.isfile(path) and match_filename(path, extensions): if os.path.realpath(path) not in excludes: files[path] = SOURCE_FILETYPE if is_repository_root(os.path.dirname(path)): basename = os.path.basename(path) for filetype, filename in ALL_FILETYPES.items(): if filename == basename: files[path] = filetype break return {os.path.normpath(path): filetype for path, filetype in files.items()} def is_repository_root(path): """Check if the path is the root of a git or mercurial repository.""" return ( os.path.exists(os.path.join(path, '.git')) or os.path.exists(os.path.join(path, '.hg')) ) def match_filename(filename, extensions): """Check if the filename has one of the extensions.""" _, ext = os.path.splitext(filename) return ext in ('.%s' % e for e in extensions) def add_files_for_all_filetypes(path, files): for filetype, filename in ALL_FILETYPES.items(): if filename is None: continue files[os.path.join(path, filename)] = filetype ament_lint-0.12.0/ament_copyright/ament_copyright/licenses.py000066400000000000000000000066771420377356500245270ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # to add more licenses do not extend this file # instead create a separate package and register custom licenses as entry points from collections import namedtuple import os LicenseEntryPoint = namedtuple( 'LicenseEntryPoint', ['name', 'spdx', 'file_headers', 'license_files', 'contributing_files']) TEMPLATE_DIRECTORY = os.path.join(os.path.dirname(__file__), 'template') def read_data(path, name, prefix, license_type): path_template = os.path.join(path, prefix + '_' + license_type + '_%d.txt') data = [] with open(os.path.join(path, prefix + '_' + license_type + '.txt'), 'r') as h: data.append(h.read()) index = 0 while True: try: with open(path_template % index, 'r') as h: data.append(h.read()) index += 1 except OSError: break return data def read_license_data(path, name, spdx, prefix): file_headers = read_data(path, name, prefix, 'header') license_files = read_data(path, name, prefix, 'license') contributing_files = read_data(path, name, prefix, 'contributing') return LicenseEntryPoint(name, spdx, file_headers, license_files, contributing_files) # The SPDX identifier (the 3rd argument) comes from the official list at https://spdx.org/licenses/ apache2 = read_license_data(TEMPLATE_DIRECTORY, 'Apache License, Version 2.0', 'Apache-2.0', 'apache2') boost1 = read_license_data(TEMPLATE_DIRECTORY, 'Boost Software License - Version 1.0', 'BSL-1.0', 'boost1') bsd2 = read_license_data(TEMPLATE_DIRECTORY, 'BSD License 2.0', 'BSD-2.0', 'bsd2') bsd_3clause = read_license_data(TEMPLATE_DIRECTORY, '3-Clause BSD License', 'BSD-3-Clause', 'bsd_3clause') bsd_2clause = read_license_data(TEMPLATE_DIRECTORY, '2-Clause BSD License', 'BSD-2-Clause', 'bsd_2clause') mit = read_license_data(TEMPLATE_DIRECTORY, 'MIT License', 'MIT', 'mit') mit0 = read_license_data(TEMPLATE_DIRECTORY, 'MIT-0 License', 'MIT-0', 'mit0') gplv3 = read_license_data(TEMPLATE_DIRECTORY, 'GNU General Public License 3.0', 'GPL-3.0-only', 'gplv3') lgplv3 = read_license_data(TEMPLATE_DIRECTORY, 'GNU Lesser General Public License 3.0', 'LGPL-3.0-only', 'lgplv3') ament_lint-0.12.0/ament_copyright/ament_copyright/main.py000066400000000000000000000373631420377356500236420ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse from itertools import groupby import os import re import sys import time from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr from ament_copyright import CONTRIBUTING_FILETYPE from ament_copyright import get_copyright_names from ament_copyright import get_licenses from ament_copyright import LICENSE_FILETYPE from ament_copyright import SOURCE_FILETYPE from ament_copyright import UNKNOWN_IDENTIFIER from ament_copyright.crawler import get_files from ament_copyright.parser import get_comment_block from ament_copyright.parser import get_index_of_next_line from ament_copyright.parser import parse_file from ament_copyright.parser import scan_past_coding_and_shebang_lines from ament_copyright.parser import scan_past_empty_lines from ament_copyright.parser import search_copyright_information def main(argv=sys.argv[1:]): extensions = [ 'c', 'cc', 'cpp', 'cxx', 'h', 'hh', 'hpp', 'hxx', 'cmake', 'py', ] parser = argparse.ArgumentParser( description='Check code files for copyright and license information.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files ending ' "in %s will be considered (except directories starting with '.' " "or '_' and 'setup.py' files beside 'package.xml' files)." % ', '.join(["'.%s'" % e for e in extensions])) parser.add_argument( '--exclude', metavar='filename', nargs='*', default=[], dest='excludes', help='The filenames to exclude.') group = parser.add_mutually_exclusive_group() group.add_argument( '--add-missing', nargs=2, metavar=('COPYRIGHT_NAME', 'LICENSE'), help=( 'Add missing copyright notice and license information using the ' 'passed copyright holder and license')) group.add_argument( '--add-copyright-year', nargs='*', type=int, help='Add the current year to existing copyright notices') group.add_argument( '--list-copyright-names', action='store_true', help='List names of known copyright holders') group.add_argument( '--list-licenses', action='store_true', help='List names of known licenses') parser.add_argument( '--verbose', action='store_true', help='Show all files instead of only the ones with errors / modifications') # not using a file handle directly # in order to prevent leaving an empty file when something fails early group.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) names = get_copyright_names() if args.list_copyright_names: for key in sorted(names.keys()): print('%s: %s' % (key, names[key])) return 0 licenses = get_licenses() if args.list_licenses: for key in sorted(licenses.keys()): print('%s: %s' % (key, licenses[key].name)) return 0 if args.xunit_file: start_time = time.time() filenames = get_files(args.paths, extensions, args.excludes) if not filenames: print('No repository roots and files found') file_descriptors = {} for filename in sorted(filenames): file_descriptors[filename] = parse_file(filename) if args.add_missing: name = names.get(args.add_missing[0], args.add_missing[0]) if args.add_missing[1] not in licenses: parser.error( "'LICENSE' argument must be a known license name. " "Use the '--list-licenses' options to see alist of valid license names.") add_missing_header( file_descriptors, name, licenses[args.add_missing[1]], args.verbose) return 0 if args.add_copyright_year is not None: if not args.add_copyright_year: args.add_copyright_year.append(time.strftime('%Y')) args.add_copyright_year = [int(year) for year in args.add_copyright_year] add_copyright_year(file_descriptors, args.add_copyright_year, args.verbose) return 0 report = [] # check each directory for CONTRIBUTING.md and LICENSE files for path in sorted(file_descriptors.keys()): file_descriptor = file_descriptors[path] message = None has_error = False if file_descriptor.filetype == SOURCE_FILETYPE: if not file_descriptor.exists: message = 'file not found' has_error = True elif not file_descriptor.content: message = 'file empty' elif not file_descriptor.copyright_identifiers: message = 'could not find copyright notice' has_error = True else: message = 'copyright=%s, license=%s' % \ (', '.join([str(c) for c in file_descriptor.copyrights]), file_descriptor.license_identifier) has_error = file_descriptor.license_identifier == UNKNOWN_IDENTIFIER elif file_descriptor.filetype in [CONTRIBUTING_FILETYPE, LICENSE_FILETYPE]: if not file_descriptor.exists: message = 'file not found' has_error = True elif not file_descriptor.content: message = 'file empty' has_error = True elif file_descriptor.license_identifier: message = file_descriptor.license_identifier has_error = file_descriptor.license_identifier == UNKNOWN_IDENTIFIER else: assert False, file_descriptor else: assert False, 'Unknown filetype: ' + file_descriptor.filetype if args.verbose or has_error: print('%s: %s' % (file_descriptor.path, message), file=sys.stderr if has_error else sys.stdout) report.append((file_descriptor.path, not has_error, message)) # output summary error_count = len([r for r in report if not r[1]]) if not error_count: print('No problems found, checked %d files' % len(report)) rc = 0 else: print('%d errors, checked %d files' % (error_count, len(report)), file=sys.stderr) rc = 1 # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w', encoding='utf-8') as f: f.write(xml) return rc def add_missing_header(file_descriptors, name, license_, verbose): copyright_ = 'Copyright %d %s' % (int(time.strftime('%Y')) - 1 + 1, name) header = license_.file_headers[0].format(**{ 'copyright': copyright_, 'copyright_holder': name}) lines = header.splitlines() if verbose: print('Adding the following copyright / license header or repository level files:') for line in lines: print('+', line) print() for path in sorted(file_descriptors.keys()): file_descriptor = file_descriptors[path] skip = False if file_descriptor.filetype == SOURCE_FILETYPE: # ignore empty files if not file_descriptor.content: skip = True # ignore files which already have a header if file_descriptor.copyright_identifiers: skip = True elif file_descriptor.exists: # ignore non-source files if they already exist skip = True if skip: if verbose: print(' ', file_descriptor.path) continue if file_descriptor.filetype == SOURCE_FILETYPE: print('*', file_descriptor.path) add_header(file_descriptor, header) elif file_descriptor.filetype == CONTRIBUTING_FILETYPE: print('+', file_descriptor.path) with open(file_descriptor.path, 'w', encoding='utf-8') as h: h.write(license_.contributing_files[0]) elif file_descriptor.filetype == LICENSE_FILETYPE: print('+', file_descriptor.path) with open(file_descriptor.path, 'w', encoding='utf-8') as h: h.write(license_.license_files[0]) else: assert False, 'Unknown filetype: ' + file_descriptor.filetype def add_copyright_year(file_descriptors, new_years, verbose): if verbose: print('Adding the current year to existing copyright notices:') print() for path in sorted(file_descriptors.keys()): file_descriptor = file_descriptors[path] # ignore files which do not have a header if not getattr(file_descriptor, 'copyright_identifier', None): continue index = scan_past_coding_and_shebang_lines(file_descriptor.content) index = scan_past_empty_lines(file_descriptor.content, index) if file_descriptor.filetype == SOURCE_FILETYPE: block, block_offset = get_comment_block(file_descriptor.content, index) if not block: assert False, "Could not find comment block in file '%s'" % file_descriptor.path else: block = file_descriptor.content[index:] block_offset = 0 copyright_span, years_span, name_span = search_copyright_information(block) if copyright_span is None: assert False, "Could not find copyright information in file '%s'" % \ file_descriptor.path # skip if all new years are already included years = get_years_from_string(block[years_span[0]:years_span[1]]) if all((new_year in years) for new_year in new_years): if verbose: print(' ', file_descriptor.path) continue print('*' if file_descriptor.exists else '+', file_descriptor.path) for new_year in new_years: years.add(new_year) years_string = get_string_from_years(years) # overwrite previous years with new years offset = index + block_offset global_years_span = [offset + years_span[0], offset + years_span[1]] content = file_descriptor.content[:global_years_span[0]] + years_string + \ file_descriptor.content[global_years_span[1]:] # output beginning of file for debugging # index = global_years_span[0] # for _ in range(3): # index = get_index_of_next_line(content, index) # print('<<<') # print(content[:index - 1]) # print('>>>') with open(file_descriptor.path, 'w', encoding='utf-8') as h: h.write(content) def get_years_from_string(content): # remove all whitespaces content = re.sub(r'\s', '', content) # split items by comma items = content.split(',') years = set() for item in items: # each item can be a plain year or a range of years parts = item.split('-', 1) if len(parts) == 1: # plain year years.add(int(parts[0])) else: # year range start_year = int(parts[0]) end_year = int(parts[1]) assert end_year >= start_year for year in range(start_year, end_year + 1): years.add(year) return years def get_string_from_years(years): ranges = [] for _, iterable in groupby(enumerate(sorted(years)), lambda x: x[1] - x[0]): r = list(iterable) if len(r) == 1: ranges.append(str(r[0][1])) else: ranges.append('%d-%d' % (r[0][1], r[-1][1])) return ', '.join(ranges) def add_header(file_descriptor, header): """ Add the copyright / license message to a file. The copyright / license is placed below an optional shebang line as well as an optional coding line. It is preceded by an empty line if not at the beginning of the file and always followed by an empty line. """ begin_index = scan_past_coding_and_shebang_lines(file_descriptor.content) end_index = scan_past_empty_lines(file_descriptor.content, begin_index) # inject copyright message comment = get_comment(file_descriptor.path, header) inserted_block = '%s\n\n' % comment if begin_index > 0: inserted_block = '\n' + inserted_block content = file_descriptor.content[:begin_index] + inserted_block + \ file_descriptor.content[end_index:] # output beginning of file for debugging # index = end_index + len(inserted_block) # for _ in range(3): # index = get_index_of_next_line(content, index) # print('<<<') # print(content[:index - 1]) # print('>>>') with open(file_descriptor.path, 'w', encoding='utf-8') as h: h.write(content) def get_comment(filename, msg): if filename.endswith('.cmake') or filename.endswith('.py'): line_prefix = '#' else: line_prefix = '//' comment = '' index = 0 while True: new_index = get_index_of_next_line(msg, index) if new_index == index: break comment += line_prefix line = msg[index:new_index] if line.splitlines()[0]: comment += ' ' comment += line index = new_index return comment def get_xunit_content(report, testname, elapsed): test_count = len(report) error_count = len([r for r in report if not r[1]]) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for (filename, no_error, message) in report: data = { 'quoted_filename': quoteattr(filename), 'testname': testname, 'escaped_message': escape(message), } if not no_error: # report missing / unknown copyright / license as a failing testcase xml += """ """ % data else: # if there is a known copyright / license report a single successful test xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % r[0] for r in report])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_copyright/ament_copyright/parser.py000066400000000000000000000211361420377356500242010ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import re from ament_copyright import ALL_FILETYPES from ament_copyright import CONTRIBUTING_FILETYPE from ament_copyright import get_copyright_names from ament_copyright import get_licenses from ament_copyright import LICENSE_FILETYPE from ament_copyright import SOURCE_FILETYPE from ament_copyright import UNKNOWN_IDENTIFIER class CopyrightDescriptor: def __init__(self, name, year_range): self.name = name self.year_range = year_range def __str__(self): s = self.name if self.year_range: s += ' (%s)' % self.year_range return s class FileDescriptor: def __init__(self, filetype, path): self.filetype = filetype self.path = path self.exists = os.path.exists(path) self.content = None self.license_identifier = UNKNOWN_IDENTIFIER def read(self): if not self.exists: return with open(self.path, 'r', encoding='utf-8') as h: self.content = h.read() def parse(self): raise NotImplementedError() def identify_license(self, content, license_part): if content is None: return for name, license_ in get_licenses().items(): templates = getattr(license_, license_part) for template in templates: formatted_template = remove_formatting(template) last_index = -1 for license_section in formatted_template.split('{copyright_holder}'): # OK, now look for each section of the license in the incoming # content. index = remove_formatting(content).find(license_section.strip()) if index == -1 or index <= last_index: # Some part of the license is not in the content, or the license # is rearranged, this license doesn't match. break last_index = index else: # We found the license, so set it self.license_identifier = name break class SourceDescriptor(FileDescriptor): def __init__(self, path): super(SourceDescriptor, self).__init__(SOURCE_FILETYPE, path) self.copyrights = [] self.copyright_identifiers = [] def identify_copyright(self): known_copyrights = get_copyright_names() for c in self.copyrights: found_name = c.name for identifier, name in known_copyrights.items(): if name == found_name: self.copyright_identifiers.append(identifier) break else: self.copyright_identifiers.append(UNKNOWN_IDENTIFIER) def parse(self): self.read() if not self.content: return # skip over coding and shebang lines index = scan_past_coding_and_shebang_lines(self.content) index = scan_past_empty_lines(self.content, index) # get first comment block without leading comment tokens block, _ = get_comment_block(self.content, index) if not block: return copyrights, remaining_block = search_copyright_information(block) if not copyrights: return None self.copyrights = copyrights self.identify_copyright() content = '{copyright}' + remaining_block self.identify_license(content, 'file_headers') class ContributingDescriptor(FileDescriptor): def __init__(self, path): super(ContributingDescriptor, self).__init__(CONTRIBUTING_FILETYPE, path) def parse(self): self.read() if not self.content: return self.identify_license(self.content, 'contributing_files') class LicenseDescriptor(FileDescriptor): def __init__(self, path): super(LicenseDescriptor, self).__init__(LICENSE_FILETYPE, path) def parse(self): self.read() if not self.content: return self.identify_license(self.content, 'license_files') def parse_file(path): filetype = determine_filetype(path) if filetype == SOURCE_FILETYPE: d = SourceDescriptor(path) elif filetype == CONTRIBUTING_FILETYPE: d = ContributingDescriptor(path) elif filetype == LICENSE_FILETYPE: d = LicenseDescriptor(path) else: return None d.parse() return d def determine_filetype(path): basename = os.path.basename(path) for filetype, filename in ALL_FILETYPES.items(): if basename == filename: return filetype return SOURCE_FILETYPE def search_copyright_information(content): # regex for matching years or year ranges (yyyy-yyyy) separated by colons year = r'\d{4}' year_range = '%s-%s' % (year, year) year_or_year_range = '(?:%s|%s)' % (year, year_range) pattern = r'^[^\n\r]?\s*(?:\\copyright\s*)?' \ r'Copyright(?:\s+\(c\))?\s+(%s(?:,\s*%s)*),?\s+([^\n\r]+)$' % \ (year_or_year_range, year_or_year_range) regex = re.compile(pattern, re.DOTALL | re.MULTILINE) copyrights = [] while True: match = regex.search(content) if not match: break years_span, name_span = match.span(1), match.span(2) years = content[years_span[0]:years_span[1]] name = content[name_span[0]:name_span[1]] copyrights.append(CopyrightDescriptor(name, years)) content = content[name_span[1]:] return copyrights, content def scan_past_coding_and_shebang_lines(content): index = 0 while ( is_comment_line(content, index) and (is_coding_line(content, index) or is_shebang_line(content, index)) ): index = get_index_of_next_line(content, index) return index def get_index_of_next_line(content, index): index_n = content.find('\n', index) index_r = content.find('\r', index) index_rn = content.find('\r\n', index) indices = set() if index_n != -1: indices.add(index_n) if index_r != -1: indices.add(index_r) if index_rn != -1: indices.add(index_rn) if not indices: return len(content) index = min(indices) if index == index_rn: return index + 2 return index + 1 def is_comment_line(content, index): # skip over optional BOM if index == 0 and content[0] == '\ufeff': index = 1 return content[index] == '#' or content[index:index + 1] == '//' def is_coding_line(content, index): end_index = get_index_of_next_line(content, index) line = content[index:end_index] return 'coding=' in line or 'coding:' in line def is_shebang_line(content, index): # skip over optional BOM if index == 0 and content[0] == '\ufeff': index = 1 return content[index:index + 2] == '#!' def get_comment_block(content, index): # regex for matching the beginning of the first comment # check for doxygen comments (///) before regular comments (//) pattern = '^(#|///|//)' # also accept BOM if present if index == 0 and content[0] == '\ufeff': pattern = pattern[0] + '\ufeff' + pattern[1:] regex = re.compile(pattern, re.MULTILINE) match = regex.search(content, index) if not match: return None, None comment_token = match.group(1) start_index = match.start(1) end_index = start_index while True: end_index = get_index_of_next_line(content, end_index) if content[end_index:end_index + len(comment_token)] != comment_token: break block = content[start_index:end_index] lines = block.splitlines() lines = [line[len(comment_token) + 1:] for line in lines] return '\n'.join(lines), start_index + len(comment_token) + 1 def scan_past_empty_lines(content, index): while is_empty_line(content, index): index = get_index_of_next_line(content, index) return index def is_empty_line(content, index): return get_index_of_next_line(content, index) == index + 1 def remove_formatting(text): return ' '.join(filter(None, text.split())) ament_lint-0.12.0/ament_copyright/ament_copyright/pytest_marker.py000066400000000000000000000014361420377356500255770ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def pytest_configure(config): config.addinivalue_line( 'markers', 'copyright: ' 'marks tests checking for a copyright statement in non-empty source ' 'files') ament_lint-0.12.0/ament_copyright/ament_copyright/template/000077500000000000000000000000001420377356500241435ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/ament_copyright/template/apache2_contributing.txt000066400000000000000000000011711420377356500307760ustar00rootroot00000000000000Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ ament_lint-0.12.0/ament_copyright/ament_copyright/template/apache2_header.txt000066400000000000000000000010301420377356500275110ustar00rootroot00000000000000{copyright} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.ament_lint-0.12.0/ament_copyright/ament_copyright/template/apache2_license.txt000066400000000000000000000261361420377356500277210ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ament_lint-0.12.0/ament_copyright/ament_copyright/template/boost1_contributing.txt000066400000000000000000000002601420377356500307000ustar00rootroot00000000000000Any contribution that you make to this repository will be under the Boost Software License - Version 1.0, as dictated by that [license](https://www.boost.org/LICENSE_1_0.txt). ament_lint-0.12.0/ament_copyright/ament_copyright/template/boost1_header.txt000066400000000000000000000025071420377356500274270ustar00rootroot00000000000000{copyright} Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/boost1_license.txt000066400000000000000000000024721420377356500276220ustar00rootroot00000000000000Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd2_contributing.txt000066400000000000000000000002421420377356500303230ustar00rootroot00000000000000Any contribution that you make to this repository will be under the BSD license 2.0, as dictated by that [license](https://opensource.org/licenses/BSD-3-Clause). ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd2_header.txt000066400000000000000000000027611420377356500270540ustar00rootroot00000000000000{copyright} All rights reserved. Software License Agreement (BSD License 2.0) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of {copyright_holder} nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd2_license.txt000066400000000000000000000027471420377356500272520ustar00rootroot00000000000000All rights reserved. Software License Agreement (BSD License 2.0) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd_2clause_contributing.txt000066400000000000000000000002621420377356500316610ustar00rootroot00000000000000Any contribution that you make to this repository will be under the BSD 2-Clause Simplified License, as dictated by that [license](https://opensource.org/licenses/BSD-2-Clause). ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd_2clause_header.txt000066400000000000000000000024771420377356500304140ustar00rootroot00000000000000{copyright} All rights reserved. Software License Agreement (BSD 2-Clause Simplified License) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd_2clause_license.txt000066400000000000000000000024631420377356500306010ustar00rootroot00000000000000All rights reserved. Software License Agreement (BSD 2-Clause Simplified License) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd_3clause_contributing.txt000066400000000000000000000002471420377356500316650ustar00rootroot00000000000000Any contribution that you make to this repository will be under the 3-Clause BSD License, as dictated by that [license](https://opensource.org/licenses/BSD-3-Clause). ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd_3clause_header.txt000066400000000000000000000027021420377356500304040ustar00rootroot00000000000000{copyright} Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the {copyright_holder} nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd_3clause_header_0.txt000066400000000000000000000002531420377356500306220ustar00rootroot00000000000000{copyright} Use of this source code is governed by a BSD-style license that can be found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd ament_lint-0.12.0/ament_copyright/ament_copyright/template/bsd_3clause_license.txt000066400000000000000000000026631420377356500306040ustar00rootroot00000000000000Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/gplv3_contributing.txt000066400000000000000000000002501420377356500305230ustar00rootroot00000000000000Any contribution that you make to this repository will be under the GNU General Public License, as dictated by that [license](https://opensource.org/licenses/GPL-3.0). ament_lint-0.12.0/ament_copyright/ament_copyright/template/gplv3_header.txt000066400000000000000000000011621420377356500272470ustar00rootroot00000000000000{copyright} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ament_lint-0.12.0/ament_copyright/ament_copyright/template/gplv3_license.txt000066400000000000000000001045151420377356500274470ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ament_lint-0.12.0/ament_copyright/ament_copyright/template/lgplv3_contributing.txt000066400000000000000000000002601420377356500307000ustar00rootroot00000000000000Any contribution that you make to this repository will be under the GNU Lesser General Public License, as dictated by that [license](https://opensource.org/licenses/LGPL-3.0). ament_lint-0.12.0/ament_copyright/ament_copyright/template/lgplv3_header.txt000066400000000000000000000012071420377356500274230ustar00rootroot00000000000000{copyright} This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . ament_lint-0.12.0/ament_copyright/ament_copyright/template/lgplv3_license.txt000066400000000000000000000167441420377356500276310ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ament_lint-0.12.0/ament_copyright/ament_copyright/template/mit0_contributing.txt000066400000000000000000000002311420377356500303400ustar00rootroot00000000000000Any contribution that you make to this repository will be under the MIT-0 license, as dictated by that [license](https://opensource.org/licenses/MIT-0). ament_lint-0.12.0/ament_copyright/ament_copyright/template/mit0_header.txt000066400000000000000000000015471420377356500270740ustar00rootroot00000000000000{copyright} Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/mit0_license.txt000066400000000000000000000015321420377356500272600ustar00rootroot00000000000000Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/mit_contributing.txt000066400000000000000000000002251420377356500302630ustar00rootroot00000000000000Any contribution that you make to this repository will be under the MIT license, as dictated by that [license](https://opensource.org/licenses/MIT). ament_lint-0.12.0/ament_copyright/ament_copyright/template/mit_header.txt000066400000000000000000000020141420377356500270020ustar00rootroot00000000000000{copyright} Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ament_lint-0.12.0/ament_copyright/ament_copyright/template/mit_header_0.txt000066400000000000000000000002321420377356500272210ustar00rootroot00000000000000{copyright} Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at https://opensource.org/licenses/MIT. ament_lint-0.12.0/ament_copyright/ament_copyright/template/mit_license.txt000066400000000000000000000017771420377356500272130ustar00rootroot00000000000000Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ament_lint-0.12.0/ament_copyright/doc/000077500000000000000000000000001420377356500177015ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/doc/index.rst000066400000000000000000000046021420377356500215440ustar00rootroot00000000000000ament_copyright =============== Checks C / C++ / CMake / Python source files for the existence of a copyright and license notice. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``, ``.cmake``, ``.py``. When being searched for recursively the following directories and files are being excluded: - directories starting with ``.`` (e.g. ``.git``) or ``_`` (e.g. ``__pycache__``) - ``setup.py`` when being a sibling of ``package.xml`` Additionally it checks if the root of a repository contains a ``LICENSE`` and ``CONTRIBUTING.md`` file. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_copyright [ ...] When using the option ``--list-copyright-names`` a list of known copyright holders is shown. The option ``--list-licenses`` outputs a list of known licenses. When using the option ``--add-missing `` a copyright notice and license is added to all files which lack one. The first argument can either be a name from the list returned by ``--list-copyright-names`` or a custom string. The second argument must be a name from the list returned by ``--list-licenses``. When using the option ``--add-copyright-year`` existing copyright notices are being updated to include the current year. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_copyright `_. How to add support for more licenses or copyright holders? ---------------------------------------------------------- The package uses Python entry points to get all list of known licenses and copyright holder. You can implement a custom package and contribute more implementations to these entry points or extend this package with more licenses. Why are my existing copyright / license notices not detected? ------------------------------------------------------------- This script currently only checks line comments (lines starting with ``#`` / ``//`` depending on the language). Block comments / C-style comment (starting with ``/*``) are not being detected to keep the complexity minimal. Also the content must match the templates exactly. ament_lint-0.12.0/ament_copyright/package.xml000066400000000000000000000017051420377356500212540ustar00rootroot00000000000000 ament_copyright 0.12.0 The ability to check source files for copyright and license information. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_lint python3-importlib-metadata ament_flake8 ament_pep257 python3-pytest ament_python ament_lint-0.12.0/ament_copyright/pytest.ini000066400000000000000000000000351420377356500211630ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_copyright/resource/000077500000000000000000000000001420377356500207635ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/resource/ament_copyright000066400000000000000000000000001420377356500240700ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/setup.py000066400000000000000000000041701420377356500206500ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_copyright' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], package_data={'': [ 'template/*', ]}, zip_safe=False, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check source files for copyright reference.', long_description="""\ The ability to check sources file for copyright and license information.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'ament_copyright.copyright_name': [ 'osrf = ament_copyright.copyright_names:osrf', ], 'ament_copyright.license': [ 'apache2 = ament_copyright.licenses:apache2', 'boost1 = ament_copyright.licenses:boost1', 'bsd2 = ament_copyright.licenses:bsd2', 'bsd_3clause = ament_copyright.licenses:bsd_3clause', 'bsd_2clause = ament_copyright.licenses:bsd_2clause', 'mit = ament_copyright.licenses:mit', 'mit0 = ament_copyright.licenses:mit0', 'gplv3 = ament_copyright.licenses:gplv3', 'lgplv3 = ament_copyright.licenses:lgplv3', ], 'console_scripts': [ 'ament_copyright = ament_copyright.main:main', ], 'pytest11': [ 'ament_copyright = ament_copyright.pytest_marker', ], }, ) ament_lint-0.12.0/ament_copyright/test/000077500000000000000000000000001420377356500201135ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/000077500000000000000000000000001420377356500212115ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/3clause_bsd/000077500000000000000000000000001420377356500234005ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/3clause_bsd/case.py000066400000000000000000000030701420377356500246650ustar00rootroot00000000000000# Copyright 2020 Open Source Robotics Foundation, Inc. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # * Neither the name of the the copyright holder nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. def special(): pass ament_lint-0.12.0/ament_copyright/test/cases/3clause_bsd/case2.cpp000066400000000000000000000031261420377356500251030ustar00rootroot00000000000000// Copyright 2020 Open Source Robotics Foundation, Inc. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // * Neither the name of the the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. int main() { return 0; } ament_lint-0.12.0/ament_copyright/test/cases/apache2_license/000077500000000000000000000000001420377356500242165ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/apache2_license/case.py000066400000000000000000000011311420377356500254770ustar00rootroot00000000000000# Copyright 2020 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ament_lint-0.12.0/ament_copyright/test/cases/boost1/000077500000000000000000000000001420377356500224205ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/boost1/case.py000066400000000000000000000026701420377356500237120ustar00rootroot00000000000000# Copyright 2020 Open Source Robotics Foundation, Inc. # # Boost Software License - Version 1.0 - August 17th, 2003 # # Permission is hereby granted, free of charge, to any person or organization # obtaining a copy of the software and accompanying documentation covered by # this license (the "Software") to use, reproduce, display, distribute, # execute, and transmit the Software, and to prepare derivative works of the # Software, and to permit third-parties to whom the Software is furnished to # do so, all subject to the following: # # The copyright notices in the Software and this entire statement, including # the above license grant, this restriction and the following disclaimer, # must be included in all copies of the Software, in whole or in part, and # all derivative works of the Software, unless such copies or derivative # works are solely in the form of machine-executable object code generated by # a source language processor. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT # SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE # FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. def special(): pass ament_lint-0.12.0/ament_copyright/test/cases/boost1/case2.cpp000066400000000000000000000027231420377356500241250ustar00rootroot00000000000000// Copyright 2020 Open Source Robotics Foundation, Inc. // // Boost Software License - Version 1.0 - August 17th, 2003 // // Permission is hereby granted, free of charge, to any person or organization // obtaining a copy of the software and accompanying documentation covered by // this license (the "Software") to use, reproduce, display, distribute, // execute, and transmit the Software, and to prepare derivative works of the // Software, and to permit third-parties to whom the Software is furnished to // do so, all subject to the following: // // The copyright notices in the Software and this entire statement, including // the above license grant, this restriction and the following disclaimer, // must be included in all copies of the Software, in whole or in part, and // all derivative works of the Software, unless such copies or derivative // works are solely in the form of machine-executable object code generated by // a source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. int main() { return 0; } ament_lint-0.12.0/ament_copyright/test/cases/bsd_license/000077500000000000000000000000001420377356500234635ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/bsd_license/case.py000066400000000000000000000031261420377356500247520ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # All rights reserved. # # Software License Agreement (BSD License 2.0) # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. ament_lint-0.12.0/ament_copyright/test/cases/bsd_license_indented/000077500000000000000000000000001420377356500253355ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/bsd_license_indented/case.py000066400000000000000000000031501420377356500266210ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # All rights reserved. # # Software License Agreement (BSD License 2.0) # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. ament_lint-0.12.0/ament_copyright/test/cases/bsd_license_tabs/000077500000000000000000000000001420377356500244745ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/bsd_license_tabs/case.py000066400000000000000000000031401420377356500257570ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # All rights reserved. # # Software License Agreement (BSD License 2.0) # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above # copyright notice, this list of conditions and the # following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the # following disclaimer in the documentation and/or other # materials provided with the distribution. # * Neither the name of the copyright holder nor the names of # its contributors may be used to endorse or promote # products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. ament_lint-0.12.0/ament_copyright/test/cases/crawler/000077500000000000000000000000001420377356500226505ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/crawler/case.py000066400000000000000000000021301420377356500241310ustar00rootroot00000000000000# Copyright 2021 Open Source Robotics Foundation, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ament_lint-0.12.0/ament_copyright/test/cases/crawler/case2.cpp000066400000000000000000000003561420377356500243550ustar00rootroot00000000000000// Copyright 2021 Open Source Robotics Foundation, Inc. // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. int main() { return 0; } ament_lint-0.12.0/ament_copyright/test/cases/crawler/subdir/000077500000000000000000000000001420377356500241405ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/crawler/subdir/case.py000066400000000000000000000021301420377356500254210ustar00rootroot00000000000000# Copyright 2021 Open Source Robotics Foundation, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ament_lint-0.12.0/ament_copyright/test/cases/crawler/subdir/case2.cpp000066400000000000000000000003561420377356500256450ustar00rootroot00000000000000// Copyright 2021 Open Source Robotics Foundation, Inc. // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. int main() { return 0; } ament_lint-0.12.0/ament_copyright/test/cases/mit/000077500000000000000000000000001420377356500220025ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/mit/case.py000066400000000000000000000021301420377356500232630ustar00rootroot00000000000000# Copyright 2021 Open Source Robotics Foundation, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ament_lint-0.12.0/ament_copyright/test/cases/mit/case2.cpp000066400000000000000000000003561420377356500235070ustar00rootroot00000000000000// Copyright 2021 Open Source Robotics Foundation, Inc. // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. int main() { return 0; } ament_lint-0.12.0/ament_copyright/test/cases/mit0/000077500000000000000000000000001420377356500220625ustar00rootroot00000000000000ament_lint-0.12.0/ament_copyright/test/cases/mit0/case.py000066400000000000000000000016751420377356500233600ustar00rootroot00000000000000# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy of this # software and associated documentation files (the "Software"), to deal in the Software # without restriction, including without limitation the rights to use, copy, modify, # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ament_lint-0.12.0/ament_copyright/test/test_copyright.py000066400000000000000000000067131420377356500235430ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from contextlib import redirect_stdout import io import os from ament_copyright.main import main cases_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'cases') f = io.StringIO() def test_apache2_standard(): rc = main(argv=[os.path.join(cases_path, 'apache2_license')]) assert rc == 0, 'Found errors' def test_boost1_cpp(): rc = main(argv=[os.path.join(cases_path, 'boost1/case2.cpp')]) assert rc == 0, 'Found errors' def test_boost1_py(): rc = main(argv=[os.path.join(cases_path, 'boost1/case.py')]) assert rc == 0, 'Found errors' def test_bsd_standard(): rc = main(argv=[os.path.join(cases_path, 'bsd_license')]) assert rc == 0, 'Found errors' def test_bsd_indented(): rc = main(argv=[os.path.join(cases_path, 'bsd_license_indented')]) assert rc == 0, 'Found errors' def test_bsd_tabs(): rc = main(argv=[os.path.join(cases_path, 'bsd_license_tabs')]) assert rc == 0, 'Found errors' def test_3bsd_cpp(): rc = main(argv=[os.path.join(cases_path, '3clause_bsd/case2.cpp')]) assert rc == 0, 'Found errors' def test_3bsd_py(): rc = main(argv=[os.path.join(cases_path, '3clause_bsd/case.py')]) assert rc == 0, 'Found errors' def test_mit0_py(): rc = main(argv=[os.path.join(cases_path, 'mit0/case.py')]) assert rc == 0, 'Found errors' def test_mit_py(): rc = main(argv=[os.path.join(cases_path, 'mit/case.py')]) assert rc == 0, 'Found errors' def test_mit_cpp(): rc = main(argv=[os.path.join(cases_path, 'mit/case2.cpp')]) assert rc == 0, 'Found errors' def test_incorrect_exclusion(): """ Checks that excluding a single filename does not work. `ament_copyright --exclude ` should not exclude anything. """ rc = main(argv=[os.path.join(cases_path, 'mit/case.py'), '--exclude', 'case.py']) assert rc == 0, 'Found errors' def test_correct_exclusion(): """ Checks that excluding a file relatively/absolutely works as expected. `ament_copyright --exclude ` should exclude . """ with redirect_stdout(f): rc = main( argv=[ os.path.join(cases_path, 'mit/case.py'), '--exclude', os.path.join(cases_path, 'mit/case.py') ]) assert 'No repository roots and files found' in f.getvalue() assert rc == 0, 'Found errors' def test_wildcard_exclusion(): """ Checks that wildcard exclusion works correctly. `ament_copyright --exclude ` should exclude all files in . """ with redirect_stdout(f): rc = main( argv=[ os.path.join(cases_path, 'mit'), '--exclude', os.path.join(cases_path, 'mit/*') ]) assert 'No repository roots and files found' in f.getvalue() assert rc == 0, 'Found errors' ament_lint-0.12.0/ament_copyright/test/test_crawler.py000066400000000000000000000050001420377356500231560ustar00rootroot00000000000000# Copyright 2021 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from pathlib import Path from ament_copyright.crawler import get_files cases_path = Path(__file__).parent / 'cases' / 'crawler' extensions = [ 'c', 'cc', 'cpp', 'cxx', 'h', 'hh', 'hpp', 'hxx', 'cmake', 'py', ] def test_search_nested(): """Test that files are found across nested directories.""" assert len(get_files([cases_path], extensions, [])) == 4 def test_search_incorrect_extensions(): """Test that extensions are respected during search.""" assert not get_files([cases_path], ['java'], []) def test_search_single_file_name(): """ Test that the crawler finds no files with simply a filename. The assumption being that said filename does not exist relative to the test script. """ assert not get_files(['case.py'], extensions, []) def test_exclude_file_name_incorrect(): """Excluding a single file name should not work, all files found.""" excludes = [str('case.py')] assert len(get_files([cases_path], extensions, excludes)) == 4 def test_exclude_file_name_correct(): """ Checks that the crawler excludes a single file if that is excluded relatively/absolutely. Plus, checks that nested directories are respected. """ excludes = [str(cases_path / 'case.py')] assert len(get_files([cases_path], extensions, excludes)) == 3 excludes = [str(cases_path / 'subdir' / 'case.py')] assert len(get_files([cases_path], extensions, excludes)) == 3 def test_exclude_dir(): """Excluding a directory alone should not work, all files found.""" assert len(get_files([cases_path], extensions, [str(cases_path)])) == 4 def test_exclude_wildcard(): """Wildcard exclusion should work, and nested directories are respected.""" excludes = [str(cases_path / '*')] assert len(get_files([cases_path], extensions, excludes)) == 2 excludes = [str(cases_path / 'subdir' / '*')] assert len(get_files([cases_path], extensions, excludes)) == 2 ament_lint-0.12.0/ament_copyright/test/test_flake8.py000066400000000000000000000015641420377356500227040ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_copyright/test/test_pep257.py000066400000000000000000000014211420377356500225440ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pep257.main import main import pytest @pytest.mark.linter @pytest.mark.pep257 def test_pep257(): rc = main(argv=[]) assert rc == 0, 'Found docblock style errors' ament_lint-0.12.0/ament_cppcheck/000077500000000000000000000000001420377356500167045ustar00rootroot00000000000000ament_lint-0.12.0/ament_cppcheck/CHANGELOG.rst000066400000000000000000000240331420377356500207270ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cppcheck ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- * Disable cppcheck 2.x. (`#345 `_) * Contributors: Chris Lalancette 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Add cppcheck libraries option (`#323 `_) * adding ament_cppcheck libraries option * pass libraries option via CMake Co-authored-by: William Wedler * Contributors: Audrow Nash, Will 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Fix file exclusion behavior in ament_cppcheck and ament_cpplint (`#299 `_) * fix exclude behavior in ament_cppcheck and ament_cpplint * fix flake8 errors * add missing realpath() conversion * Contributors: Audrow Nash, M. Mei 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Suppress unknownMacro (`#268 `_) cppcheck creates an unknownMacro error when it cannot resolve a macro. Since we don't pass in all dependent headers, we don't expect all macros to be discoverable by cppcheck. * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang, Dan Rose 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ * Updated cpplint and cppcheck to exclude directories and files (`#234 `_) * UPted cpplint and cppcheck to exclude directories and files * setting a global variable to configure automatic linting * Fixed cmake docbloc * Added feedback * Allowed cpplint to exclude files * Restored cpplint.py * Contributors: Alejandro Hernández Cordero 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Generate xunit files valid for the junit10.xsd (`#220 `_) * Suppress internalAstError (`#219 `_) `cppcheck` can, in some cases, construct an invalid parse tree. http://build.ros2.org/user/rotu/my-views/view/CycloneDDS/job/Fci__nightly-cyclonedds_ubuntu_focal_amd64/lastCompletedBuild/testReport/rclcpp/cppcheck/error__internalAstError__src_rclcpp_clock_cpp_159\_/ ``` - rclcpp.cppcheck error: internalAstError (src/rclcpp/clock.cpp:159) <<< failure message Syntax Error: AST broken, 'if' doesn't have two operands. >>> ``` This error sounds like a syntax error, but is in fact, not. (cppcheck doesn't seem to even find the syntax error in `if(1,1){}`) This commit causes such errors to be silently ignored, as they are not actionable. * [ament_cppcheck] Report errors from additional includes (`#216 `_) * [ament_cppcheck] Report errors from additional includes Before, if an error was found in an additional include we get a KeyError exception. * Use defaultdict * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dan Rose, Dirk Thomas, Jacob Perron, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * fix handling mixed relative/absolute path in ament_cppcheck (`#188 `_) * fix handling mixed relative/absolute path in ament_cppcheck * use 'in' operator * use os.path.samefile so it doesn't matter which of the two args is relative / absolute / symlinked * skip printing duplicate errors * install manifest files in Python packages (`#185 `_) * Alternate approach to avoiding cppcheck 1.88 (`#175 `_) This approach does not require cppcheck to be present at build time. * avoid cppcheck version 1.88 due to performance issues (`#168 `_) * avoid cppcheck version 1.88 due to performance issues * downgrade to status from warning when skipping * Contributors: Dirk Thomas, Scott K Logan, William Woodall 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ * fix cppcheck report to list checked files (`#134 `_) * Contributors: Dirk Thomas 0.6.3 (2019-01-14) ------------------ * Pass include paths to cppcheck (`#117 `_) * Use BUILDSYSTEM_TARGETS list for getting include directories * Only pass include directories that are subdirectories of the package being tested This eliminates the need for a longer test timeout and avoids cppcheck from testing external files. Reverted prior changes accordingly. * Handle case when cppcheck reports error in filename with arbitrary path * Add find_package and dependency tag for ament_cmake_core * Contributors: Jacob Perron 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ * level setup.py versions to 0.5.1 * Contributors: Mikael Arguedas 0.5.0 (2018-06-18 10:09) ------------------------ * set zip_safe to avoid warning during installation (`#96 `_) * Contributors: Dirk Thomas 0.4.0 (2017-12-08) ------------------ * remove test_suite, add pytest as test_requires * 0.0.3 * Merge pull request `#84 `_ from ament/flake8_plugins update style to satisfy new flake8 plugins * update style to satisfy new flake8 plugins * Merge pull request `#81 `_ from ament/ignore_build_spaces ignore folders with an AMENT_IGNORE file, e.g. build spaces * ignore folders with an AMENT_IGNORE file, e.g. build spaces * 0.0.2 * opt to pass the language through to cppcheck (`#79 `_) * opt to pass the language through to cppcheck * add explicit LANGUAGE argument * alpha ordering on arguments and typo * fixup * [cppcheck] Remove xml warning (`#69 `_) * update to xml version 2, v1 being deprecated * parse xml v2 error outputs * remove unnecessary variable * remove __future_\_ imports * update schema url * add schema to manifest files * Merge pull request `#42 `_ from ament/remove_second_extension remove result type extension from testsuite name * remove result type extension from testsuite name * apply normpath to prevent './' prefix (fix `#24 `_) * clarify help for ament_cppcheck * improve error messages * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * move cmake part of ament_cppcheck to ament_cmake_cppcheck * disable debug output * Merge pull request `#17 `_ from ament/cppcheck_windows find cppcheck on windows * find cppcheck on windows, use env var for program files location * add trailing newline to generated test result files * add missing copyright / license information * Merge pull request `#14 `_ from ament/test_runner_windows change test runner to work on windows * change test runner to work on windows * Merge pull request `#9 `_ from ament/docs add docs for linters * add docs for linters * modify generated unit test files for a better hierarchy in Jenkins * fix copy-n-pasted license names * make testname argument optional for all linters * use other linters for the linter packages where possible * Merge pull request `#2 `_ from ament/ament_lint_auto allow linting based on test dependencies only * add ament_lint_auto and ament_lint_common, update all linter packages to implement extension point of ament_lint_auto * use project(.. NONE) * update to latest refactoring of ament_cmake * add dependency on ament_cmake_environment * add ament_cppcheck * Contributors: Dirk Thomas, Mikael Arguedas, William Woodall ament_lint-0.12.0/ament_cppcheck/ament_cppcheck/000077500000000000000000000000001420377356500216505ustar00rootroot00000000000000ament_lint-0.12.0/ament_cppcheck/ament_cppcheck/__init__.py000066400000000000000000000000001420377356500237470ustar00rootroot00000000000000ament_lint-0.12.0/ament_cppcheck/ament_cppcheck/main.py000077500000000000000000000277201420377356500231610ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse from collections import defaultdict import multiprocessing import os from shutil import which import subprocess import sys import time from xml.etree import ElementTree from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr def find_cppcheck_executable(): additional_paths = None if os.name == 'nt': # search in location where cppcheck is installed via chocolatey program_files_32 = os.environ.get('ProgramFiles(x86)', 'C:\\Program Files (x86)') additional_paths = [os.path.join(program_files_32, 'Cppcheck')] return find_executable('cppcheck', additional_paths=additional_paths) def get_cppcheck_version(cppcheck_bin): version_cmd = [cppcheck_bin, '--version'] output = subprocess.check_output(version_cmd) # expecting something like b'Cppcheck 1.88\n' or b'Cppcheck 2.7 dev' output = output.decode().strip() tokens = output.split() if len(tokens) not in (2, 3): raise RuntimeError("unexpected cppcheck version string '{}'".format(output)) if tokens[0] != 'Cppcheck': raise RuntimeError("unexpected cppcheck version name '{}'".format(output)) return tokens[1] def main(argv=sys.argv[1:]): extensions = ['c', 'cc', 'cpp', 'cxx', 'h', 'hh', 'hpp', 'hxx'] parser = argparse.ArgumentParser( description='Perform static code analysis using cppcheck.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='Files and/or directories to be checked. Directories are searched recursively for ' 'files ending in one of %s.' % ', '.join(["'.%s'" % e for e in extensions])) parser.add_argument( '--libraries', nargs='*', help="Library configurations to load in addition to the standard libraries of C and C++." "Each library is passed to cppcheck as '--library='") parser.add_argument( '--include_dirs', nargs='*', help="Include directories for C/C++ files being checked." "Each directory is passed to cppcheck as '-I '") parser.add_argument( '--exclude', nargs='*', help="Exclude C/C++ files from being checked." "Each file is passed to cppcheck as '--suppress=*:'") parser.add_argument( '--language', help="Passed to cppcheck as '--language=', and it forces cppcheck to consider " "as the given language ('c' or 'c++').") # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') # option to just get the cppcheck version and print that parser.add_argument( '--cppcheck-version', action='store_true', help='Get the cppcheck version, print it, and then exit.') args = parser.parse_args(argv) cppcheck_bin = find_cppcheck_executable() if not cppcheck_bin: print("Could not find 'cppcheck' executable", file=sys.stderr) return 1 cppcheck_version = get_cppcheck_version(cppcheck_bin) if args.cppcheck_version: print(cppcheck_version) return 0 if args.xunit_file: start_time = time.time() files = get_files(args.paths, extensions) if not files: print('No files found', file=sys.stderr) return 1 # try to determine the number of CPU cores jobs = None try: jobs = multiprocessing.cpu_count() except NotImplementedError: # the number of cores cannot be determined, do not extend args pass # detect cppcheck 1.88 or 2.x which are much too slow if 'AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS' not in os.environ: if cppcheck_version == '1.88' or cppcheck_version.startswith('2.'): print( f'cppcheck {cppcheck_version} has known performance issues and therefore will not ' 'be used, set the AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS environment variable to override this.', file=sys.stderr, ) if args.xunit_file: report = {input_file: [] for input_file in files} write_xunit_file( args.xunit_file, report, time.time() - start_time, skip=f'cppcheck {cppcheck_version} performance issues' ) return 0 return 188 # invoke cppcheck cmd = [cppcheck_bin, '-f', '--inline-suppr', '-q', '-rp', '--xml', '--xml-version=2', '--suppress=internalAstError', '--suppress=unknownMacro'] if args.language: cmd.extend(['--language={0}'.format(args.language)]) for library in (args.libraries or []): cmd.extend(['--library={0}'.format(library)]) for include_dir in (args.include_dirs or []): cmd.extend(['-I', include_dir]) for exclude in (args.exclude or []): cmd.extend(['--suppress=*:' + exclude]) if jobs: cmd.extend(['-j', '%d' % jobs]) cmd.extend(files) try: p = subprocess.Popen(cmd, stderr=subprocess.PIPE) xml = p.communicate()[1] except subprocess.CalledProcessError as e: print("The invocation of 'cppcheck' failed with error code %d: %s" % (e.returncode, e), file=sys.stderr) return 1 try: root = ElementTree.fromstring(xml) except ElementTree.ParseError as e: print('Invalid XML in cppcheck output: %s' % str(e), file=sys.stderr) return 1 # output errors report = defaultdict(list) # even though we use a defaultdict, explicity add known files so they are listed for filename in files: report[filename] = [] for error in root.find('errors'): location = error.find('location') filename = location.get('file') data = { 'line': int(location.get('line')), 'id': error.get('id'), 'severity': error.get('severity'), 'msg': error.get('verbose'), } for key in report.keys(): if os.path.samefile(key, filename): filename = key break # in the case where relative and absolute paths are mixed for paths and # include_dirs cppcheck might return duplicate results if data not in report[filename]: report[filename].append(data) data = dict(data) data['filename'] = filename print('[%(filename)s:%(line)d]: (%(severity)s: %(id)s) %(msg)s' % data, file=sys.stderr) # output summary error_count = sum(len(r) for r in report.values()) if not error_count: print('No problems found') rc = 0 else: print('%d errors' % error_count, file=sys.stderr) rc = 1 # generate xunit file if args.xunit_file: write_xunit_file(args.xunit_file, report, time.time() - start_time) return rc def find_executable(file_name, additional_paths=None): path = None if additional_paths: path = os.getenv('PATH', os.defpath) path += os.path.pathsep + os.path.pathsep.join(additional_paths) return which(file_name, path=path) def get_files(paths, extensions): files = [] for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] dirnames.sort() # select files by extension for filename in sorted(filenames): _, ext = os.path.splitext(filename) if ext in ['.%s' % e for e in extensions]: files.append(os.path.join(dirpath, filename)) if os.path.isfile(path): files.append(path) return [os.path.normpath(f) for f in files] def get_xunit_content(report, testname, elapsed, skip=None): test_count = sum(max(len(r), 1) for r in report.values()) error_count = sum(len(r) for r in report.values()) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), 'skip': test_count if skip else 0, } xml = """ """ % data for filename in sorted(report.keys()): errors = report[filename] if skip: data = { 'quoted_name': quoteattr(filename), 'testname': testname, 'quoted_message': quoteattr(''), 'skip': skip, } xml += """ ![CDATA[Test Skipped due to %(skip)s]] """ % data elif errors: # report each cppcheck error as a failing testcase for error in errors: data = { 'quoted_name': quoteattr( '%s: %s (%s:%d)' % ( error['severity'], error['id'], filename, error['line'])), 'testname': testname, 'quoted_message': quoteattr(error['msg']), } xml += """ """ % data else: # if there are no cpplint errors report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files if skip: data = { 'skip': skip, } xml += """ Tests Skipped due to %(skip)s """ % data else: data = { 'escaped_files': escape( ''.join(['\n* %s' % r for r in sorted(report.keys())]) ), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml def write_xunit_file(xunit_file, report, duration, skip=None): folder_name = os.path.basename(os.path.dirname(xunit_file)) file_name = os.path.basename(xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, duration, skip) path = os.path.dirname(os.path.abspath(xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(xunit_file, 'w') as f: f.write(xml) if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_cppcheck/doc/000077500000000000000000000000001420377356500174515ustar00rootroot00000000000000ament_lint-0.12.0/ament_cppcheck/doc/index.rst000066400000000000000000000012471420377356500213160ustar00rootroot00000000000000ament_cppcheck ============== Performs a static code analysis of C / C++ source files using `CppCheck `_. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_cppcheck [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_cppcheck `_. ament_lint-0.12.0/ament_cppcheck/package.xml000066400000000000000000000014571420377356500210300ustar00rootroot00000000000000 ament_cppcheck 0.12.0 The ability to perform static code analysis on C/C++ code using Cppcheck and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas cppcheck ament_python ament_lint-0.12.0/ament_cppcheck/pytest.ini000066400000000000000000000000351420377356500207330ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_cppcheck/resource/000077500000000000000000000000001420377356500205335ustar00rootroot00000000000000ament_lint-0.12.0/ament_cppcheck/resource/ament_cppcheck000066400000000000000000000000001420377356500234100ustar00rootroot00000000000000ament_lint-0.12.0/ament_cppcheck/setup.py000066400000000000000000000025531420377356500204230ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_cppcheck' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], zip_safe=True, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Static code analysis on C/C++ code using Cppcheck.', long_description="""\ The ability to perform static code analysis on C/C++ code using Cppcheck and generate xUnit test result files.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_cppcheck = ament_cppcheck.main:main', ], }, ) ament_lint-0.12.0/ament_cpplint/000077500000000000000000000000001420377356500165755ustar00rootroot00000000000000ament_lint-0.12.0/ament_cpplint/CHANGELOG.rst000066400000000000000000000275271420377356500206330ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_cpplint ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Reapply patches Reapply parts of 232428752251de61e84ef013bcd643e35eb9038d that are still relevant. * Update cpplint version Point to the fork https://github.com/cpplint/cpplint Contains updates for modern C++ standards (e.g. C++14 and C++17). * Contributors: Audrow Nash, Dirk Thomas, Jacob Perron 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * [ament_copyright] Fix file exclusion behavior (`#327 `_) * [ament_copyright] Fix file exclusion behavior This commit fixes the faulty file exclusion behavior reported in https://github.com/ament/ament_lint/issues/326. Specifically, the exclusion list is matched against traversed files in the `crawler` module. Changes inspired by https://github.com/ament/ament_lint/pull/299/. * Update excluded file path in copyright tests Since file names are not indiscriminately matched throughout the search tree anymore, the excluded files listed in the copyright tests need to be updated relative to the root of the package. * Add test cases to check exclusion behavior Specifically, these tests check for: - Incorrect exclusion of single filenames. - Correct exclusion of relatively/absolutely addressed filenames. - Correct exclusion of wildcarded paths. * Add unit tests for crawler module These unit tests make sure both search and exclusion behaviors are correctly demonstrated by the `ament_copyright.crawler` module. * Contributors: Abrar Rahman Protyasha, Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Fix file exclusion behavior in ament_cppcheck and ament_cpplint (`#299 `_) * fix exclude behavior in ament_cppcheck and ament_cpplint * fix flake8 errors * add missing realpath() conversion * Contributors: Audrow Nash, M. Mei 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ * Close source files after reading them (`#249 `_) Resolves the ResourceWarning messages coming to the console during testing with debug-enabled Python. * Contributors: Scott K Logan 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * Generate xunit files valid for the junit10.xsd (`#220 `_) * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dirk Thomas, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Convert list comprehension to generator (`#179 `_) Addresses flake8 C412 errors introduced by flake8-comprehension 2.2.0 * Contributors: Dirk Thomas, Scott K Logan 0.7.4 (2019-07-31) ------------------ * Escape backslashes in cpplint.py This gets rid of DeprecationWarning on Windows. * Contributors: Chris Lalancette 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ * fix sorting of keys in same cases (`#127 `_) * Contributors: Dirk Thomas 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ * level setup.py versions to 0.5.1 * Contributors: Mikael Arguedas 0.5.0 (2018-06-18 10:09) ------------------------ * add pytest markers to linter tests * set zip_safe to avoid warning during installation (`#96 `_) * fix root logic of cpplint (`#94 `_) * Contributors: Dirk Thomas 0.4.0 (2017-12-08) ------------------ * remove test_suite, add pytest as test_requires * add filters argument to cpplint (`#87 `_) * add filters argument to cpplint * full ellipsis * string -> strings * 0.0.3 * Merge pull request `#84 `_ from ament/flake8_plugins update style to satisfy new flake8 plugins * update style to satisfy new flake8 plugins * Merge pull request `#81 `_ from ament/ignore_build_spaces ignore folders with an AMENT_IGNORE file, e.g. build spaces * ignore folders with an AMENT_IGNORE file, e.g. build spaces * 0.0.2 * Merge pull request `#78 `_ from ament/use_flake8 use flake8 instead of pep8 and pyflakes * fix style warnings * use flake8 instead of pep8 and pyflakes * cpplint: allow using-directive for a whitelist of namespaces (`#67 `_) This will permit the use of std::chrono and other useful new literals in C++14, which are most conveniently brought in via "using namespace" * remove __future_\_ imports * Merge pull request `#59 `_ from ament/update_cpplint update cpplint * reapply patches * use new --headers option * pull new version from upstream * update schema url * add schema to manifest files * Merge pull request `#54 `_ from ament/update_cpplint update cpplint * find deepest vcs path instead of most top level * update to latest upstream version of cpplint * Merge pull request `#52 `_ from ament/lint_generated_code fix handling of --root * fix handling of --root * Merge pull request `#46 `_ from ament/fix_cpplint_root fix algo to determine --root for cpplint * fix algo to determine --root for cpplint * Merge pull request `#43 `_ from ament/ignore_space_after_semicolon ignore space after a semi colon * also advice cpplint to ignore whitespace after semicolon * Merge pull request `#42 `_ from ament/remove_second_extension remove result type extension from testsuite name * remove result type extension from testsuite name * Merge pull request `#40 `_ from ament/cpplint_root add --root option to ament_cpplint * add --root option to ament_cpplint * Merge pull request `#39 `_ from ament/cpplint_python3 use Python 3 for cpplint and split into Python and CMake package * fix matching root on Windows * refactor ament_cpplint into Python and CMake package * modify cpplint to work with Python 3 * Merge pull request `#37 `_ from ament/patches enforce single line comments for closing namespaces * fix infinite loop * only allow single line comments for closing namespaces * Merge pull request `#35 `_ from ament/cpplint-int Reenable int/long check * Reenable int/long check * Merge pull request `#33 `_ from ament/disable_cpplint_runtime_int ignore cpplint runtime/int error * ignore cpplint runtime/int error * Merge pull request `#32 `_ from ament/cpplint_c_style_casts allow C-style casts in c code * allow C-style casts in c code * workaround to check guard variable for all header files * Merge pull request `#31 `_ from ament/config_cpplint update cpplint configuration * fix --root for files which are directly in the include/src/test folder * update cpplint options and implement custom include guard pattern * update url for cpplint * Merge pull request `#30 `_ from ament/test_labels add labels to tests * add labels to tests * Merge pull request `#29 `_ from ament/change_test_dependencies update documentation for linters * update documentation for linters * Merge pull request `#27 `_ from ament/gtest_location add type as extension to test result files * add type as extension to test result files * add explicit build type * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * move cmake part of ament_pyflakes to ament_cmake_pyflakes * move cmake part of ament_pep8 to ament_cmake_pep8 * move cmake part of ament_lint_cmake to ament_cmake_lint_cmake * disable debug output * add trailing newline to generated test result files * add missing copyright / license information * Merge pull request `#14 `_ from ament/test_runner_windows change test runner to work on windows * change test runner to work on windows * Merge pull request `#9 `_ from ament/docs add docs for linters * add docs for linters * modify generated unit test files for a better hierarchy in Jenkins * make testname argument optional for all linters * use other linters for the linter packages where possible * update cpplint to rev 141 * Merge pull request `#2 `_ from ament/ament_lint_auto allow linting based on test dependencies only * add ament_lint_auto and ament_lint_common, update all linter packages to implement extension point of ament_lint_auto * use project(.. NONE) * update to latest refactoring of ament_cmake * add dependency on ament_cmake_environment * add ament_pyflakes * add ament_lint_cmake * add ament_cpplint * Contributors: Dirk Thomas, Esteve Fernandez, Guillaume Papin, William Woodall ament_lint-0.12.0/ament_cpplint/ament_cpplint/000077500000000000000000000000001420377356500214325ustar00rootroot00000000000000ament_lint-0.12.0/ament_cpplint/ament_cpplint/__init__.py000066400000000000000000000000001420377356500235310ustar00rootroot00000000000000ament_lint-0.12.0/ament_cpplint/ament_cpplint/cpplint.py000066400000000000000000010017071420377356500234630ustar00rootroot00000000000000#!/usr/bin/env python3 # # Copyright (c) 2009 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # https://github.com/cpplint/cpplint/blob/6b1d29874dc5d7c3c9201b70e760b3eb9468a60d/cpplint.py """Does google-lint on c++ files. The goal of this script is to identify places in the code that *may* be in non-compliance with google style. It does not attempt to fix up these problems -- the point is to educate. It does also not attempt to find all problems, or to ensure that everything it does find is legitimately a problem. In particular, we can get very confused by /* and // inside strings! We do a small hack, which is to ignore //'s with "'s after them on the same line, but it is far from perfect (in either direction). """ import codecs import copy import getopt import glob import itertools import math # for log import os import re import sre_compile import string import sys import sysconfig import unicodedata import xml.etree.ElementTree # if empty, use defaults _valid_extensions = set([]) __VERSION__ = '1.5.5' try: xrange # Python 2 except NameError: # -- pylint: disable=redefined-builtin xrange = range # Python 3 _USAGE = """ Syntax: cpplint.py [--verbose=#] [--output=emacs|eclipse|vs7|junit|sed|gsed] [--filter=-x,+y,...] [--counting=total|toplevel|detailed] [--root=subdir] [--repository=path] [--linelength=digits] [--headers=x,y,...] [--recursive] [--exclude=path] [--extensions=hpp,cpp,...] [--includeorder=default|standardcfirst] [--quiet] [--version] [file] ... Style checker for C/C++ source files. This is a fork of the Google style checker with minor extensions. The style guidelines this tries to follow are those in https://google.github.io/styleguide/cppguide.html Every problem is given a confidence score from 1-5, with 5 meaning we are certain of the problem, and 1 meaning it could be a legitimate construct. This will miss some errors, and is not a substitute for a code review. To suppress false-positive errors of a certain category, add a 'NOLINT(category)' comment to the line. NOLINT or NOLINT(*) suppresses errors of all categories on that line. The files passed in will be linted; at least one file must be provided. Default linted extensions are %s. Other file types will be ignored. Change the extensions with the --extensions flag. Flags: output=emacs|eclipse|vs7|junit|sed|gsed By default, the output is formatted to ease emacs parsing. Visual Studio compatible output (vs7) may also be used. Further support exists for eclipse (eclipse), and JUnit (junit). XML parsers such as those used in Jenkins and Bamboo may also be used. The sed format outputs sed commands that should fix some of the errors. Note that this requires gnu sed. If that is installed as gsed on your system (common e.g. on macOS with homebrew) you can use the gsed output format. Sed commands are written to stdout, not stderr, so you should be able to pipe output straight to a shell to run the fixes. verbose=# Specify a number 0-5 to restrict errors to certain verbosity levels. Errors with lower verbosity levels have lower confidence and are more likely to be false positives. quiet Don't print anything if no errors are found. filter=-x,+y,... Specify a comma-separated list of category-filters to apply: only error messages whose category names pass the filters will be printed. (Category names are printed with the message and look like "[whitespace/indent]".) Filters are evaluated left to right. "-FOO" means "do not print categories that start with FOO". "+FOO" means "do print categories that start with FOO". Examples: --filter=-whitespace,+whitespace/braces --filter=-whitespace,-runtime/printf,+runtime/printf_format --filter=-,+build/include_what_you_use To see a list of all the categories used in cpplint, pass no arg: --filter= counting=total|toplevel|detailed The total number of errors found is always printed. If 'toplevel' is provided, then the count of errors in each of the top-level categories like 'build' and 'whitespace' will also be printed. If 'detailed' is provided, then a count is provided for each category like 'build/class'. repository=path The top level directory of the repository, used to derive the header guard CPP variable. By default, this is determined by searching for a path that contains .git, .hg, or .svn. When this flag is specified, the given path is used instead. This option allows the header guard CPP variable to remain consistent even if members of a team have different repository root directories (such as when checking out a subdirectory with SVN). In addition, users of non-mainstream version control systems can use this flag to ensure readable header guard CPP variables. Examples: Assuming that Alice checks out ProjectName and Bob checks out ProjectName/trunk and trunk contains src/chrome/ui/browser.h, then with no --repository flag, the header guard CPP variable will be: Alice => TRUNK_SRC_CHROME_BROWSER_UI_BROWSER_H_ Bob => SRC_CHROME_BROWSER_UI_BROWSER_H_ If Alice uses the --repository=trunk flag and Bob omits the flag or uses --repository=. then the header guard CPP variable will be: Alice => SRC_CHROME_BROWSER_UI_BROWSER_H_ Bob => SRC_CHROME_BROWSER_UI_BROWSER_H_ root=subdir The root directory used for deriving header guard CPP variable. This directory is relative to the top level directory of the repository which by default is determined by searching for a directory that contains .git, .hg, or .svn but can also be controlled with the --repository flag. If the specified directory does not exist, this flag is ignored. Examples: Assuming that src is the top level directory of the repository (and cwd=top/src), the header guard CPP variables for src/chrome/browser/ui/browser.h are: No flag => CHROME_BROWSER_UI_BROWSER_H_ --root=chrome => BROWSER_UI_BROWSER_H_ --root=chrome/browser => UI_BROWSER_H_ --root=.. => SRC_CHROME_BROWSER_UI_BROWSER_H_ linelength=digits This is the allowed line length for the project. The default value is 80 characters. Examples: --linelength=120 recursive Search for files to lint recursively. Each directory given in the list of files to be linted is replaced by all files that descend from that directory. Files with extensions not in the valid extensions list are excluded. exclude=path Exclude the given path from the list of files to be linted. Relative paths are evaluated relative to the current directory and shell globbing is performed. This flag can be provided multiple times to exclude multiple files. Examples: --exclude=one.cc --exclude=src/*.cc --exclude=src/*.cc --exclude=test/*.cc extensions=extension,extension,... The allowed file extensions that cpplint will check Examples: --extensions=%s includeorder=default|standardcfirst For the build/include_order rule, the default is to blindly assume angle bracket includes with file extension are c-system-headers (default), even knowing this will have false classifications. The default is established at google. standardcfirst means to instead use an allow-list of known c headers and treat all others as separate group of "other system headers". The C headers included are those of the C-standard lib and closely related ones. headers=x,y,... The header extensions that cpplint will treat as .h in checks. Values are automatically added to --extensions list. (by default, only files with extensions %s will be assumed to be headers) Examples: --headers=%s --headers=hpp,hxx --headers=hpp cpplint.py supports per-directory configurations specified in CPPLINT.cfg files. CPPLINT.cfg file can contain a number of key=value pairs. Currently the following options are supported: set noparent filter=+filter1,-filter2,... exclude_files=regex linelength=80 root=subdir headers=x,y,... "set noparent" option prevents cpplint from traversing directory tree upwards looking for more .cfg files in parent directories. This option is usually placed in the top-level project directory. The "filter" option is similar in function to --filter flag. It specifies message filters in addition to the |_DEFAULT_FILTERS| and those specified through --filter command-line flag. "exclude_files" allows to specify a regular expression to be matched against a file name. If the expression matches, the file is skipped and not run through the linter. "linelength" allows to specify the allowed line length for the project. The "root" option is similar in function to the --root flag (see example above). Paths are relative to the directory of the CPPLINT.cfg. The "headers" option is similar in function to the --headers flag (see example above). CPPLINT.cfg has an effect on files in the same directory and all sub-directories, unless overridden by a nested configuration file. Example file: filter=-build/include_order,+build/include_alpha exclude_files=.*\\.cc The above example disables build/include_order warning and enables build/include_alpha as well as excludes all .cc from being processed by linter, in the current directory (where the .cfg file is located) and all sub-directories. """ # We categorize each error message we print. Here are the categories. # We want an explicit list so we can list them all in cpplint --filter=. # If you add a new error message with a new category, add it to the list # here! cpplint_unittest.py should tell you if you forget to do this. _ERROR_CATEGORIES = [ 'build/class', 'build/c++11', 'build/c++14', 'build/c++tr1', 'build/deprecated', 'build/endif_comment', 'build/explicit_make_pair', 'build/forward_decl', 'build/header_guard', 'build/include', 'build/include_subdir', 'build/include_alpha', 'build/include_order', 'build/include_what_you_use', 'build/namespaces_headers', 'build/namespaces_literals', 'build/namespaces', 'build/printf_format', 'build/storage_class', 'legal/copyright', 'readability/alt_tokens', 'readability/braces', 'readability/casting', 'readability/check', 'readability/constructors', 'readability/fn_size', 'readability/inheritance', 'readability/multiline_comment', 'readability/multiline_string', 'readability/namespace', 'readability/nolint', 'readability/nul', 'readability/strings', 'readability/todo', 'readability/utf8', 'runtime/arrays', 'runtime/casting', 'runtime/explicit', 'runtime/int', 'runtime/init', 'runtime/invalid_increment', 'runtime/member_string_references', 'runtime/memset', 'runtime/indentation_namespace', 'runtime/operator', 'runtime/printf', 'runtime/printf_format', 'runtime/references', 'runtime/string', 'runtime/threadsafe_fn', 'runtime/vlog', 'whitespace/blank_line', 'whitespace/braces', 'whitespace/comma', 'whitespace/comments', 'whitespace/empty_conditional_body', 'whitespace/empty_if_body', 'whitespace/empty_loop_body', 'whitespace/end_of_line', 'whitespace/ending_newline', 'whitespace/forcolon', 'whitespace/indent', 'whitespace/line_length', 'whitespace/newline', 'whitespace/operators', 'whitespace/parens', 'whitespace/semicolon', 'whitespace/tab', 'whitespace/todo', ] # keywords to use with --outputs which generate stdout for machine processing _MACHINE_OUTPUTS = [ 'junit', 'sed', 'gsed' ] # These error categories are no longer enforced by cpplint, but for backwards- # compatibility they may still appear in NOLINT comments. _LEGACY_ERROR_CATEGORIES = [ 'readability/streams', 'readability/function', ] # The default state of the category filter. This is overridden by the --filter= # flag. By default all errors are on, so only add here categories that should be # off by default (i.e., categories that must be enabled by the --filter= flags). # All entries here should start with a '-' or '+', as in the --filter= flag. _DEFAULT_FILTERS = ['-build/include_alpha'] # The default list of categories suppressed for C (not C++) files. _DEFAULT_C_SUPPRESSED_CATEGORIES = [ 'readability/casting', ] # The default list of categories suppressed for Linux Kernel files. _DEFAULT_KERNEL_SUPPRESSED_CATEGORIES = [ 'whitespace/tab', ] # We used to check for high-bit characters, but after much discussion we # decided those were OK, as long as they were in UTF-8 and didn't represent # hard-coded international strings, which belong in a separate i18n file. # C++ headers _CPP_HEADERS = frozenset([ # Legacy 'algobase.h', 'algo.h', 'alloc.h', 'builtinbuf.h', 'bvector.h', 'complex.h', 'defalloc.h', 'deque.h', 'editbuf.h', 'fstream.h', 'function.h', 'hash_map', 'hash_map.h', 'hash_set', 'hash_set.h', 'hashtable.h', 'heap.h', 'indstream.h', 'iomanip.h', 'iostream.h', 'istream.h', 'iterator.h', 'list.h', 'map.h', 'multimap.h', 'multiset.h', 'ostream.h', 'pair.h', 'parsestream.h', 'pfstream.h', 'procbuf.h', 'pthread_alloc', 'pthread_alloc.h', 'rope', 'rope.h', 'ropeimpl.h', 'set.h', 'slist', 'slist.h', 'stack.h', 'stdiostream.h', 'stl_alloc.h', 'stl_relops.h', 'streambuf.h', 'stream.h', 'strfile.h', 'strstream.h', 'tempbuf.h', 'tree.h', 'type_traits.h', 'vector.h', # 17.6.1.2 C++ library headers 'algorithm', 'array', 'atomic', 'bitset', 'chrono', 'codecvt', 'complex', 'condition_variable', 'deque', 'exception', 'forward_list', 'fstream', 'functional', 'future', 'initializer_list', 'iomanip', 'ios', 'iosfwd', 'iostream', 'istream', 'iterator', 'limits', 'list', 'locale', 'map', 'memory', 'mutex', 'new', 'numeric', 'ostream', 'queue', 'random', 'ratio', 'regex', 'scoped_allocator', 'set', 'sstream', 'stack', 'stdexcept', 'streambuf', 'string', 'strstream', 'system_error', 'thread', 'tuple', 'typeindex', 'typeinfo', 'type_traits', 'unordered_map', 'unordered_set', 'utility', 'valarray', 'vector', # 17.6.1.2 C++14 headers 'shared_mutex', # 17.6.1.2 C++17 headers 'any', 'charconv', 'codecvt', 'execution', 'filesystem', 'memory_resource', 'optional', 'string_view', 'variant', # 17.6.1.2 C++ headers for C library facilities 'cassert', 'ccomplex', 'cctype', 'cerrno', 'cfenv', 'cfloat', 'cinttypes', 'ciso646', 'climits', 'clocale', 'cmath', 'csetjmp', 'csignal', 'cstdalign', 'cstdarg', 'cstdbool', 'cstddef', 'cstdint', 'cstdio', 'cstdlib', 'cstring', 'ctgmath', 'ctime', 'cuchar', 'cwchar', 'cwctype', ]) # C headers _C_HEADERS = frozenset([ # System C headers 'assert.h', 'complex.h', 'ctype.h', 'errno.h', 'fenv.h', 'float.h', 'inttypes.h', 'iso646.h', 'limits.h', 'locale.h', 'math.h', 'setjmp.h', 'signal.h', 'stdalign.h', 'stdarg.h', 'stdatomic.h', 'stdbool.h', 'stddef.h', 'stdint.h', 'stdio.h', 'stdlib.h', 'stdnoreturn.h', 'string.h', 'tgmath.h', 'threads.h', 'time.h', 'uchar.h', 'wchar.h', 'wctype.h', # additional POSIX C headers 'aio.h', 'arpa/inet.h', 'cpio.h', 'dirent.h', 'dlfcn.h', 'fcntl.h', 'fmtmsg.h', 'fnmatch.h', 'ftw.h', 'glob.h', 'grp.h', 'iconv.h', 'langinfo.h', 'libgen.h', 'monetary.h', 'mqueue.h', 'ndbm.h', 'net/if.h', 'netdb.h', 'netinet/in.h', 'netinet/tcp.h', 'nl_types.h', 'poll.h', 'pthread.h', 'pwd.h', 'regex.h', 'sched.h', 'search.h', 'semaphore.h', 'setjmp.h', 'signal.h', 'spawn.h', 'strings.h', 'stropts.h', 'syslog.h', 'tar.h', 'termios.h', 'trace.h', 'ulimit.h', 'unistd.h', 'utime.h', 'utmpx.h', 'wordexp.h', # additional GNUlib headers 'a.out.h', 'aliases.h', 'alloca.h', 'ar.h', 'argp.h', 'argz.h', 'byteswap.h', 'crypt.h', 'endian.h', 'envz.h', 'err.h', 'error.h', 'execinfo.h', 'fpu_control.h', 'fstab.h', 'fts.h', 'getopt.h', 'gshadow.h', 'ieee754.h', 'ifaddrs.h', 'libintl.h', 'mcheck.h', 'mntent.h', 'obstack.h', 'paths.h', 'printf.h', 'pty.h', 'resolv.h', 'shadow.h', 'sysexits.h', 'ttyent.h', # Additional linux glibc headers 'dlfcn.h', 'elf.h', 'features.h', 'gconv.h', 'gnu-versions.h', 'lastlog.h', 'libio.h', 'link.h', 'malloc.h', 'memory.h', 'netash/ash.h', 'netatalk/at.h', 'netax25/ax25.h', 'neteconet/ec.h', 'netipx/ipx.h', 'netiucv/iucv.h', 'netpacket/packet.h', 'netrom/netrom.h', 'netrose/rose.h', 'nfs/nfs.h', 'nl_types.h', 'nss.h', 're_comp.h', 'regexp.h', 'sched.h', 'sgtty.h', 'stab.h', 'stdc-predef.h', 'stdio_ext.h', 'syscall.h', 'termio.h', 'thread_db.h', 'ucontext.h', 'ustat.h', 'utmp.h', 'values.h', 'wait.h', 'xlocale.h', # Hardware specific headers 'arm_neon.h', 'emmintrin.h', 'xmmintin.h', ]) # Folders of C libraries so commonly used in C++, # that they have parity with standard C libraries. C_STANDARD_HEADER_FOLDERS = frozenset([ # standard C library "sys", # glibc for linux "arpa", "asm-generic", "bits", "gnu", "net", "netinet", "protocols", "rpc", "rpcsvc", "scsi", # linux kernel header "drm", "linux", "misc", "mtd", "rdma", "sound", "video", "xen", ]) # Type names _TYPES = re.compile( r'^(?:' # [dcl.type.simple] r'(char(16_t|32_t)?)|wchar_t|' r'bool|short|int|long|signed|unsigned|float|double|' # [support.types] r'(ptrdiff_t|size_t|max_align_t|nullptr_t)|' # [cstdint.syn] r'(u?int(_fast|_least)?(8|16|32|64)_t)|' r'(u?int(max|ptr)_t)|' r')$') # These headers are excluded from [build/include] and [build/include_order] # checks: # - Anything not following google file name conventions (containing an # uppercase character, such as Python.h or nsStringAPI.h, for example). # - Lua headers. _THIRD_PARTY_HEADERS_PATTERN = re.compile( r'^(?:[^/]*[A-Z][^/]*\.h|lua\.h|lauxlib\.h|lualib\.h)$') # Pattern for matching FileInfo.BaseName() against test file name _test_suffixes = ['_test', '_regtest', '_unittest'] _TEST_FILE_SUFFIX = '(' + '|'.join(_test_suffixes) + r')$' # Pattern that matches only complete whitespace, possibly across multiple lines. _EMPTY_CONDITIONAL_BODY_PATTERN = re.compile(r'^\s*$', re.DOTALL) # Assertion macros. These are defined in base/logging.h and # testing/base/public/gunit.h. _CHECK_MACROS = [ 'DCHECK', 'CHECK', 'EXPECT_TRUE', 'ASSERT_TRUE', 'EXPECT_FALSE', 'ASSERT_FALSE', ] # Replacement macros for CHECK/DCHECK/EXPECT_TRUE/EXPECT_FALSE _CHECK_REPLACEMENT = dict([(macro_var, {}) for macro_var in _CHECK_MACROS]) for op, replacement in [('==', 'EQ'), ('!=', 'NE'), ('>=', 'GE'), ('>', 'GT'), ('<=', 'LE'), ('<', 'LT')]: _CHECK_REPLACEMENT['DCHECK'][op] = 'DCHECK_%s' % replacement _CHECK_REPLACEMENT['CHECK'][op] = 'CHECK_%s' % replacement _CHECK_REPLACEMENT['EXPECT_TRUE'][op] = 'EXPECT_%s' % replacement _CHECK_REPLACEMENT['ASSERT_TRUE'][op] = 'ASSERT_%s' % replacement for op, inv_replacement in [('==', 'NE'), ('!=', 'EQ'), ('>=', 'LT'), ('>', 'LE'), ('<=', 'GT'), ('<', 'GE')]: _CHECK_REPLACEMENT['EXPECT_FALSE'][op] = 'EXPECT_%s' % inv_replacement _CHECK_REPLACEMENT['ASSERT_FALSE'][op] = 'ASSERT_%s' % inv_replacement # Alternative tokens and their replacements. For full list, see section 2.5 # Alternative tokens [lex.digraph] in the C++ standard. # # Digraphs (such as '%:') are not included here since it's a mess to # match those on a word boundary. _ALT_TOKEN_REPLACEMENT = { 'and': '&&', 'bitor': '|', 'or': '||', 'xor': '^', 'compl': '~', 'bitand': '&', 'and_eq': '&=', 'or_eq': '|=', 'xor_eq': '^=', 'not': '!', 'not_eq': '!=' } # Compile regular expression that matches all the above keywords. The "[ =()]" # bit is meant to avoid matching these keywords outside of boolean expressions. # # False positives include C-style multi-line comments and multi-line strings # but those have always been troublesome for cpplint. _ALT_TOKEN_REPLACEMENT_PATTERN = re.compile( r'[ =()](' + ('|'.join(_ALT_TOKEN_REPLACEMENT.keys())) + r')(?=[ (]|$)') # These constants define types of headers for use with # _IncludeState.CheckNextIncludeOrder(). _C_SYS_HEADER = 1 _CPP_SYS_HEADER = 2 _OTHER_SYS_HEADER = 3 _LIKELY_MY_HEADER = 4 _POSSIBLE_MY_HEADER = 5 _OTHER_HEADER = 6 # These constants define the current inline assembly state _NO_ASM = 0 # Outside of inline assembly block _INSIDE_ASM = 1 # Inside inline assembly block _END_ASM = 2 # Last line of inline assembly block _BLOCK_ASM = 3 # The whole block is an inline assembly block # Match start of assembly blocks _MATCH_ASM = re.compile(r'^\s*(?:asm|_asm|__asm|__asm__)' r'(?:\s+(volatile|__volatile__))?' r'\s*[{(]') # Match strings that indicate we're working on a C (not C++) file. _SEARCH_C_FILE = re.compile(r'\b(?:LINT_C_FILE|' r'vim?:\s*.*(\s*|:)filetype=c(\s*|:|$))') # Match string that indicates we're working on a Linux Kernel file. _SEARCH_KERNEL_FILE = re.compile(r'\b(?:LINT_KERNEL_FILE)') # Commands for sed to fix the problem _SED_FIXUPS = { 'Remove spaces around =': r's/ = /=/', 'Remove spaces around !=': r's/ != /!=/', 'Remove space before ( in if (': r's/if (/if(/', 'Remove space before ( in for (': r's/for (/for(/', 'Remove space before ( in while (': r's/while (/while(/', 'Remove space before ( in switch (': r's/switch (/switch(/', 'Should have a space between // and comment': r's/\/\//\/\/ /', 'Missing space before {': r's/\([^ ]\){/\1 {/', 'Tab found, replace by spaces': r's/\t/ /g', 'Line ends in whitespace. Consider deleting these extra spaces.': r's/\s*$//', 'You don\'t need a ; after a }': r's/};/}/', 'Missing space after ,': r's/,\([^ ]\)/, \1/g', } _regexp_compile_cache = {} # {str, set(int)}: a map from error categories to sets of linenumbers # on which those errors are expected and should be suppressed. _error_suppressions = {} # The root directory used for deriving header guard CPP variable. # This is set by --root flag. _root = None _root_debug = False # The top level repository directory. If set, _root is calculated relative to # this directory instead of the directory containing version control artifacts. # This is set by the --repository flag. _repository = None # Files to exclude from linting. This is set by the --exclude flag. _excludes = None # Whether to supress all PrintInfo messages, UNRELATED to --quiet flag _quiet = False # The allowed line length of files. # This is set by --linelength flag. _line_length = 80 # This allows to use different include order rule than default _include_order = "default" try: unicode except NameError: # -- pylint: disable=redefined-builtin basestring = unicode = str try: long except NameError: # -- pylint: disable=redefined-builtin long = int if sys.version_info < (3,): # -- pylint: disable=no-member # BINARY_TYPE = str itervalues = dict.itervalues iteritems = dict.iteritems else: # BINARY_TYPE = bytes itervalues = dict.values iteritems = dict.items def unicode_escape_decode(x): if sys.version_info < (3,): return codecs.unicode_escape_decode(x)[0] else: return x # Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc. # This is set by --headers flag. _hpp_headers = set([]) # {str, bool}: a map from error categories to booleans which indicate if the # category should be suppressed for every line. _global_error_suppressions = {} def ProcessHppHeadersOption(val): global _hpp_headers try: _hpp_headers = {ext.strip() for ext in val.split(',')} except ValueError: PrintUsage('Header extensions must be comma separated list.') def ProcessIncludeOrderOption(val): if val is None or val == "default": pass elif val == "standardcfirst": global _include_order _include_order = val else: PrintUsage('Invalid includeorder value %s. Expected default|standardcfirst') def IsHeaderExtension(file_extension): return file_extension in GetHeaderExtensions() def GetHeaderExtensions(): if _hpp_headers: return _hpp_headers if _valid_extensions: return {h for h in _valid_extensions if 'h' in h} return set(['h', 'hh', 'hpp', 'hxx', 'h++', 'cuh']) # The allowed extensions for file names # This is set by --extensions flag def GetAllExtensions(): return GetHeaderExtensions().union(_valid_extensions or set( ['c', 'cc', 'cpp', 'cxx', 'c++', 'cu'])) def ProcessExtensionsOption(val): global _valid_extensions try: extensions = [ext.strip() for ext in val.split(',')] _valid_extensions = set(extensions) except ValueError: PrintUsage('Extensions should be a comma-separated list of values;' 'for example: extensions=hpp,cpp\n' 'This could not be parsed: "%s"' % (val,)) def GetNonHeaderExtensions(): return GetAllExtensions().difference(GetHeaderExtensions()) def ParseNolintSuppressions(filename, raw_line, linenum, error): """Updates the global list of line error-suppressions. Parses any NOLINT comments on the current line, updating the global error_suppressions store. Reports an error if the NOLINT comment was malformed. Args: filename: str, the name of the input file. raw_line: str, the line of input text, with comments. linenum: int, the number of the current line. error: function, an error handler. """ matched = Search(r'\bNOLINT(NEXTLINE)?\b(\([^)]+\))?', raw_line) if matched: if matched.group(1): suppressed_line = linenum + 1 else: suppressed_line = linenum category = matched.group(2) if category in (None, '(*)'): # => "suppress all" _error_suppressions.setdefault(None, set()).add(suppressed_line) else: if category.startswith('(') and category.endswith(')'): category = category[1:-1] if category in _ERROR_CATEGORIES: _error_suppressions.setdefault(category, set()).add(suppressed_line) elif category not in _LEGACY_ERROR_CATEGORIES: error(filename, linenum, 'readability/nolint', 5, 'Unknown NOLINT error category: %s' % category) def ProcessGlobalSuppresions(lines): """Updates the list of global error suppressions. Parses any lint directives in the file that have global effect. Args: lines: An array of strings, each representing a line of the file, with the last element being empty if the file is terminated with a newline. """ for line in lines: if _SEARCH_C_FILE.search(line): for category in _DEFAULT_C_SUPPRESSED_CATEGORIES: _global_error_suppressions[category] = True if _SEARCH_KERNEL_FILE.search(line): for category in _DEFAULT_KERNEL_SUPPRESSED_CATEGORIES: _global_error_suppressions[category] = True def ResetNolintSuppressions(): """Resets the set of NOLINT suppressions to empty.""" _error_suppressions.clear() _global_error_suppressions.clear() def IsErrorSuppressedByNolint(category, linenum): """Returns true if the specified error category is suppressed on this line. Consults the global error_suppressions map populated by ParseNolintSuppressions/ProcessGlobalSuppresions/ResetNolintSuppressions. Args: category: str, the category of the error. linenum: int, the current line number. Returns: bool, True iff the error should be suppressed due to a NOLINT comment or global suppression. """ return (_global_error_suppressions.get(category, False) or linenum in _error_suppressions.get(category, set()) or linenum in _error_suppressions.get(None, set())) def Match(pattern, s): """Matches the string with the pattern, caching the compiled regexp.""" # The regexp compilation caching is inlined in both Match and Search for # performance reasons; factoring it out into a separate function turns out # to be noticeably expensive. if pattern not in _regexp_compile_cache: _regexp_compile_cache[pattern] = sre_compile.compile(pattern) return _regexp_compile_cache[pattern].match(s) def ReplaceAll(pattern, rep, s): """Replaces instances of pattern in a string with a replacement. The compiled regex is kept in a cache shared by Match and Search. Args: pattern: regex pattern rep: replacement text s: search string Returns: string with replacements made (or original string if no replacements) """ if pattern not in _regexp_compile_cache: _regexp_compile_cache[pattern] = sre_compile.compile(pattern) return _regexp_compile_cache[pattern].sub(rep, s) def Search(pattern, s): """Searches the string for the pattern, caching the compiled regexp.""" if pattern not in _regexp_compile_cache: _regexp_compile_cache[pattern] = sre_compile.compile(pattern) return _regexp_compile_cache[pattern].search(s) def _IsSourceExtension(s): """File extension (excluding dot) matches a source file extension.""" return s in GetNonHeaderExtensions() class _IncludeState(object): """Tracks line numbers for includes, and the order in which includes appear. include_list contains list of lists of (header, line number) pairs. It's a lists of lists rather than just one flat list to make it easier to update across preprocessor boundaries. Call CheckNextIncludeOrder() once for each header in the file, passing in the type constants defined above. Calls in an illegal order will raise an _IncludeError with an appropriate error message. """ # self._section will move monotonically through this set. If it ever # needs to move backwards, CheckNextIncludeOrder will raise an error. _INITIAL_SECTION = 0 _MY_H_SECTION = 1 _C_SECTION = 2 _CPP_SECTION = 3 _OTHER_SYS_SECTION = 4 _OTHER_H_SECTION = 5 _TYPE_NAMES = { _C_SYS_HEADER: 'C system header', _CPP_SYS_HEADER: 'C++ system header', _OTHER_SYS_HEADER: 'other system header', _LIKELY_MY_HEADER: 'header this file implements', _POSSIBLE_MY_HEADER: 'header this file may implement', _OTHER_HEADER: 'other header', } _SECTION_NAMES = { _INITIAL_SECTION: "... nothing. (This can't be an error.)", _MY_H_SECTION: 'a header this file implements', _C_SECTION: 'C system header', _CPP_SECTION: 'C++ system header', _OTHER_SYS_SECTION: 'other system header', _OTHER_H_SECTION: 'other header', } def __init__(self): self.include_list = [[]] self._section = None self._last_header = None self.ResetSection('') def FindHeader(self, header): """Check if a header has already been included. Args: header: header to check. Returns: Line number of previous occurrence, or -1 if the header has not been seen before. """ for section_list in self.include_list: for f in section_list: if f[0] == header: return f[1] return -1 def ResetSection(self, directive): """Reset section checking for preprocessor directive. Args: directive: preprocessor directive (e.g. "if", "else"). """ # The name of the current section. self._section = self._INITIAL_SECTION # The path of last found header. self._last_header = '' # Update list of includes. Note that we never pop from the # include list. if directive in ('if', 'ifdef', 'ifndef'): self.include_list.append([]) elif directive in ('else', 'elif'): self.include_list[-1] = [] def SetLastHeader(self, header_path): self._last_header = header_path def CanonicalizeAlphabeticalOrder(self, header_path): """Returns a path canonicalized for alphabetical comparison. - replaces "-" with "_" so they both cmp the same. - removes '-inl' since we don't require them to be after the main header. - lowercase everything, just in case. Args: header_path: Path to be canonicalized. Returns: Canonicalized path. """ return header_path.replace('-inl.h', '.h').replace('-', '_').lower() def IsInAlphabeticalOrder(self, clean_lines, linenum, header_path): """Check if a header is in alphabetical order with the previous header. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. header_path: Canonicalized header to be checked. Returns: Returns true if the header is in alphabetical order. """ # If previous section is different from current section, _last_header will # be reset to empty string, so it's always less than current header. # # If previous line was a blank line, assume that the headers are # intentionally sorted the way they are. if (self._last_header > header_path and Match(r'^\s*#\s*include\b', clean_lines.elided[linenum - 1])): return False return True def CheckNextIncludeOrder(self, header_type): """Returns a non-empty error message if the next header is out of order. This function also updates the internal state to be ready to check the next include. Args: header_type: One of the _XXX_HEADER constants defined above. Returns: The empty string if the header is in the right order, or an error message describing what's wrong. """ error_message = ('Found %s after %s' % (self._TYPE_NAMES[header_type], self._SECTION_NAMES[self._section])) last_section = self._section if header_type == _C_SYS_HEADER: if self._section <= self._C_SECTION: self._section = self._C_SECTION else: self._last_header = '' return error_message elif header_type == _CPP_SYS_HEADER: if self._section <= self._CPP_SECTION: self._section = self._CPP_SECTION else: self._last_header = '' return error_message elif header_type == _OTHER_SYS_HEADER: if self._section <= self._OTHER_SYS_SECTION: self._section = self._OTHER_SYS_SECTION else: self._last_header = '' return error_message elif header_type == _LIKELY_MY_HEADER: if self._section <= self._MY_H_SECTION: self._section = self._MY_H_SECTION else: self._section = self._OTHER_H_SECTION elif header_type == _POSSIBLE_MY_HEADER: if self._section <= self._MY_H_SECTION: self._section = self._MY_H_SECTION else: # This will always be the fallback because we're not sure # enough that the header is associated with this file. self._section = self._OTHER_H_SECTION else: assert header_type == _OTHER_HEADER self._section = self._OTHER_H_SECTION if last_section != self._section: self._last_header = '' return '' class _CppLintState(object): """Maintains module-wide state..""" def __init__(self): self.verbose_level = 1 # global setting. self.error_count = 0 # global count of reported errors # filters to apply when emitting error messages self.filters = _DEFAULT_FILTERS[:] # backup of filter list. Used to restore the state after each file. self._filters_backup = self.filters[:] self.counting = 'total' # In what way are we counting errors? self.errors_by_category = {} # string to int dict storing error counts self.quiet = False # Suppress non-error messagess? # output format: # "emacs" - format that emacs can parse (default) # "eclipse" - format that eclipse can parse # "vs7" - format that Microsoft Visual Studio 7 can parse # "junit" - format that Jenkins, Bamboo, etc can parse # "sed" - returns a gnu sed command to fix the problem # "gsed" - like sed, but names the command gsed, e.g. for macOS homebrew users self.output_format = 'emacs' # For JUnit output, save errors and failures until the end so that they # can be written into the XML self._junit_errors = [] self._junit_failures = [] def SetOutputFormat(self, output_format): """Sets the output format for errors.""" self.output_format = output_format def SetQuiet(self, quiet): """Sets the module's quiet settings, and returns the previous setting.""" last_quiet = self.quiet self.quiet = quiet return last_quiet def SetVerboseLevel(self, level): """Sets the module's verbosity, and returns the previous setting.""" last_verbose_level = self.verbose_level self.verbose_level = level return last_verbose_level def SetCountingStyle(self, counting_style): """Sets the module's counting options.""" self.counting = counting_style def SetFilters(self, filters): """Sets the error-message filters. These filters are applied when deciding whether to emit a given error message. Args: filters: A string of comma-separated filters (eg "+whitespace/indent"). Each filter should start with + or -; else we die. Raises: ValueError: The comma-separated filters did not all start with '+' or '-'. E.g. "-,+whitespace,-whitespace/indent,whitespace/badfilter" """ # Default filters always have less priority than the flag ones. self.filters = _DEFAULT_FILTERS[:] self.AddFilters(filters) def AddFilters(self, filters): """ Adds more filters to the existing list of error-message filters. """ for filt in filters.split(','): clean_filt = filt.strip() if clean_filt: self.filters.append(clean_filt) for filt in self.filters: if not (filt.startswith('+') or filt.startswith('-')): raise ValueError('Every filter in --filters must start with + or -' ' (%s does not)' % filt) def BackupFilters(self): """ Saves the current filter list to backup storage.""" self._filters_backup = self.filters[:] def RestoreFilters(self): """ Restores filters previously backed up.""" self.filters = self._filters_backup[:] def ResetErrorCounts(self): """Sets the module's error statistic back to zero.""" self.error_count = 0 self.errors_by_category = {} def IncrementErrorCount(self, category): """Bumps the module's error statistic.""" self.error_count += 1 if self.counting in ('toplevel', 'detailed'): if self.counting != 'detailed': category = category.split('/')[0] if category not in self.errors_by_category: self.errors_by_category[category] = 0 self.errors_by_category[category] += 1 def PrintErrorCounts(self): """Print a summary of errors by category, and the total.""" for category, count in sorted(iteritems(self.errors_by_category)): self.PrintInfo('Category \'%s\' errors found: %d\n' % (category, count)) if self.error_count > 0: self.PrintInfo('Total errors found: %d\n' % self.error_count) def PrintInfo(self, message): # _quiet does not represent --quiet flag. # Hide infos from stdout to keep stdout pure for machine consumption if not _quiet and self.output_format not in _MACHINE_OUTPUTS: sys.stdout.write(message) def PrintError(self, message): if self.output_format == 'junit': self._junit_errors.append(message) else: sys.stderr.write(message) def AddJUnitFailure(self, filename, linenum, message, category, confidence): self._junit_failures.append((filename, linenum, message, category, confidence)) def FormatJUnitXML(self): num_errors = len(self._junit_errors) num_failures = len(self._junit_failures) testsuite = xml.etree.ElementTree.Element('testsuite') testsuite.attrib['errors'] = str(num_errors) testsuite.attrib['failures'] = str(num_failures) testsuite.attrib['name'] = 'cpplint' if num_errors == 0 and num_failures == 0: testsuite.attrib['tests'] = str(1) xml.etree.ElementTree.SubElement(testsuite, 'testcase', name='passed') else: testsuite.attrib['tests'] = str(num_errors + num_failures) if num_errors > 0: testcase = xml.etree.ElementTree.SubElement(testsuite, 'testcase') testcase.attrib['name'] = 'errors' error = xml.etree.ElementTree.SubElement(testcase, 'error') error.text = '\n'.join(self._junit_errors) if num_failures > 0: # Group failures by file failed_file_order = [] failures_by_file = {} for failure in self._junit_failures: failed_file = failure[0] if failed_file not in failed_file_order: failed_file_order.append(failed_file) failures_by_file[failed_file] = [] failures_by_file[failed_file].append(failure) # Create a testcase for each file for failed_file in failed_file_order: failures = failures_by_file[failed_file] testcase = xml.etree.ElementTree.SubElement(testsuite, 'testcase') testcase.attrib['name'] = failed_file failure = xml.etree.ElementTree.SubElement(testcase, 'failure') template = '{0}: {1} [{2}] [{3}]' texts = [template.format(f[1], f[2], f[3], f[4]) for f in failures] failure.text = '\n'.join(texts) xml_decl = '\n' return xml_decl + xml.etree.ElementTree.tostring(testsuite, 'utf-8').decode('utf-8') _cpplint_state = _CppLintState() def _OutputFormat(): """Gets the module's output format.""" return _cpplint_state.output_format def _SetOutputFormat(output_format): """Sets the module's output format.""" _cpplint_state.SetOutputFormat(output_format) def _Quiet(): """Return's the module's quiet setting.""" return _cpplint_state.quiet def _SetQuiet(quiet): """Set the module's quiet status, and return previous setting.""" return _cpplint_state.SetQuiet(quiet) def _VerboseLevel(): """Returns the module's verbosity setting.""" return _cpplint_state.verbose_level def _SetVerboseLevel(level): """Sets the module's verbosity, and returns the previous setting.""" return _cpplint_state.SetVerboseLevel(level) def _SetCountingStyle(level): """Sets the module's counting options.""" _cpplint_state.SetCountingStyle(level) def _Filters(): """Returns the module's list of output filters, as a list.""" return _cpplint_state.filters def _SetFilters(filters): """Sets the module's error-message filters. These filters are applied when deciding whether to emit a given error message. Args: filters: A string of comma-separated filters (eg "whitespace/indent"). Each filter should start with + or -; else we die. """ _cpplint_state.SetFilters(filters) def _AddFilters(filters): """Adds more filter overrides. Unlike _SetFilters, this function does not reset the current list of filters available. Args: filters: A string of comma-separated filters (eg "whitespace/indent"). Each filter should start with + or -; else we die. """ _cpplint_state.AddFilters(filters) def _BackupFilters(): """ Saves the current filter list to backup storage.""" _cpplint_state.BackupFilters() def _RestoreFilters(): """ Restores filters previously backed up.""" _cpplint_state.RestoreFilters() class _FunctionState(object): """Tracks current function name and the number of lines in its body.""" _NORMAL_TRIGGER = 250 # for --v=0, 500 for --v=1, etc. _TEST_TRIGGER = 400 # about 50% more than _NORMAL_TRIGGER. def __init__(self): self.in_a_function = False self.lines_in_function = 0 self.current_function = '' def Begin(self, function_name): """Start analyzing function body. Args: function_name: The name of the function being tracked. """ self.in_a_function = True self.lines_in_function = 0 self.current_function = function_name def Count(self): """Count line in current function body.""" if self.in_a_function: self.lines_in_function += 1 def Check(self, error, filename, linenum): """Report if too many lines in function body. Args: error: The function to call with any errors found. filename: The name of the current file. linenum: The number of the line to check. """ if not self.in_a_function: return if Match(r'T(EST|est)', self.current_function): base_trigger = self._TEST_TRIGGER else: base_trigger = self._NORMAL_TRIGGER trigger = base_trigger * 2**_VerboseLevel() if self.lines_in_function > trigger: error_level = int(math.log(self.lines_in_function / base_trigger, 2)) # 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ... if error_level > 5: error_level = 5 error(filename, linenum, 'readability/fn_size', error_level, 'Small and focused functions are preferred:' ' %s has %d non-comment lines' ' (error triggered by exceeding %d lines).' % ( self.current_function, self.lines_in_function, trigger)) def End(self): """Stop analyzing function body.""" self.in_a_function = False class _IncludeError(Exception): """Indicates a problem with the include order in a file.""" pass class FileInfo(object): """Provides utility functions for filenames. FileInfo provides easy access to the components of a file's path relative to the project root. """ def __init__(self, filename): self._filename = filename def FullName(self): """Make Windows paths like Unix.""" return os.path.abspath(self._filename).replace('\\', '/') def RepositoryName(self): r"""FullName after removing the local path to the repository. If we have a real absolute path name here we can try to do something smart: detecting the root of the checkout and truncating /path/to/checkout from the name so that we get header guards that don't include things like "C:\\Documents and Settings\\..." or "/home/username/..." in them and thus people on different computers who have checked the source out to different locations won't see bogus errors. """ fullname = self.FullName() if os.path.exists(fullname): project_dir = os.path.dirname(fullname) # If the user specified a repository path, it exists, and the file is # contained in it, use the specified repository path if _repository: repo = FileInfo(_repository).FullName() root_dir = project_dir while os.path.exists(root_dir): # allow case insensitive compare on Windows if os.path.normcase(root_dir) == os.path.normcase(repo): return os.path.relpath(fullname, root_dir).replace('\\', '/') one_up_dir = os.path.dirname(root_dir) if one_up_dir == root_dir: break root_dir = one_up_dir if os.path.exists(os.path.join(project_dir, ".svn")): # If there's a .svn file in the current directory, we recursively look # up the directory tree for the top of the SVN checkout root_dir = project_dir one_up_dir = os.path.dirname(root_dir) while os.path.exists(os.path.join(one_up_dir, ".svn")): root_dir = os.path.dirname(root_dir) one_up_dir = os.path.dirname(one_up_dir) prefix = os.path.commonprefix([root_dir, project_dir]) return fullname[len(prefix) + 1:] # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by # searching up from the current path. root_dir = current_dir = os.path.dirname(fullname) while current_dir != os.path.dirname(current_dir): if (os.path.exists(os.path.join(current_dir, ".git")) or os.path.exists(os.path.join(current_dir, ".hg")) or os.path.exists(os.path.join(current_dir, ".svn"))): root_dir = current_dir break current_dir = os.path.dirname(current_dir) if (os.path.exists(os.path.join(root_dir, ".git")) or os.path.exists(os.path.join(root_dir, ".hg")) or os.path.exists(os.path.join(root_dir, ".svn"))): prefix = os.path.commonprefix([root_dir, project_dir]) return fullname[len(prefix) + 1:] # Don't know what to do; header guard warnings may be wrong... return fullname def Split(self): """Splits the file into the directory, basename, and extension. For 'chrome/browser/browser.cc', Split() would return ('chrome/browser', 'browser', '.cc') Returns: A tuple of (directory, basename, extension). """ googlename = self.RepositoryName() project, rest = os.path.split(googlename) return (project,) + os.path.splitext(rest) def BaseName(self): """File base name - text after the final slash, before the final period.""" return self.Split()[1] def Extension(self): """File extension - text following the final period, includes that period.""" return self.Split()[2] def NoExtension(self): """File has no source file extension.""" return '/'.join(self.Split()[0:2]) def IsSource(self): """File has a source file extension.""" return _IsSourceExtension(self.Extension()[1:]) def _ShouldPrintError(category, confidence, linenum): """If confidence >= verbose, category passes filter and is not suppressed.""" # There are three ways we might decide not to print an error message: # a "NOLINT(category)" comment appears in the source, # the verbosity level isn't high enough, or the filters filter it out. if IsErrorSuppressedByNolint(category, linenum): return False if confidence < _cpplint_state.verbose_level: return False is_filtered = False for one_filter in _Filters(): if one_filter.startswith('-'): if category.startswith(one_filter[1:]): is_filtered = True elif one_filter.startswith('+'): if category.startswith(one_filter[1:]): is_filtered = False else: assert False # should have been checked for in SetFilter. if is_filtered: return False return True def Error(filename, linenum, category, confidence, message): """Logs the fact we've found a lint error. We log where the error was found, and also our confidence in the error, that is, how certain we are this is a legitimate style regression, and not a misidentification or a use that's sometimes justified. False positives can be suppressed by the use of "cpplint(category)" comments on the offending line. These are parsed into _error_suppressions. Args: filename: The name of the file containing the error. linenum: The number of the line containing the error. category: A string used to describe the "category" this bug falls under: "whitespace", say, or "runtime". Categories may have a hierarchy separated by slashes: "whitespace/indent". confidence: A number from 1-5 representing a confidence score for the error, with 5 meaning that we are certain of the problem, and 1 meaning that it could be a legitimate construct. message: The error message. """ if _ShouldPrintError(category, confidence, linenum): _cpplint_state.IncrementErrorCount(category) if _cpplint_state.output_format == 'vs7': _cpplint_state.PrintError('%s(%s): error cpplint: [%s] %s [%d]\n' % ( filename, linenum, category, message, confidence)) elif _cpplint_state.output_format == 'eclipse': sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( filename, linenum, message, category, confidence)) elif _cpplint_state.output_format == 'junit': _cpplint_state.AddJUnitFailure(filename, linenum, message, category, confidence) elif _cpplint_state.output_format in ['sed', 'gsed']: if message in _SED_FIXUPS: sys.stdout.write(_cpplint_state.output_format + " -i '%s%s' %s # %s [%s] [%d]\n" % ( linenum, _SED_FIXUPS[message], filename, message, category, confidence)) else: sys.stderr.write('# %s:%s: "%s" [%s] [%d]\n' % ( filename, linenum, message, category, confidence)) else: final_message = '%s:%s: %s [%s] [%d]\n' % ( filename, linenum, message, category, confidence) sys.stderr.write(final_message) # Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard. _RE_PATTERN_CLEANSE_LINE_ESCAPES = re.compile( r'\\([abfnrtv?"\\\']|\d+|x[0-9a-fA-F]+)') # Match a single C style comment on the same line. _RE_PATTERN_C_COMMENTS = r'/\*(?:[^*]|\*(?!/))*\*/' # Matches multi-line C style comments. # This RE is a little bit more complicated than one might expect, because we # have to take care of space removals tools so we can handle comments inside # statements better. # The current rule is: We only clear spaces from both sides when we're at the # end of the line. Otherwise, we try to remove spaces from the right side, # if this doesn't work we try on left side but only if there's a non-character # on the right. _RE_PATTERN_CLEANSE_LINE_C_COMMENTS = re.compile( r'(\s*' + _RE_PATTERN_C_COMMENTS + r'\s*$|' + _RE_PATTERN_C_COMMENTS + r'\s+|' + r'\s+' + _RE_PATTERN_C_COMMENTS + r'(?=\W)|' + _RE_PATTERN_C_COMMENTS + r')') def IsCppString(line): """Does line terminate so, that the next symbol is in string constant. This function does not consider single-line nor multi-line comments. Args: line: is a partial line of code starting from the 0..n. Returns: True, if next character appended to 'line' is inside a string constant. """ line = line.replace(r'\\', 'XX') # after this, \\" does not match to \" return ((line.count('"') - line.count(r'\"') - line.count("'\"'")) & 1) == 1 def CleanseRawStrings(raw_lines): """Removes C++11 raw strings from lines. Before: static const char kData[] = R"( multi-line string )"; After: static const char kData[] = "" (replaced by blank line) ""; Args: raw_lines: list of raw lines. Returns: list of lines with C++11 raw strings replaced by empty strings. """ delimiter = None lines_without_raw_strings = [] for line in raw_lines: if delimiter: # Inside a raw string, look for the end end = line.find(delimiter) if end >= 0: # Found the end of the string, match leading space for this # line and resume copying the original lines, and also insert # a "" on the last line. leading_space = Match(r'^(\s*)\S', line) line = leading_space.group(1) + '""' + line[end + len(delimiter):] delimiter = None else: # Haven't found the end yet, append a blank line. line = '""' # Look for beginning of a raw string, and replace them with # empty strings. This is done in a loop to handle multiple raw # strings on the same line. while delimiter is None: # Look for beginning of a raw string. # See 2.14.15 [lex.string] for syntax. # # Once we have matched a raw string, we check the prefix of the # line to make sure that the line is not part of a single line # comment. It's done this way because we remove raw strings # before removing comments as opposed to removing comments # before removing raw strings. This is because there are some # cpplint checks that requires the comments to be preserved, but # we don't want to check comments that are inside raw strings. matched = Match(r'^(.*?)\b(?:R|u8R|uR|UR|LR)"([^\s\\()]*)\((.*)$', line) if (matched and not Match(r'^([^\'"]|\'(\\.|[^\'])*\'|"(\\.|[^"])*")*//', matched.group(1))): delimiter = ')' + matched.group(2) + '"' end = matched.group(3).find(delimiter) if end >= 0: # Raw string ended on same line line = (matched.group(1) + '""' + matched.group(3)[end + len(delimiter):]) delimiter = None else: # Start of a multi-line raw string line = matched.group(1) + '""' else: break lines_without_raw_strings.append(line) # TODO(unknown): if delimiter is not None here, we might want to # emit a warning for unterminated string. return lines_without_raw_strings def FindNextMultiLineCommentStart(lines, lineix): """Find the beginning marker for a multiline comment.""" while lineix < len(lines): if lines[lineix].strip().startswith('/*'): # Only return this marker if the comment goes beyond this line if lines[lineix].strip().find('*/', 2) < 0: return lineix lineix += 1 return len(lines) def FindNextMultiLineCommentEnd(lines, lineix): """We are inside a comment, find the end marker.""" while lineix < len(lines): if lines[lineix].strip().endswith('*/'): return lineix lineix += 1 return len(lines) def RemoveMultiLineCommentsFromRange(lines, begin, end): """Clears a range of lines for multi-line comments.""" # Having // comments makes the lines non-empty, so we will not get # unnecessary blank line warnings later in the code. for i in range(begin, end): lines[i] = '/**/' def RemoveMultiLineComments(filename, lines, error): """Removes multiline (c-style) comments from lines.""" lineix = 0 while lineix < len(lines): lineix_begin = FindNextMultiLineCommentStart(lines, lineix) if lineix_begin >= len(lines): return lineix_end = FindNextMultiLineCommentEnd(lines, lineix_begin) if lineix_end >= len(lines): error(filename, lineix_begin + 1, 'readability/multiline_comment', 5, 'Could not find end of multi-line comment') return RemoveMultiLineCommentsFromRange(lines, lineix_begin, lineix_end + 1) lineix = lineix_end + 1 def CleanseComments(line): """Removes //-comments and single-line C-style /* */ comments. Args: line: A line of C++ source. Returns: The line with single-line comments removed. """ commentpos = line.find('//') if commentpos != -1 and not IsCppString(line[:commentpos]): line = line[:commentpos].rstrip() # get rid of /* ... */ return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) class CleansedLines(object): """Holds 4 copies of all lines with different preprocessing applied to them. 1) elided member contains lines without strings and comments. 2) lines member contains lines without comments. 3) raw_lines member contains all the lines without processing. 4) lines_without_raw_strings member is same as raw_lines, but with C++11 raw strings removed. All these members are of , and of the same length. """ def __init__(self, lines): self.elided = [] self.lines = [] self.raw_lines = lines self.num_lines = len(lines) self.lines_without_raw_strings = CleanseRawStrings(lines) for linenum in range(len(self.lines_without_raw_strings)): self.lines.append(CleanseComments( self.lines_without_raw_strings[linenum])) elided = self._CollapseStrings(self.lines_without_raw_strings[linenum]) self.elided.append(CleanseComments(elided)) def NumLines(self): """Returns the number of lines represented.""" return self.num_lines @staticmethod def _CollapseStrings(elided): """Collapses strings and chars on a line to simple "" or '' blocks. We nix strings first so we're not fooled by text like '"http://"' Args: elided: The line being processed. Returns: The line with collapsed strings. """ if _RE_PATTERN_INCLUDE.match(elided): return elided # Remove escaped characters first to make quote/single quote collapsing # basic. Things that look like escaped characters shouldn't occur # outside of strings and chars. elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub('', elided) # Replace quoted strings and digit separators. Both single quotes # and double quotes are processed in the same loop, otherwise # nested quotes wouldn't work. collapsed = '' while True: # Find the first quote character match = Match(r'^([^\'"]*)([\'"])(.*)$', elided) if not match: collapsed += elided break head, quote, tail = match.groups() if quote == '"': # Collapse double quoted strings second_quote = tail.find('"') if second_quote >= 0: collapsed += head + '""' elided = tail[second_quote + 1:] else: # Unmatched double quote, don't bother processing the rest # of the line since this is probably a multiline string. collapsed += elided break else: # Found single quote, check nearby text to eliminate digit separators. # # There is no special handling for floating point here, because # the integer/fractional/exponent parts would all be parsed # correctly as long as there are digits on both sides of the # separator. So we are fine as long as we don't see something # like "0.'3" (gcc 4.9.0 will not allow this literal). if Search(r'\b(?:0[bBxX]?|[1-9])[0-9a-fA-F]*$', head): match_literal = Match(r'^((?:\'?[0-9a-zA-Z_])*)(.*)$', "'" + tail) collapsed += head + match_literal.group(1).replace("'", '') elided = match_literal.group(2) else: second_quote = tail.find('\'') if second_quote >= 0: collapsed += head + "''" elided = tail[second_quote + 1:] else: # Unmatched single quote collapsed += elided break return collapsed def FindEndOfExpressionInLine(line, startpos, stack): """Find the position just after the end of current parenthesized expression. Args: line: a CleansedLines line. startpos: start searching at this position. stack: nesting stack at startpos. Returns: On finding matching end: (index just after matching end, None) On finding an unclosed expression: (-1, None) Otherwise: (-1, new stack at end of this line) """ for i in xrange(startpos, len(line)): char = line[i] if char in '([{': # Found start of parenthesized expression, push to expression stack stack.append(char) elif char == '<': # Found potential start of template argument list if i > 0 and line[i - 1] == '<': # Left shift operator if stack and stack[-1] == '<': stack.pop() if not stack: return (-1, None) elif i > 0 and Search(r'\boperator\s*$', line[0:i]): # operator<, don't add to stack continue else: # Tentative start of template argument list stack.append('<') elif char in ')]}': # Found end of parenthesized expression. # # If we are currently expecting a matching '>', the pending '<' # must have been an operator. Remove them from expression stack. while stack and stack[-1] == '<': stack.pop() if not stack: return (-1, None) if ((stack[-1] == '(' and char == ')') or (stack[-1] == '[' and char == ']') or (stack[-1] == '{' and char == '}')): stack.pop() if not stack: return (i + 1, None) else: # Mismatched parentheses return (-1, None) elif char == '>': # Found potential end of template argument list. # Ignore "->" and operator functions if (i > 0 and (line[i - 1] == '-' or Search(r'\boperator\s*$', line[0:i - 1]))): continue # Pop the stack if there is a matching '<'. Otherwise, ignore # this '>' since it must be an operator. if stack: if stack[-1] == '<': stack.pop() if not stack: return (i + 1, None) elif char == ';': # Found something that look like end of statements. If we are currently # expecting a '>', the matching '<' must have been an operator, since # template argument list should not contain statements. while stack and stack[-1] == '<': stack.pop() if not stack: return (-1, None) # Did not find end of expression or unbalanced parentheses on this line return (-1, stack) def CloseExpression(clean_lines, linenum, pos): """If input points to ( or { or [ or <, finds the position that closes it. If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the linenum/pos that correspond to the closing of the expression. TODO(unknown): cpplint spends a fair bit of time matching parentheses. Ideally we would want to index all opening and closing parentheses once and have CloseExpression be just a simple lookup, but due to preprocessor tricks, this is not so easy. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. pos: A position on the line. Returns: A tuple (line, linenum, pos) pointer *past* the closing brace, or (line, len(lines), -1) if we never find a close. Note we ignore strings and comments when matching; and the line we return is the 'cleansed' line at linenum. """ line = clean_lines.elided[linenum] if (line[pos] not in '({[<') or Match(r'<[<=]', line[pos:]): return (line, clean_lines.NumLines(), -1) # Check first line (end_pos, stack) = FindEndOfExpressionInLine(line, pos, []) if end_pos > -1: return (line, linenum, end_pos) # Continue scanning forward while stack and linenum < clean_lines.NumLines() - 1: linenum += 1 line = clean_lines.elided[linenum] (end_pos, stack) = FindEndOfExpressionInLine(line, 0, stack) if end_pos > -1: return (line, linenum, end_pos) # Did not find end of expression before end of file, give up return (line, clean_lines.NumLines(), -1) def FindStartOfExpressionInLine(line, endpos, stack): """Find position at the matching start of current expression. This is almost the reverse of FindEndOfExpressionInLine, but note that the input position and returned position differs by 1. Args: line: a CleansedLines line. endpos: start searching at this position. stack: nesting stack at endpos. Returns: On finding matching start: (index at matching start, None) On finding an unclosed expression: (-1, None) Otherwise: (-1, new stack at beginning of this line) """ i = endpos while i >= 0: char = line[i] if char in ')]}': # Found end of expression, push to expression stack stack.append(char) elif char == '>': # Found potential end of template argument list. # # Ignore it if it's a "->" or ">=" or "operator>" if (i > 0 and (line[i - 1] == '-' or Match(r'\s>=\s', line[i - 1:]) or Search(r'\boperator\s*$', line[0:i]))): i -= 1 else: stack.append('>') elif char == '<': # Found potential start of template argument list if i > 0 and line[i - 1] == '<': # Left shift operator i -= 1 else: # If there is a matching '>', we can pop the expression stack. # Otherwise, ignore this '<' since it must be an operator. if stack and stack[-1] == '>': stack.pop() if not stack: return (i, None) elif char in '([{': # Found start of expression. # # If there are any unmatched '>' on the stack, they must be # operators. Remove those. while stack and stack[-1] == '>': stack.pop() if not stack: return (-1, None) if ((char == '(' and stack[-1] == ')') or (char == '[' and stack[-1] == ']') or (char == '{' and stack[-1] == '}')): stack.pop() if not stack: return (i, None) else: # Mismatched parentheses return (-1, None) elif char == ';': # Found something that look like end of statements. If we are currently # expecting a '<', the matching '>' must have been an operator, since # template argument list should not contain statements. while stack and stack[-1] == '>': stack.pop() if not stack: return (-1, None) i -= 1 return (-1, stack) def ReverseCloseExpression(clean_lines, linenum, pos): """If input points to ) or } or ] or >, finds the position that opens it. If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the linenum/pos that correspond to the opening of the expression. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. pos: A position on the line. Returns: A tuple (line, linenum, pos) pointer *at* the opening brace, or (line, 0, -1) if we never find the matching opening brace. Note we ignore strings and comments when matching; and the line we return is the 'cleansed' line at linenum. """ line = clean_lines.elided[linenum] if line[pos] not in ')}]>': return (line, 0, -1) # Check last line (start_pos, stack) = FindStartOfExpressionInLine(line, pos, []) if start_pos > -1: return (line, linenum, start_pos) # Continue scanning backward while stack and linenum > 0: linenum -= 1 line = clean_lines.elided[linenum] (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack) if start_pos > -1: return (line, linenum, start_pos) # Did not find start of expression before beginning of file, give up return (line, 0, -1) def CheckForCopyright(filename, lines, error): """Logs an error if no Copyright message appears at the top of the file.""" # We'll say it should occur by line 10. Don't forget there's a # placeholder line at the front. for line in xrange(1, min(len(lines), 11)): if re.search(r'Copyright', lines[line], re.I): break else: # means no copyright line was found error(filename, 0, 'legal/copyright', 5, 'No copyright message found. ' 'You should have a line: "Copyright [year] "') def GetIndentLevel(line): """Return the number of leading spaces in line. Args: line: A string to check. Returns: An integer count of leading spaces, possibly zero. """ indent = Match(r'^( *)\S', line) if indent: return len(indent.group(1)) else: return 0 def PathSplitToList(path): """Returns the path split into a list by the separator. Args: path: An absolute or relative path (e.g. '/a/b/c/' or '../a') Returns: A list of path components (e.g. ['a', 'b', 'c]). """ lst = [] while True: (head, tail) = os.path.split(path) if head == path: # absolute paths end lst.append(head) break if tail == path: # relative paths end lst.append(tail) break path = head lst.append(tail) lst.reverse() return lst def GetHeaderGuardCPPVariable(filename): """Returns the CPP variable that should be used as a header guard. Args: filename: The name of a C++ header file. Returns: The CPP variable that should be used as a header guard in the named file. """ # Restores original filename in case that cpplint is invoked from Emacs's # flymake. filename = re.sub(r'_flymake\.h$', '.h', filename) filename = re.sub(r'/\.flymake/([^/]*)$', r'/\1', filename) # Replace 'c++' with 'cpp'. filename = filename.replace('C++', 'cpp').replace('c++', 'cpp') fileinfo = FileInfo(filename) file_path_from_root = fileinfo.RepositoryName() def FixupPathFromRoot(): if _root_debug: sys.stderr.write("\n_root fixup, _root = '%s', repository name = '%s'\n" % (_root, fileinfo.RepositoryName())) # Process the file path with the --root flag if it was set. if not _root: if _root_debug: sys.stderr.write("_root unspecified\n") return file_path_from_root def StripListPrefix(lst, prefix): # f(['x', 'y'], ['w, z']) -> None (not a valid prefix) if lst[:len(prefix)] != prefix: return None # f(['a, 'b', 'c', 'd'], ['a', 'b']) -> ['c', 'd'] return lst[(len(prefix)):] # root behavior: # --root=subdir , lstrips subdir from the header guard maybe_path = StripListPrefix(PathSplitToList(file_path_from_root), PathSplitToList(_root)) if _root_debug: sys.stderr.write(("_root lstrip (maybe_path=%s, file_path_from_root=%s," + " _root=%s)\n") % (maybe_path, file_path_from_root, _root)) if maybe_path: return os.path.join(*maybe_path) # --root=.. , will prepend the outer directory to the header guard full_path = fileinfo.FullName() # adapt slashes for windows root_abspath = os.path.abspath(_root).replace('\\', '/') maybe_path = StripListPrefix(PathSplitToList(full_path), PathSplitToList(root_abspath)) if _root_debug: sys.stderr.write(("_root prepend (maybe_path=%s, full_path=%s, " + "root_abspath=%s)\n") % (maybe_path, full_path, root_abspath)) if maybe_path: return os.path.join(*maybe_path) if _root_debug: sys.stderr.write("_root ignore, returning %s\n" % (file_path_from_root)) # --root=FAKE_DIR is ignored return file_path_from_root file_path_from_root = FixupPathFromRoot() return re.sub(r'[^a-zA-Z0-9]', '_', file_path_from_root).upper() + '_' def CheckForHeaderGuard(filename, clean_lines, error): """Checks that the file contains a header guard. Logs an error if no #ifndef header guard is present. For other headers, checks that the full pathname is used. Args: filename: The name of the C++ header file. clean_lines: A CleansedLines instance containing the file. error: The function to call with any errors found. """ # Don't check for header guards if there are error suppression # comments somewhere in this file. # # Because this is silencing a warning for a nonexistent line, we # only support the very specific NOLINT(build/header_guard) syntax, # and not the general NOLINT or NOLINT(*) syntax. raw_lines = clean_lines.lines_without_raw_strings for i in raw_lines: if Search(r'//\s*NOLINT\(build/header_guard\)', i): return # Allow pragma once instead of header guards for i in raw_lines: if Search(r'^\s*#pragma\s+once', i): return cppvar = GetHeaderGuardCPPVariable(filename) ifndef = '' ifndef_linenum = 0 define = '' endif = '' endif_linenum = 0 for linenum, line in enumerate(raw_lines): linesplit = line.split() if len(linesplit) >= 2: # find the first occurrence of #ifndef and #define, save arg if not ifndef and linesplit[0] == '#ifndef': # set ifndef to the header guard presented on the #ifndef line. ifndef = linesplit[1] ifndef_linenum = linenum if not define and linesplit[0] == '#define': define = linesplit[1] # find the last occurrence of #endif, save entire line if line.startswith('#endif'): endif = line endif_linenum = linenum if not ifndef or not define or ifndef != define: error(filename, 0, 'build/header_guard', 5, 'No #ifndef header guard found, suggested CPP variable is: %s' % cppvar) return # The guard should be PATH_FILE_H_, but we also allow PATH_FILE_H__ # for backward compatibility. if ifndef != cppvar: error_level = 0 if ifndef != cppvar + '_': error_level = 5 ParseNolintSuppressions(filename, raw_lines[ifndef_linenum], ifndef_linenum, error) error(filename, ifndef_linenum, 'build/header_guard', error_level, '#ifndef header guard has wrong style, please use: %s' % cppvar) # Check for "//" comments on endif line. ParseNolintSuppressions(filename, raw_lines[endif_linenum], endif_linenum, error) match = Match(r'#endif\s*//\s*' + cppvar + r'(_)?\b', endif) if match: if match.group(1) == '_': # Issue low severity warning for deprecated double trailing underscore error(filename, endif_linenum, 'build/header_guard', 0, '#endif line should be "#endif // %s"' % cppvar) return # Didn't find the corresponding "//" comment. If this file does not # contain any "//" comments at all, it could be that the compiler # only wants "/**/" comments, look for those instead. no_single_line_comments = True for i in xrange(1, len(raw_lines) - 1): line = raw_lines[i] if Match(r'^(?:(?:\'(?:\.|[^\'])*\')|(?:"(?:\.|[^"])*")|[^\'"])*//', line): no_single_line_comments = False break if no_single_line_comments: match = Match(r'#endif\s*/\*\s*' + cppvar + r'(_)?\s*\*/', endif) if match: if match.group(1) == '_': # Low severity warning for double trailing underscore error(filename, endif_linenum, 'build/header_guard', 0, '#endif line should be "#endif /* %s */"' % cppvar) return # Didn't find anything error(filename, endif_linenum, 'build/header_guard', 5, '#endif line should be "#endif // %s"' % cppvar) def CheckHeaderFileIncluded(filename, include_state, error): """Logs an error if a source file does not include its header.""" # Do not check test files fileinfo = FileInfo(filename) if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()): return for ext in GetHeaderExtensions(): basefilename = filename[0:len(filename) - len(fileinfo.Extension())] headerfile = basefilename + '.' + ext if not os.path.exists(headerfile): continue headername = FileInfo(headerfile).RepositoryName() first_include = None include_uses_unix_dir_aliases = False for section_list in include_state.include_list: for f in section_list: include_text = f[0] if "./" in include_text: include_uses_unix_dir_aliases = True if headername in include_text or include_text in headername: return if not first_include: first_include = f[1] message = '%s should include its header file %s' % (fileinfo.RepositoryName(), headername) if include_uses_unix_dir_aliases: message += ". Relative paths like . and .. are not allowed." error(filename, first_include, 'build/include', 5, message) def CheckForBadCharacters(filename, lines, error): """Logs an error for each line containing bad characters. Two kinds of bad characters: 1. Unicode replacement characters: These indicate that either the file contained invalid UTF-8 (likely) or Unicode replacement characters (which it shouldn't). Note that it's possible for this to throw off line numbering if the invalid UTF-8 occurred adjacent to a newline. 2. NUL bytes. These are problematic for some tools. Args: filename: The name of the current file. lines: An array of strings, each representing a line of the file. error: The function to call with any errors found. """ for linenum, line in enumerate(lines): if unicode_escape_decode('\ufffd') in line: error(filename, linenum, 'readability/utf8', 5, 'Line contains invalid UTF-8 (or Unicode replacement character).') if '\0' in line: error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.') def CheckForNewlineAtEOF(filename, lines, error): """Logs an error if there is no newline char at the end of the file. Args: filename: The name of the current file. lines: An array of strings, each representing a line of the file. error: The function to call with any errors found. """ # The array lines() was created by adding two newlines to the # original file (go figure), then splitting on \n. # To verify that the file ends in \n, we just have to make sure the # last-but-two element of lines() exists and is empty. if len(lines) < 3 or lines[-2]: error(filename, len(lines) - 2, 'whitespace/ending_newline', 5, 'Could not find a newline character at the end of the file.') def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error): """Logs an error if we see /* ... */ or "..." that extend past one line. /* ... */ comments are legit inside macros, for one line. Otherwise, we prefer // comments, so it's ok to warn about the other. Likewise, it's ok for strings to extend across multiple lines, as long as a line continuation character (backslash) terminates each line. Although not currently prohibited by the C++ style guide, it's ugly and unnecessary. We don't do well with either in this lint program, so we warn about both. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # Remove all \\ (escaped backslashes) from the line. They are OK, and the # second (escaped) slash may trigger later \" detection erroneously. line = line.replace('\\\\', '') if line.count('/*') > line.count('*/'): error(filename, linenum, 'readability/multiline_comment', 5, 'Complex multi-line /*...*/-style comment found. ' 'Lint may give bogus warnings. ' 'Consider replacing these with //-style comments, ' 'with #if 0...#endif, ' 'or with more clearly structured multi-line comments.') if (line.count('"') - line.count('\\"')) % 2: error(filename, linenum, 'readability/multiline_string', 5, 'Multi-line string ("...") found. This lint script doesn\'t ' 'do well with such strings, and may give bogus warnings. ' 'Use C++11 raw strings or concatenation instead.') # (non-threadsafe name, thread-safe alternative, validation pattern) # # The validation pattern is used to eliminate false positives such as: # _rand(); // false positive due to substring match. # ->rand(); // some member function rand(). # ACMRandom rand(seed); // some variable named rand. # ISAACRandom rand(); // another variable named rand. # # Basically we require the return value of these functions to be used # in some expression context on the same line by matching on some # operator before the function name. This eliminates constructors and # member function calls. _UNSAFE_FUNC_PREFIX = r'(?:[-+*/=%^&|(<]\s*|>\s+)' _THREADING_LIST = ( ('asctime(', 'asctime_r(', _UNSAFE_FUNC_PREFIX + r'asctime\([^)]+\)'), ('ctime(', 'ctime_r(', _UNSAFE_FUNC_PREFIX + r'ctime\([^)]+\)'), ('getgrgid(', 'getgrgid_r(', _UNSAFE_FUNC_PREFIX + r'getgrgid\([^)]+\)'), ('getgrnam(', 'getgrnam_r(', _UNSAFE_FUNC_PREFIX + r'getgrnam\([^)]+\)'), ('getlogin(', 'getlogin_r(', _UNSAFE_FUNC_PREFIX + r'getlogin\(\)'), ('getpwnam(', 'getpwnam_r(', _UNSAFE_FUNC_PREFIX + r'getpwnam\([^)]+\)'), ('getpwuid(', 'getpwuid_r(', _UNSAFE_FUNC_PREFIX + r'getpwuid\([^)]+\)'), ('gmtime(', 'gmtime_r(', _UNSAFE_FUNC_PREFIX + r'gmtime\([^)]+\)'), ('localtime(', 'localtime_r(', _UNSAFE_FUNC_PREFIX + r'localtime\([^)]+\)'), ('rand(', 'rand_r(', _UNSAFE_FUNC_PREFIX + r'rand\(\)'), ('strtok(', 'strtok_r(', _UNSAFE_FUNC_PREFIX + r'strtok\([^)]+\)'), ('ttyname(', 'ttyname_r(', _UNSAFE_FUNC_PREFIX + r'ttyname\([^)]+\)'), ) def CheckPosixThreading(filename, clean_lines, linenum, error): """Checks for calls to thread-unsafe functions. Much code has been originally written without consideration of multi-threading. Also, engineers are relying on their old experience; they have learned posix before threading extensions were added. These tests guide the engineers to use thread-safe functions (when using posix directly). Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST: # Additional pattern matching check to confirm that this is the # function we are looking for if Search(pattern, line): error(filename, linenum, 'runtime/threadsafe_fn', 2, 'Consider using ' + multithread_safe_func + '...) instead of ' + single_thread_func + '...) for improved thread safety.') def CheckVlogArguments(filename, clean_lines, linenum, error): """Checks that VLOG() is only used for defining a logging level. For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and VLOG(FATAL) are not. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] if Search(r'\bVLOG\((INFO|ERROR|WARNING|DFATAL|FATAL)\)', line): error(filename, linenum, 'runtime/vlog', 5, 'VLOG() should be used with numeric verbosity level. ' 'Use LOG() if you want symbolic severity levels.') # Matches invalid increment: *count++, which moves pointer instead of # incrementing a value. _RE_PATTERN_INVALID_INCREMENT = re.compile( r'^\s*\*\w+(\+\+|--);') def CheckInvalidIncrement(filename, clean_lines, linenum, error): """Checks for invalid increment *count++. For example following function: void increment_counter(int* count) { *count++; } is invalid, because it effectively does count++, moving pointer, and should be replaced with ++*count, (*count)++ or *count += 1. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] if _RE_PATTERN_INVALID_INCREMENT.match(line): error(filename, linenum, 'runtime/invalid_increment', 5, 'Changing pointer instead of value (or unused value of operator*).') def IsMacroDefinition(clean_lines, linenum): if Search(r'^#define', clean_lines[linenum]): return True if linenum > 0 and Search(r'\\$', clean_lines[linenum - 1]): return True return False def IsForwardClassDeclaration(clean_lines, linenum): return Match(r'^\s*(\btemplate\b)*.*class\s+\w+;\s*$', clean_lines[linenum]) class _BlockInfo(object): """Stores information about a generic block of code.""" def __init__(self, linenum, seen_open_brace): self.starting_linenum = linenum self.seen_open_brace = seen_open_brace self.open_parentheses = 0 self.inline_asm = _NO_ASM self.check_namespace_indentation = False def CheckBegin(self, filename, clean_lines, linenum, error): """Run checks that applies to text up to the opening brace. This is mostly for checking the text after the class identifier and the "{", usually where the base class is specified. For other blocks, there isn't much to check, so we always pass. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ pass def CheckEnd(self, filename, clean_lines, linenum, error): """Run checks that applies to text after the closing brace. This is mostly used for checking end of namespace comments. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ pass def IsBlockInfo(self): """Returns true if this block is a _BlockInfo. This is convenient for verifying that an object is an instance of a _BlockInfo, but not an instance of any of the derived classes. Returns: True for this class, False for derived classes. """ return self.__class__ == _BlockInfo class _ExternCInfo(_BlockInfo): """Stores information about an 'extern "C"' block.""" def __init__(self, linenum): _BlockInfo.__init__(self, linenum, True) class _ClassInfo(_BlockInfo): """Stores information about a class.""" def __init__(self, name, class_or_struct, clean_lines, linenum): _BlockInfo.__init__(self, linenum, False) self.name = name self.is_derived = False self.check_namespace_indentation = True if class_or_struct == 'struct': self.access = 'public' self.is_struct = True else: self.access = 'private' self.is_struct = False # Remember initial indentation level for this class. Using raw_lines here # instead of elided to account for leading comments. self.class_indent = GetIndentLevel(clean_lines.raw_lines[linenum]) # Try to find the end of the class. This will be confused by things like: # class A { # } *x = { ... # # But it's still good enough for CheckSectionSpacing. self.last_line = 0 depth = 0 for i in range(linenum, clean_lines.NumLines()): line = clean_lines.elided[i] depth += line.count('{') - line.count('}') if not depth: self.last_line = i break def CheckBegin(self, filename, clean_lines, linenum, error): # Look for a bare ':' if Search('(^|[^:]):($|[^:])', clean_lines.elided[linenum]): self.is_derived = True def CheckEnd(self, filename, clean_lines, linenum, error): # If there is a DISALLOW macro, it should appear near the end of # the class. seen_last_thing_in_class = False for i in xrange(linenum - 1, self.starting_linenum, -1): match = Search( r'\b(DISALLOW_COPY_AND_ASSIGN|DISALLOW_IMPLICIT_CONSTRUCTORS)\(' + self.name + r'\)', clean_lines.elided[i]) if match: if seen_last_thing_in_class: error(filename, i, 'readability/constructors', 3, match.group(1) + ' should be the last thing in the class') break if not Match(r'^\s*$', clean_lines.elided[i]): seen_last_thing_in_class = True # Check that closing brace is aligned with beginning of the class. # Only do this if the closing brace is indented by only whitespaces. # This means we will not check single-line class definitions. indent = Match(r'^( *)\}', clean_lines.elided[linenum]) if indent and len(indent.group(1)) != self.class_indent: if self.is_struct: parent = 'struct ' + self.name else: parent = 'class ' + self.name error(filename, linenum, 'whitespace/indent', 3, 'Closing brace should be aligned with beginning of %s' % parent) class _NamespaceInfo(_BlockInfo): """Stores information about a namespace.""" def __init__(self, name, linenum): _BlockInfo.__init__(self, linenum, False) self.name = name or '' self.check_namespace_indentation = True def CheckEnd(self, filename, clean_lines, linenum, error): """Check end of namespace comments.""" line = clean_lines.raw_lines[linenum] # Check how many lines is enclosed in this namespace. Don't issue # warning for missing namespace comments if there aren't enough # lines. However, do apply checks if there is already an end of # namespace comment and it's incorrect. # # TODO(unknown): We always want to check end of namespace comments # if a namespace is large, but sometimes we also want to apply the # check if a short namespace contained nontrivial things (something # other than forward declarations). There is currently no logic on # deciding what these nontrivial things are, so this check is # triggered by namespace size only, which works most of the time. if (linenum - self.starting_linenum < 10 and not Match(r'^\s*};*\s*(//).*\bnamespace\b', line)): return # Look for matching comment at end of namespace. # # Note that we accept C style "/* */" comments for terminating # namespaces, so that code that terminate namespaces inside # preprocessor macros can be cpplint clean. # # We also accept stuff like "// end of namespace ." with the # period at the end. # # Besides these, we don't accept anything else, otherwise we might # get false negatives when existing comment is a substring of the # expected namespace. if self.name: # Named namespace if not Match((r'^\s*};*\s*(//).*\bnamespace\s+' + re.escape(self.name) + r'[\*/\.\\\s]*$'), line): error(filename, linenum, 'readability/namespace', 5, 'Namespace should be terminated with "// namespace %s"' % self.name) else: # Anonymous namespace if not Match(r'^\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line): # If "// namespace anonymous" or "// anonymous namespace (more text)", # mention "// anonymous namespace" as an acceptable form if Match(r'^\s*}.*\b(namespace anonymous|anonymous namespace)\b', line): error(filename, linenum, 'readability/namespace', 5, 'Anonymous namespace should be terminated with "// namespace"' ' or "// anonymous namespace"') else: error(filename, linenum, 'readability/namespace', 5, 'Anonymous namespace should be terminated with "// namespace"') class _PreprocessorInfo(object): """Stores checkpoints of nesting stacks when #if/#else is seen.""" def __init__(self, stack_before_if): # The entire nesting stack before #if self.stack_before_if = stack_before_if # The entire nesting stack up to #else self.stack_before_else = [] # Whether we have already seen #else or #elif self.seen_else = False class NestingState(object): """Holds states related to parsing braces.""" def __init__(self): # Stack for tracking all braces. An object is pushed whenever we # see a "{", and popped when we see a "}". Only 3 types of # objects are possible: # - _ClassInfo: a class or struct. # - _NamespaceInfo: a namespace. # - _BlockInfo: some other type of block. self.stack = [] # Top of the previous stack before each Update(). # # Because the nesting_stack is updated at the end of each line, we # had to do some convoluted checks to find out what is the current # scope at the beginning of the line. This check is simplified by # saving the previous top of nesting stack. # # We could save the full stack, but we only need the top. Copying # the full nesting stack would slow down cpplint by ~10%. self.previous_stack_top = [] # Stack of _PreprocessorInfo objects. self.pp_stack = [] def SeenOpenBrace(self): """Check if we have seen the opening brace for the innermost block. Returns: True if we have seen the opening brace, False if the innermost block is still expecting an opening brace. """ return (not self.stack) or self.stack[-1].seen_open_brace def InNamespaceBody(self): """Check if we are currently one level inside a namespace body. Returns: True if top of the stack is a namespace block, False otherwise. """ return self.stack and isinstance(self.stack[-1], _NamespaceInfo) def InExternC(self): """Check if we are currently one level inside an 'extern "C"' block. Returns: True if top of the stack is an extern block, False otherwise. """ return self.stack and isinstance(self.stack[-1], _ExternCInfo) def InClassDeclaration(self): """Check if we are currently one level inside a class or struct declaration. Returns: True if top of the stack is a class/struct, False otherwise. """ return self.stack and isinstance(self.stack[-1], _ClassInfo) def InAsmBlock(self): """Check if we are currently one level inside an inline ASM block. Returns: True if the top of the stack is a block containing inline ASM. """ return self.stack and self.stack[-1].inline_asm != _NO_ASM def InTemplateArgumentList(self, clean_lines, linenum, pos): """Check if current position is inside template argument list. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. pos: position just after the suspected template argument. Returns: True if (linenum, pos) is inside template arguments. """ while linenum < clean_lines.NumLines(): # Find the earliest character that might indicate a template argument line = clean_lines.elided[linenum] match = Match(r'^[^{};=\[\]\.<>]*(.)', line[pos:]) if not match: linenum += 1 pos = 0 continue token = match.group(1) pos += len(match.group(0)) # These things do not look like template argument list: # class Suspect { # class Suspect x; } if token in ('{', '}', ';'): return False # These things look like template argument list: # template # template # template # template if token in ('>', '=', '[', ']', '.'): return True # Check if token is an unmatched '<'. # If not, move on to the next character. if token != '<': pos += 1 if pos >= len(line): linenum += 1 pos = 0 continue # We can't be sure if we just find a single '<', and need to # find the matching '>'. (_, end_line, end_pos) = CloseExpression(clean_lines, linenum, pos - 1) if end_pos < 0: # Not sure if template argument list or syntax error in file return False linenum = end_line pos = end_pos return False def UpdatePreprocessor(self, line): """Update preprocessor stack. We need to handle preprocessors due to classes like this: #ifdef SWIG struct ResultDetailsPageElementExtensionPoint { #else struct ResultDetailsPageElementExtensionPoint : public Extension { #endif We make the following assumptions (good enough for most files): - Preprocessor condition evaluates to true from #if up to first #else/#elif/#endif. - Preprocessor condition evaluates to false from #else/#elif up to #endif. We still perform lint checks on these lines, but these do not affect nesting stack. Args: line: current line to check. """ if Match(r'^\s*#\s*(if|ifdef|ifndef)\b', line): # Beginning of #if block, save the nesting stack here. The saved # stack will allow us to restore the parsing state in the #else case. self.pp_stack.append(_PreprocessorInfo(copy.deepcopy(self.stack))) elif Match(r'^\s*#\s*(else|elif)\b', line): # Beginning of #else block if self.pp_stack: if not self.pp_stack[-1].seen_else: # This is the first #else or #elif block. Remember the # whole nesting stack up to this point. This is what we # keep after the #endif. self.pp_stack[-1].seen_else = True self.pp_stack[-1].stack_before_else = copy.deepcopy(self.stack) # Restore the stack to how it was before the #if self.stack = copy.deepcopy(self.pp_stack[-1].stack_before_if) else: # TODO(unknown): unexpected #else, issue warning? pass elif Match(r'^\s*#\s*endif\b', line): # End of #if or #else blocks. if self.pp_stack: # If we saw an #else, we will need to restore the nesting # stack to its former state before the #else, otherwise we # will just continue from where we left off. if self.pp_stack[-1].seen_else: # Here we can just use a shallow copy since we are the last # reference to it. self.stack = self.pp_stack[-1].stack_before_else # Drop the corresponding #if self.pp_stack.pop() else: # TODO(unknown): unexpected #endif, issue warning? pass # TODO(unknown): Update() is too long, but we will refactor later. def Update(self, filename, clean_lines, linenum, error): """Update nesting state with current line. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # Remember top of the previous nesting stack. # # The stack is always pushed/popped and not modified in place, so # we can just do a shallow copy instead of copy.deepcopy. Using # deepcopy would slow down cpplint by ~28%. if self.stack: self.previous_stack_top = self.stack[-1] else: self.previous_stack_top = None # Update pp_stack self.UpdatePreprocessor(line) # Count parentheses. This is to avoid adding struct arguments to # the nesting stack. if self.stack: inner_block = self.stack[-1] depth_change = line.count('(') - line.count(')') inner_block.open_parentheses += depth_change # Also check if we are starting or ending an inline assembly block. if inner_block.inline_asm in (_NO_ASM, _END_ASM): if (depth_change != 0 and inner_block.open_parentheses == 1 and _MATCH_ASM.match(line)): # Enter assembly block inner_block.inline_asm = _INSIDE_ASM else: # Not entering assembly block. If previous line was _END_ASM, # we will now shift to _NO_ASM state. inner_block.inline_asm = _NO_ASM elif (inner_block.inline_asm == _INSIDE_ASM and inner_block.open_parentheses == 0): # Exit assembly block inner_block.inline_asm = _END_ASM # Consume namespace declaration at the beginning of the line. Do # this in a loop so that we catch same line declarations like this: # namespace proto2 { namespace bridge { class MessageSet; } } while True: # Match start of namespace. The "\b\s*" below catches namespace # declarations even if it weren't followed by a whitespace, this # is so that we don't confuse our namespace checker. The # missing spaces will be flagged by CheckSpacing. namespace_decl_match = Match(r'^\s*namespace\b\s*([:\w]+)?(.*)$', line) if not namespace_decl_match: break new_namespace = _NamespaceInfo(namespace_decl_match.group(1), linenum) self.stack.append(new_namespace) line = namespace_decl_match.group(2) if line.find('{') != -1: new_namespace.seen_open_brace = True line = line[line.find('{') + 1:] # Look for a class declaration in whatever is left of the line # after parsing namespaces. The regexp accounts for decorated classes # such as in: # class LOCKABLE API Object { # }; class_decl_match = Match( r'^(\s*(?:template\s*<[\w\s<>,:=]*>\s*)?' r'(class|struct)\s+(?:[a-zA-Z0-9_]+\s+)*(\w+(?:::\w+)*))' r'(.*)$', line) if (class_decl_match and (not self.stack or self.stack[-1].open_parentheses == 0)): # We do not want to accept classes that are actually template arguments: # template , # template class Ignore3> # void Function() {}; # # To avoid template argument cases, we scan forward and look for # an unmatched '>'. If we see one, assume we are inside a # template argument list. end_declaration = len(class_decl_match.group(1)) if not self.InTemplateArgumentList(clean_lines, linenum, end_declaration): self.stack.append(_ClassInfo( class_decl_match.group(3), class_decl_match.group(2), clean_lines, linenum)) line = class_decl_match.group(4) # If we have not yet seen the opening brace for the innermost block, # run checks here. if not self.SeenOpenBrace(): self.stack[-1].CheckBegin(filename, clean_lines, linenum, error) # Update access control if we are inside a class/struct if self.stack and isinstance(self.stack[-1], _ClassInfo): classinfo = self.stack[-1] access_match = Match( r'^(.*)\b(public|private|protected|signals)(\s+(?:slots\s*)?)?' r':(?:[^:]|$)', line) if access_match: classinfo.access = access_match.group(2) # Check that access keywords are indented +1 space. Skip this # check if the keywords are not preceded by whitespaces. indent = access_match.group(1) if (len(indent) != classinfo.class_indent + 1 and Match(r'^\s*$', indent)): if classinfo.is_struct: parent = 'struct ' + classinfo.name else: parent = 'class ' + classinfo.name slots = '' if access_match.group(3): slots = access_match.group(3) error(filename, linenum, 'whitespace/indent', 3, '%s%s: should be indented +1 space inside %s' % ( access_match.group(2), slots, parent)) # Consume braces or semicolons from what's left of the line while True: # Match first brace, semicolon, or closed parenthesis. matched = Match(r'^[^{;)}]*([{;)}])(.*)$', line) if not matched: break token = matched.group(1) if token == '{': # If namespace or class hasn't seen a opening brace yet, mark # namespace/class head as complete. Push a new block onto the # stack otherwise. if not self.SeenOpenBrace(): self.stack[-1].seen_open_brace = True elif Match(r'^extern\s*"[^"]*"\s*\{', line): self.stack.append(_ExternCInfo(linenum)) else: self.stack.append(_BlockInfo(linenum, True)) if _MATCH_ASM.match(line): self.stack[-1].inline_asm = _BLOCK_ASM elif token == ';' or token == ')': # If we haven't seen an opening brace yet, but we already saw # a semicolon, this is probably a forward declaration. Pop # the stack for these. # # Similarly, if we haven't seen an opening brace yet, but we # already saw a closing parenthesis, then these are probably # function arguments with extra "class" or "struct" keywords. # Also pop these stack for these. if not self.SeenOpenBrace(): self.stack.pop() else: # token == '}' # Perform end of block checks and pop the stack. if self.stack: self.stack[-1].CheckEnd(filename, clean_lines, linenum, error) self.stack.pop() line = matched.group(2) def InnermostClass(self): """Get class info on the top of the stack. Returns: A _ClassInfo object if we are inside a class, or None otherwise. """ for i in range(len(self.stack), 0, -1): classinfo = self.stack[i - 1] if isinstance(classinfo, _ClassInfo): return classinfo return None def CheckCompletedBlocks(self, filename, error): """Checks that all classes and namespaces have been completely parsed. Call this when all lines in a file have been processed. Args: filename: The name of the current file. error: The function to call with any errors found. """ # Note: This test can result in false positives if #ifdef constructs # get in the way of brace matching. See the testBuildClass test in # cpplint_unittest.py for an example of this. for obj in self.stack: if isinstance(obj, _ClassInfo): error(filename, obj.starting_linenum, 'build/class', 5, 'Failed to find complete declaration of class %s' % obj.name) elif isinstance(obj, _NamespaceInfo): error(filename, obj.starting_linenum, 'build/namespaces', 5, 'Failed to find complete declaration of namespace %s' % obj.name) def CheckForNonStandardConstructs(filename, clean_lines, linenum, nesting_state, error): r"""Logs an error if we see certain non-ANSI constructs ignored by gcc-2. Complain about several constructs which gcc-2 accepts, but which are not standard C++. Warning about these in lint is one way to ease the transition to new compilers. - put storage class first (e.g. "static const" instead of "const static"). - "%lld" instead of %qd" in printf-type functions. - "%1$d" is non-standard in printf-type functions. - "\%" is an undefined character escape sequence. - text after #endif is not allowed. - invalid inner-style forward declaration. - >? and ?= and )\?=?\s*(\w+|[+-]?\d+)(\.\d*)?', line): error(filename, linenum, 'build/deprecated', 3, '>? and ))?' # r'\s*const\s*' + type_name + '\s*&\s*\w+\s*;' error(filename, linenum, 'runtime/member_string_references', 2, 'const string& members are dangerous. It is much better to use ' 'alternatives, such as pointers or simple constants.') # Everything else in this function operates on class declarations. # Return early if the top of the nesting stack is not a class, or if # the class head is not completed yet. classinfo = nesting_state.InnermostClass() if not classinfo or not classinfo.seen_open_brace: return # The class may have been declared with namespace or classname qualifiers. # The constructor and destructor will not have those qualifiers. base_classname = classinfo.name.split('::')[-1] # Look for single-argument constructors that aren't marked explicit. # Technically a valid construct, but against style. explicit_constructor_match = Match( r'\s+(?:(?:inline|constexpr)\s+)*(explicit\s+)?' r'(?:(?:inline|constexpr)\s+)*%s\s*' r'\(((?:[^()]|\([^()]*\))*)\)' % re.escape(base_classname), line) if explicit_constructor_match: is_marked_explicit = explicit_constructor_match.group(1) if not explicit_constructor_match.group(2): constructor_args = [] else: constructor_args = explicit_constructor_match.group(2).split(',') # collapse arguments so that commas in template parameter lists and function # argument parameter lists don't split arguments in two i = 0 while i < len(constructor_args): constructor_arg = constructor_args[i] while (constructor_arg.count('<') > constructor_arg.count('>') or constructor_arg.count('(') > constructor_arg.count(')')): constructor_arg += ',' + constructor_args[i + 1] del constructor_args[i + 1] constructor_args[i] = constructor_arg i += 1 variadic_args = [arg for arg in constructor_args if '&&...' in arg] defaulted_args = [arg for arg in constructor_args if '=' in arg] noarg_constructor = (not constructor_args or # empty arg list # 'void' arg specifier (len(constructor_args) == 1 and constructor_args[0].strip() == 'void')) onearg_constructor = ((len(constructor_args) == 1 and # exactly one arg not noarg_constructor) or # all but at most one arg defaulted (len(constructor_args) >= 1 and not noarg_constructor and len(defaulted_args) >= len(constructor_args) - 1) or # variadic arguments with zero or one argument (len(constructor_args) <= 2 and len(variadic_args) >= 1)) initializer_list_constructor = bool( onearg_constructor and Search(r'\bstd\s*::\s*initializer_list\b', constructor_args[0])) copy_constructor = bool( onearg_constructor and Match(r'((const\s+(volatile\s+)?)?|(volatile\s+(const\s+)?))?' r'%s(\s*<[^>]*>)?(\s+const)?\s*(?:<\w+>\s*)?&' % re.escape(base_classname), constructor_args[0].strip())) if (not is_marked_explicit and onearg_constructor and not initializer_list_constructor and not copy_constructor): if defaulted_args or variadic_args: error(filename, linenum, 'runtime/explicit', 5, 'Constructors callable with one argument ' 'should be marked explicit.') else: error(filename, linenum, 'runtime/explicit', 5, 'Single-parameter constructors should be marked explicit.') elif is_marked_explicit and not onearg_constructor: if noarg_constructor: error(filename, linenum, 'runtime/explicit', 5, 'Zero-parameter constructors should not be marked explicit.') def CheckSpacingForFunctionCall(filename, clean_lines, linenum, error): """Checks for the correctness of various spacing around function calls. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # Since function calls often occur inside if/for/while/switch # expressions - which have their own, more liberal conventions - we # first see if we should be looking inside such an expression for a # function call, to which we can apply more strict standards. fncall = line # if there's no control flow construct, look at whole line for pattern in (r'\bif\s*\((.*)\)\s*{', r'\bfor\s*\((.*)\)\s*{', r'\bwhile\s*\((.*)\)\s*[{;]', r'\bswitch\s*\((.*)\)\s*{'): match = Search(pattern, line) if match: fncall = match.group(1) # look inside the parens for function calls break # Except in if/for/while/switch, there should never be space # immediately inside parens (eg "f( 3, 4 )"). We make an exception # for nested parens ( (a+b) + c ). Likewise, there should never be # a space before a ( when it's a function argument. I assume it's a # function argument when the char before the whitespace is legal in # a function name (alnum + _) and we're not starting a macro. Also ignore # pointers and references to arrays and functions coz they're too tricky: # we use a very simple way to recognize these: # " (something)(maybe-something)" or # " (something)(maybe-something," or # " (something)[something]" # Note that we assume the contents of [] to be short enough that # they'll never need to wrap. if ( # Ignore control structures. not Search(r'\b(if|elif|for|while|switch|return|new|delete|catch|sizeof)\b', fncall) and # Ignore pointers/references to functions. not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and # Ignore pointers/references to arrays. not Search(r' \([^)]+\)\[[^\]]+\]', fncall)): if Search(r'\w\s*\(\s(?!\s*\\$)', fncall): # a ( used for a fn call error(filename, linenum, 'whitespace/parens', 4, 'Extra space after ( in function call') elif Search(r'\(\s+(?!(\s*\\)|\()', fncall): error(filename, linenum, 'whitespace/parens', 2, 'Extra space after (') if (Search(r'\w\s+\(', fncall) and not Search(r'_{0,2}asm_{0,2}\s+_{0,2}volatile_{0,2}\s+\(', fncall) and not Search(r'#\s*define|typedef|using\s+\w+\s*=', fncall) and not Search(r'\w\s+\((\w+::)*\*\w+\)\(', fncall) and not Search(r'\bcase\s+\(', fncall)): # TODO(unknown): Space after an operator function seem to be a common # error, silence those for now by restricting them to highest verbosity. if Search(r'\boperator_*\b', line): error(filename, linenum, 'whitespace/parens', 0, 'Extra space before ( in function call') else: error(filename, linenum, 'whitespace/parens', 4, 'Extra space before ( in function call') # If the ) is followed only by a newline or a { + newline, assume it's # part of a control statement (if/while/etc), and don't complain if Search(r'[^)]\s+\)\s*[^{\s]', fncall): # If the closing parenthesis is preceded by only whitespaces, # try to give a more descriptive error message. if Search(r'^\s+\)', fncall): error(filename, linenum, 'whitespace/parens', 2, 'Closing ) should be moved to the previous line') else: error(filename, linenum, 'whitespace/parens', 2, 'Extra space before )') def IsBlankLine(line): """Returns true if the given line is blank. We consider a line to be blank if the line is empty or consists of only white spaces. Args: line: A line of a string. Returns: True, if the given line is blank. """ return not line or line.isspace() def CheckForNamespaceIndentation(filename, nesting_state, clean_lines, line, error): is_namespace_indent_item = ( len(nesting_state.stack) > 1 and nesting_state.stack[-1].check_namespace_indentation and isinstance(nesting_state.previous_stack_top, _NamespaceInfo) and nesting_state.previous_stack_top == nesting_state.stack[-2]) if ShouldCheckNamespaceIndentation(nesting_state, is_namespace_indent_item, clean_lines.elided, line): CheckItemIndentationInNamespace(filename, clean_lines.elided, line, error) def CheckForFunctionLengths(filename, clean_lines, linenum, function_state, error): """Reports for long function bodies. For an overview why this is done, see: https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions Uses a simplistic algorithm assuming other style guidelines (especially spacing) are followed. Only checks unindented functions, so class members are unchecked. Trivial bodies are unchecked, so constructors with huge initializer lists may be missed. Blank/comment lines are not counted so as to avoid encouraging the removal of vertical space and comments just to get through a lint check. NOLINT *on the last line of a function* disables this check. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. function_state: Current function name and lines in body so far. error: The function to call with any errors found. """ lines = clean_lines.lines line = lines[linenum] joined_line = '' starting_func = False regexp = r'(\w(\w|::|\*|\&|\s)*)\(' # decls * & space::name( ... match_result = Match(regexp, line) if match_result: # If the name is all caps and underscores, figure it's a macro and # ignore it, unless it's TEST or TEST_F. function_name = match_result.group(1).split()[-1] if function_name == 'TEST' or function_name == 'TEST_F' or ( not Match(r'[A-Z_]+$', function_name)): starting_func = True if starting_func: body_found = False for start_linenum in xrange(linenum, clean_lines.NumLines()): start_line = lines[start_linenum] joined_line += ' ' + start_line.lstrip() if Search(r'(;|})', start_line): # Declarations and trivial functions body_found = True break # ... ignore if Search(r'{', start_line): body_found = True function = Search(r'((\w|:)*)\(', line).group(1) if Match(r'TEST', function): # Handle TEST... macros parameter_regexp = Search(r'(\(.*\))', joined_line) if parameter_regexp: # Ignore bad syntax function += parameter_regexp.group(1) else: function += '()' function_state.Begin(function) break if not body_found: # No body for the function (or evidence of a non-function) was found. error(filename, linenum, 'readability/fn_size', 5, 'Lint failed to find start of function body.') elif Match(r'^\}\s*$', line): # function end function_state.Check(error, filename, linenum) function_state.End() elif not Match(r'^\s*$', line): function_state.Count() # Count non-blank/non-comment lines. _RE_PATTERN_TODO = re.compile(r'^//(\s*)TODO(\(.+?\))?:?(\s|$)?') def CheckComment(line, filename, linenum, next_line_start, error): """Checks for common mistakes in comments. Args: line: The line in question. filename: The name of the current file. linenum: The number of the line to check. next_line_start: The first non-whitespace column of the next line. error: The function to call with any errors found. """ commentpos = line.find('//') if commentpos != -1: # Check if the // may be in quotes. If so, ignore it if re.sub(r'\\.', '', line[0:commentpos]).count('"') % 2 == 0: # Allow one space for new scopes, two spaces otherwise: if (not (Match(r'^.*{ *//', line) and next_line_start == commentpos) and ((commentpos >= 1 and line[commentpos-1] not in string.whitespace) or (commentpos >= 2 and line[commentpos-2] not in string.whitespace))): error(filename, linenum, 'whitespace/comments', 2, 'At least two spaces is best between code and comments') # Checks for common mistakes in TODO comments. comment = line[commentpos:] match = _RE_PATTERN_TODO.match(comment) if match: # One whitespace is correct; zero whitespace is handled elsewhere. leading_whitespace = match.group(1) if len(leading_whitespace) > 1: error(filename, linenum, 'whitespace/todo', 2, 'Too many spaces before TODO') username = match.group(2) if not username: error(filename, linenum, 'readability/todo', 2, 'Missing username in TODO; it should look like ' '"// TODO(my_username): Stuff."') middle_whitespace = match.group(3) # Comparisons made explicit for correctness -- pylint: disable=g-explicit-bool-comparison if middle_whitespace != ' ' and middle_whitespace != '': error(filename, linenum, 'whitespace/todo', 2, 'TODO(my_username) should be followed by a space') # If the comment contains an alphanumeric character, there # should be a space somewhere between it and the // unless # it's a /// or //! Doxygen comment. if (Match(r'//[^ ]*\w', comment) and not Match(r'(///|//\!)(\s+|$)', comment)): error(filename, linenum, 'whitespace/comments', 4, 'Should have a space between // and comment') def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): """Checks for the correctness of various spacing issues in the code. Things we check for: spaces around operators, spaces after if/for/while/switch, no spaces around parens in function calls, two spaces between code and comment, don't start a block with a blank line, don't end a function with a blank line, don't add a blank line after public/protected/private, don't have too many blank lines in a row. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found. """ # Don't use "elided" lines here, otherwise we can't check commented lines. # Don't want to use "raw" either, because we don't want to check inside C++11 # raw strings, raw = clean_lines.lines_without_raw_strings line = raw[linenum] # Before nixing comments, check if the line is blank for no good # reason. This includes the first line after a block is opened, and # blank lines at the end of a function (ie, right before a line like '}' # # Skip all the blank line checks if we are immediately inside a # namespace body. In other words, don't issue blank line warnings # for this block: # namespace { # # } # # A warning about missing end of namespace comments will be issued instead. # # Also skip blank line checks for 'extern "C"' blocks, which are formatted # like namespaces. if (IsBlankLine(line) and not nesting_state.InNamespaceBody() and not nesting_state.InExternC()): elided = clean_lines.elided prev_line = elided[linenum - 1] prevbrace = prev_line.rfind('{') # TODO(unknown): Don't complain if line before blank line, and line after, # both start with alnums and are indented the same amount. # This ignores whitespace at the start of a namespace block # because those are not usually indented. if prevbrace != -1 and prev_line[prevbrace:].find('}') == -1: # OK, we have a blank line at the start of a code block. Before we # complain, we check if it is an exception to the rule: The previous # non-empty line has the parameters of a function header that are indented # 4 spaces (because they did not fit in a 80 column line when placed on # the same line as the function name). We also check for the case where # the previous line is indented 6 spaces, which may happen when the # initializers of a constructor do not fit into a 80 column line. exception = False if Match(r' {6}\w', prev_line): # Initializer list? # We are looking for the opening column of initializer list, which # should be indented 4 spaces to cause 6 space indentation afterwards. search_position = linenum-2 while (search_position >= 0 and Match(r' {6}\w', elided[search_position])): search_position -= 1 exception = (search_position >= 0 and elided[search_position][:5] == ' :') else: # Search for the function arguments or an initializer list. We use a # simple heuristic here: If the line is indented 4 spaces; and we have a # closing paren, without the opening paren, followed by an opening brace # or colon (for initializer lists) we assume that it is the last line of # a function header. If we have a colon indented 4 spaces, it is an # initializer list. exception = (Match(r' {4}\w[^\(]*\)\s*(const\s*)?(\{\s*$|:)', prev_line) or Match(r' {4}:', prev_line)) if not exception: error(filename, linenum, 'whitespace/blank_line', 2, 'Redundant blank line at the start of a code block ' 'should be deleted.') # Ignore blank lines at the end of a block in a long if-else # chain, like this: # if (condition1) { # // Something followed by a blank line # # } else if (condition2) { # // Something else # } if linenum + 1 < clean_lines.NumLines(): next_line = raw[linenum + 1] if (next_line and Match(r'\s*}', next_line) and next_line.find('} else ') == -1): error(filename, linenum, 'whitespace/blank_line', 3, 'Redundant blank line at the end of a code block ' 'should be deleted.') matched = Match(r'\s*(public|protected|private):', prev_line) if matched: error(filename, linenum, 'whitespace/blank_line', 3, 'Do not leave a blank line after "%s:"' % matched.group(1)) # Next, check comments next_line_start = 0 if linenum + 1 < clean_lines.NumLines(): next_line = raw[linenum + 1] next_line_start = len(next_line) - len(next_line.lstrip()) CheckComment(line, filename, linenum, next_line_start, error) # get rid of comments and strings line = clean_lines.elided[linenum] # You shouldn't have spaces before your brackets, except for C++11 attributes # or maybe after 'delete []', 'return []() {};', or 'auto [abc, ...] = ...;'. if (Search(r'\w\s+\[(?!\[)', line) and not Search(r'(?:auto&?|delete|return)\s+\[', line)): error(filename, linenum, 'whitespace/braces', 5, 'Extra space before [') # In range-based for, we wanted spaces before and after the colon, but # not around "::" tokens that might appear. if (Search(r'for *\(.*[^:]:[^: ]', line) or Search(r'for *\(.*[^: ]:[^:]', line)): error(filename, linenum, 'whitespace/forcolon', 2, 'Missing space around colon in range-based for loop') def CheckOperatorSpacing(filename, clean_lines, linenum, error): """Checks for horizontal spacing around operators. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # Don't try to do spacing checks for operator methods. Do this by # replacing the troublesome characters with something else, # preserving column position for all other characters. # # The replacement is done repeatedly to avoid false positives from # operators that call operators. while True: match = Match(r'^(.*\boperator\b)(\S+)(\s*\(.*)$', line) if match: line = match.group(1) + ('_' * len(match.group(2))) + match.group(3) else: break # We allow no-spaces around = within an if: "if ( (a=Foo()) == 0 )". # Otherwise not. Note we only check for non-spaces on *both* sides; # sometimes people put non-spaces on one side when aligning ='s among # many lines (not that this is behavior that I approve of...) if ((Search(r'[\w.]=', line) or Search(r'=[\w.]', line)) and not Search(r'\b(if|while|for) ', line) # Operators taken from [lex.operators] in C++11 standard. and not Search(r'(>=|<=|==|!=|&=|\^=|\|=|\+=|\*=|\/=|\%=)', line) and not Search(r'operator=', line)): error(filename, linenum, 'whitespace/operators', 4, 'Missing spaces around =') # It's ok not to have spaces around binary operators like + - * /, but if # there's too little whitespace, we get concerned. It's hard to tell, # though, so we punt on this one for now. TODO. # You should always have whitespace around binary operators. # # Check <= and >= first to avoid false positives with < and >, then # check non-include lines for spacing around < and >. # # If the operator is followed by a comma, assume it's be used in a # macro context and don't do any checks. This avoids false # positives. # # Note that && is not included here. This is because there are too # many false positives due to RValue references. match = Search(r'[^<>=!\s](==|!=|<=|>=|\|\|)[^<>=!\s,;\)]', line) if match: error(filename, linenum, 'whitespace/operators', 3, 'Missing spaces around %s' % match.group(1)) elif not Match(r'#.*include', line): # Look for < that is not surrounded by spaces. This is only # triggered if both sides are missing spaces, even though # technically should should flag if at least one side is missing a # space. This is done to avoid some false positives with shifts. match = Match(r'^(.*[^\s<])<[^\s=<,]', line) if match: (_, _, end_pos) = CloseExpression( clean_lines, linenum, len(match.group(1))) if end_pos <= -1: error(filename, linenum, 'whitespace/operators', 3, 'Missing spaces around <') # Look for > that is not surrounded by spaces. Similar to the # above, we only trigger if both sides are missing spaces to avoid # false positives with shifts. match = Match(r'^(.*[^-\s>])>[^\s=>,]', line) if match: (_, _, start_pos) = ReverseCloseExpression( clean_lines, linenum, len(match.group(1))) if start_pos <= -1: error(filename, linenum, 'whitespace/operators', 3, 'Missing spaces around >') # We allow no-spaces around << when used like this: 10<<20, but # not otherwise (particularly, not when used as streams) # # We also allow operators following an opening parenthesis, since # those tend to be macros that deal with operators. match = Search(r'(operator|[^\s(<])(?:L|UL|LL|ULL|l|ul|ll|ull)?<<([^\s,=<])', line) if (match and not (match.group(1).isdigit() and match.group(2).isdigit()) and not (match.group(1) == 'operator' and match.group(2) == ';')): error(filename, linenum, 'whitespace/operators', 3, 'Missing spaces around <<') # We allow no-spaces around >> for almost anything. This is because # C++11 allows ">>" to close nested templates, which accounts for # most cases when ">>" is not followed by a space. # # We still warn on ">>" followed by alpha character, because that is # likely due to ">>" being used for right shifts, e.g.: # value >> alpha # # When ">>" is used to close templates, the alphanumeric letter that # follows would be part of an identifier, and there should still be # a space separating the template type and the identifier. # type> alpha match = Search(r'>>[a-zA-Z_]', line) if match: error(filename, linenum, 'whitespace/operators', 3, 'Missing spaces around >>') # There shouldn't be space around unary operators match = Search(r'(!\s|~\s|[\s]--[\s;]|[\s]\+\+[\s;])', line) if match: error(filename, linenum, 'whitespace/operators', 4, 'Extra space for operator %s' % match.group(1)) def CheckParenthesisSpacing(filename, clean_lines, linenum, error): """Checks for horizontal spacing around parentheses. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # No spaces after an if, while, switch, or for match = Search(r' (if\(|for\(|while\(|switch\()', line) if match: error(filename, linenum, 'whitespace/parens', 5, 'Missing space before ( in %s' % match.group(1)) # For if/for/while/switch, the left and right parens should be # consistent about how many spaces are inside the parens, and # there should either be zero or one spaces inside the parens. # We don't want: "if ( foo)" or "if ( foo )". # Exception: "for ( ; foo; bar)" and "for (foo; bar; )" are allowed. match = Search(r'\b(if|for|while|switch)\s*' r'\(([ ]*)(.).*[^ ]+([ ]*)\)\s*{\s*$', line) if match: if len(match.group(2)) != len(match.group(4)): if not (match.group(3) == ';' and len(match.group(2)) == 1 + len(match.group(4)) or not match.group(2) and Search(r'\bfor\s*\(.*; \)', line)): error(filename, linenum, 'whitespace/parens', 5, 'Mismatching spaces inside () in %s' % match.group(1)) if len(match.group(2)) not in [0, 1]: error(filename, linenum, 'whitespace/parens', 5, 'Should have zero or one spaces inside ( and ) in %s' % match.group(1)) def CheckCommaSpacing(filename, clean_lines, linenum, error): """Checks for horizontal spacing near commas and semicolons. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ raw = clean_lines.lines_without_raw_strings line = clean_lines.elided[linenum] # You should always have a space after a comma (either as fn arg or operator) # # This does not apply when the non-space character following the # comma is another comma, since the only time when that happens is # for empty macro arguments. # # We run this check in two passes: first pass on elided lines to # verify that lines contain missing whitespaces, second pass on raw # lines to confirm that those missing whitespaces are not due to # elided comments. if (Search(r',[^,\s]', ReplaceAll(r'\boperator\s*,\s*\(', 'F(', line)) and Search(r',[^,\s]', raw[linenum])): error(filename, linenum, 'whitespace/comma', 3, 'Missing space after ,') # You should always have a space after a semicolon # except for few corner cases # TODO(unknown): clarify if 'if (1) { return 1;}' is requires one more # space after ; if Search(r';[^\s};\\)/]', line): error(filename, linenum, 'whitespace/semicolon', 3, 'Missing space after ;') def _IsType(clean_lines, nesting_state, expr): """Check if expression looks like a type name, returns true if so. Args: clean_lines: A CleansedLines instance containing the file. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. expr: The expression to check. Returns: True, if token looks like a type. """ # Keep only the last token in the expression last_word = Match(r'^.*(\b\S+)$', expr) if last_word: token = last_word.group(1) else: token = expr # Match native types and stdint types if _TYPES.match(token): return True # Try a bit harder to match templated types. Walk up the nesting # stack until we find something that resembles a typename # declaration for what we are looking for. typename_pattern = (r'\b(?:typename|class|struct)\s+' + re.escape(token) + r'\b') block_index = len(nesting_state.stack) - 1 while block_index >= 0: if isinstance(nesting_state.stack[block_index], _NamespaceInfo): return False # Found where the opening brace is. We want to scan from this # line up to the beginning of the function, minus a few lines. # template # class C # : public ... { // start scanning here last_line = nesting_state.stack[block_index].starting_linenum next_block_start = 0 if block_index > 0: next_block_start = nesting_state.stack[block_index - 1].starting_linenum first_line = last_line while first_line >= next_block_start: if clean_lines.elided[first_line].find('template') >= 0: break first_line -= 1 if first_line < next_block_start: # Didn't find any "template" keyword before reaching the next block, # there are probably no template things to check for this block block_index -= 1 continue # Look for typename in the specified range for i in xrange(first_line, last_line + 1, 1): if Search(typename_pattern, clean_lines.elided[i]): return True block_index -= 1 return False def CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error): """Checks for horizontal spacing near commas. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # Except after an opening paren, or after another opening brace (in case of # an initializer list, for instance), you should have spaces before your # braces when they are delimiting blocks, classes, namespaces etc. # And since you should never have braces at the beginning of a line, # this is an easy test. Except that braces used for initialization don't # follow the same rule; we often don't want spaces before those. match = Match(r'^(.*[^ ({>]){', line) if match: # Try a bit harder to check for brace initialization. This # happens in one of the following forms: # Constructor() : initializer_list_{} { ... } # Constructor{}.MemberFunction() # Type variable{}; # FunctionCall(type{}, ...); # LastArgument(..., type{}); # LOG(INFO) << type{} << " ..."; # map_of_type[{...}] = ...; # ternary = expr ? new type{} : nullptr; # OuterTemplate{}> # # We check for the character following the closing brace, and # silence the warning if it's one of those listed above, i.e. # "{.;,)<>]:". # # To account for nested initializer list, we allow any number of # closing braces up to "{;,)<". We can't simply silence the # warning on first sight of closing brace, because that would # cause false negatives for things that are not initializer lists. # Silence this: But not this: # Outer{ if (...) { # Inner{...} if (...){ // Missing space before { # }; } # # There is a false negative with this approach if people inserted # spurious semicolons, e.g. "if (cond){};", but we will catch the # spurious semicolon with a separate check. leading_text = match.group(1) (endline, endlinenum, endpos) = CloseExpression( clean_lines, linenum, len(match.group(1))) trailing_text = '' if endpos > -1: trailing_text = endline[endpos:] for offset in xrange(endlinenum + 1, min(endlinenum + 3, clean_lines.NumLines() - 1)): trailing_text += clean_lines.elided[offset] # We also suppress warnings for `uint64_t{expression}` etc., as the style # guide recommends brace initialization for integral types to avoid # overflow/truncation. if (not Match(r'^[\s}]*[{.;,)<>\]:]', trailing_text) and not _IsType(clean_lines, nesting_state, leading_text)): error(filename, linenum, 'whitespace/braces', 5, 'Missing space before {') # Make sure '} else {' has spaces. if Search(r'}else', line): error(filename, linenum, 'whitespace/braces', 5, 'Missing space before else') # You shouldn't have a space before a semicolon at the end of the line. # There's a special case for "for" since the style guide allows space before # the semicolon there. if Search(r':\s*;\s*$', line): error(filename, linenum, 'whitespace/semicolon', 5, 'Semicolon defining empty statement. Use {} instead.') elif Search(r'^\s*;\s*$', line): error(filename, linenum, 'whitespace/semicolon', 5, 'Line contains only semicolon. If this should be an empty statement, ' 'use {} instead.') elif (Search(r'\s+;\s*$', line) and not Search(r'\bfor\b', line)): error(filename, linenum, 'whitespace/semicolon', 5, 'Extra space before last semicolon. If this should be an empty ' 'statement, use {} instead.') def IsDecltype(clean_lines, linenum, column): """Check if the token ending on (linenum, column) is decltype(). Args: clean_lines: A CleansedLines instance containing the file. linenum: the number of the line to check. column: end column of the token to check. Returns: True if this token is decltype() expression, False otherwise. """ (text, _, start_col) = ReverseCloseExpression(clean_lines, linenum, column) if start_col < 0: return False if Search(r'\bdecltype\s*$', text[0:start_col]): return True return False def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): """Checks for additional blank line issues related to sections. Currently the only thing checked here is blank line before protected/private. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. class_info: A _ClassInfo objects. linenum: The number of the line to check. error: The function to call with any errors found. """ # Skip checks if the class is small, where small means 25 lines or less. # 25 lines seems like a good cutoff since that's the usual height of # terminals, and any class that can't fit in one screen can't really # be considered "small". # # Also skip checks if we are on the first line. This accounts for # classes that look like # class Foo { public: ... }; # # If we didn't find the end of the class, last_line would be zero, # and the check will be skipped by the first condition. if (class_info.last_line - class_info.starting_linenum <= 24 or linenum <= class_info.starting_linenum): return matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum]) if matched: # Issue warning if the line before public/protected/private was # not a blank line, but don't do this if the previous line contains # "class" or "struct". This can happen two ways: # - We are at the beginning of the class. # - We are forward-declaring an inner class that is semantically # private, but needed to be public for implementation reasons. # Also ignores cases where the previous line ends with a backslash as can be # common when defining classes in C macros. prev_line = clean_lines.lines[linenum - 1] if (not IsBlankLine(prev_line) and not Search(r'\b(class|struct)\b', prev_line) and not Search(r'\\$', prev_line)): # Try a bit harder to find the beginning of the class. This is to # account for multi-line base-specifier lists, e.g.: # class Derived # : public Base { end_class_head = class_info.starting_linenum for i in range(class_info.starting_linenum, linenum): if Search(r'\{\s*$', clean_lines.lines[i]): end_class_head = i break if end_class_head < linenum - 1: error(filename, linenum, 'whitespace/blank_line', 3, '"%s:" should be preceded by a blank line' % matched.group(1)) def GetPreviousNonBlankLine(clean_lines, linenum): """Return the most recent non-blank line and its line number. Args: clean_lines: A CleansedLines instance containing the file contents. linenum: The number of the line to check. Returns: A tuple with two elements. The first element is the contents of the last non-blank line before the current line, or the empty string if this is the first non-blank line. The second is the line number of that line, or -1 if this is the first non-blank line. """ prevlinenum = linenum - 1 while prevlinenum >= 0: prevline = clean_lines.elided[prevlinenum] if not IsBlankLine(prevline): # if not a blank line... return (prevline, prevlinenum) prevlinenum -= 1 return ('', -1) def CheckBraces(filename, clean_lines, linenum, error): """Looks for misplaced braces (e.g. at the end of line). Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # get rid of comments and strings if Match(r'\s*{\s*$', line): # We allow an open brace to start a line in the case where someone is using # braces in a block to explicitly create a new scope, which is commonly used # to control the lifetime of stack-allocated variables. Braces are also # used for brace initializers inside function calls. We don't detect this # perfectly: we just don't complain if the last non-whitespace character on # the previous non-blank line is ',', ';', ':', '(', '{', or '}', or if the # previous line starts a preprocessor block. We also allow a brace on the # following line if it is part of an array initialization and would not fit # within the 80 character limit of the preceding line. prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] if (not Search(r'[,;:}{(]\s*$', prevline) and not Match(r'\s*#', prevline) and not (GetLineWidth(prevline) > _line_length - 2 and '[]' in prevline)): error(filename, linenum, 'whitespace/braces', 4, '{ should almost always be at the end of the previous line') # An else clause should be on the same line as the preceding closing brace. if Match(r'\s*else\b\s*(?:if\b|\{|$)', line): prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] if Match(r'\s*}\s*$', prevline): error(filename, linenum, 'whitespace/newline', 4, 'An else should appear on the same line as the preceding }') # If braces come on one side of an else, they should be on both. # However, we have to worry about "else if" that spans multiple lines! if Search(r'else if\s*\(', line): # could be multi-line if brace_on_left = bool(Search(r'}\s*else if\s*\(', line)) # find the ( after the if pos = line.find('else if') pos = line.find('(', pos) if pos > 0: (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos) brace_on_right = endline[endpos:].find('{') != -1 if brace_on_left != brace_on_right: # must be brace after if error(filename, linenum, 'readability/braces', 5, 'If an else has a brace on one side, it should have it on both') elif Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line): error(filename, linenum, 'readability/braces', 5, 'If an else has a brace on one side, it should have it on both') # Likewise, an else should never have the else clause on the same line if Search(r'\belse [^\s{]', line) and not Search(r'\belse if\b', line): error(filename, linenum, 'whitespace/newline', 4, 'Else clause should never be on same line as else (use 2 lines)') # In the same way, a do/while should never be on one line if Match(r'\s*do [^\s{]', line): error(filename, linenum, 'whitespace/newline', 4, 'do/while clauses should not be on a single line') # Check single-line if/else bodies. The style guide says 'curly braces are not # required for single-line statements'. We additionally allow multi-line, # single statements, but we reject anything with more than one semicolon in # it. This means that the first semicolon after the if should be at the end of # its line, and the line after that should have an indent level equal to or # lower than the if. We also check for ambiguous if/else nesting without # braces. if_else_match = Search(r'\b(if\s*(|constexpr)\s*\(|else\b)', line) if if_else_match and not Match(r'\s*#', line): if_indent = GetIndentLevel(line) endline, endlinenum, endpos = line, linenum, if_else_match.end() if_match = Search(r'\bif\s*(|constexpr)\s*\(', line) if if_match: # This could be a multiline if condition, so find the end first. pos = if_match.end() - 1 (endline, endlinenum, endpos) = CloseExpression(clean_lines, linenum, pos) # Check for an opening brace, either directly after the if or on the next # line. If found, this isn't a single-statement conditional. if (not Match(r'\s*{', endline[endpos:]) and not (Match(r'\s*$', endline[endpos:]) and endlinenum < (len(clean_lines.elided) - 1) and Match(r'\s*{', clean_lines.elided[endlinenum + 1]))): while (endlinenum < len(clean_lines.elided) and ';' not in clean_lines.elided[endlinenum][endpos:]): endlinenum += 1 endpos = 0 if endlinenum < len(clean_lines.elided): endline = clean_lines.elided[endlinenum] # We allow a mix of whitespace and closing braces (e.g. for one-liner # methods) and a single \ after the semicolon (for macros) endpos = endline.find(';') if not Match(r';[\s}]*(\\?)$', endline[endpos:]): # Semicolon isn't the last character, there's something trailing. # Output a warning if the semicolon is not contained inside # a lambda expression. if not Match(r'^[^{};]*\[[^\[\]]*\][^{}]*\{[^{}]*\}\s*\)*[;,]\s*$', endline): error(filename, linenum, 'readability/braces', 4, 'If/else bodies with multiple statements require braces') elif endlinenum < len(clean_lines.elided) - 1: # Make sure the next line is dedented next_line = clean_lines.elided[endlinenum + 1] next_indent = GetIndentLevel(next_line) # With ambiguous nested if statements, this will error out on the # if that *doesn't* match the else, regardless of whether it's the # inner one or outer one. if (if_match and Match(r'\s*else\b', next_line) and next_indent != if_indent): error(filename, linenum, 'readability/braces', 4, 'Else clause should be indented at the same level as if. ' 'Ambiguous nested if/else chains require braces.') elif next_indent > if_indent: error(filename, linenum, 'readability/braces', 4, 'If/else bodies with multiple statements require braces') def CheckTrailingSemicolon(filename, clean_lines, linenum, error): """Looks for redundant trailing semicolon. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # Block bodies should not be followed by a semicolon. Due to C++11 # brace initialization, there are more places where semicolons are # required than not, so we explicitly list the allowed rules rather # than listing the disallowed ones. These are the places where "};" # should be replaced by just "}": # 1. Some flavor of block following closing parenthesis: # for (;;) {}; # while (...) {}; # switch (...) {}; # Function(...) {}; # if (...) {}; # if (...) else if (...) {}; # # 2. else block: # if (...) else {}; # # 3. const member function: # Function(...) const {}; # # 4. Block following some statement: # x = 42; # {}; # # 5. Block at the beginning of a function: # Function(...) { # {}; # } # # Note that naively checking for the preceding "{" will also match # braces inside multi-dimensional arrays, but this is fine since # that expression will not contain semicolons. # # 6. Block following another block: # while (true) {} # {}; # # 7. End of namespaces: # namespace {}; # # These semicolons seems far more common than other kinds of # redundant semicolons, possibly due to people converting classes # to namespaces. For now we do not warn for this case. # # Try matching case 1 first. match = Match(r'^(.*\)\s*)\{', line) if match: # Matched closing parenthesis (case 1). Check the token before the # matching opening parenthesis, and don't warn if it looks like a # macro. This avoids these false positives: # - macro that defines a base class # - multi-line macro that defines a base class # - macro that defines the whole class-head # # But we still issue warnings for macros that we know are safe to # warn, specifically: # - TEST, TEST_F, TEST_P, MATCHER, MATCHER_P # - TYPED_TEST # - INTERFACE_DEF # - EXCLUSIVE_LOCKS_REQUIRED, SHARED_LOCKS_REQUIRED, LOCKS_EXCLUDED: # # We implement a list of safe macros instead of a list of # unsafe macros, even though the latter appears less frequently in # google code and would have been easier to implement. This is because # the downside for getting the allowed checks wrong means some extra # semicolons, while the downside for getting disallowed checks wrong # would result in compile errors. # # In addition to macros, we also don't want to warn on # - Compound literals # - Lambdas # - alignas specifier with anonymous structs # - decltype closing_brace_pos = match.group(1).rfind(')') opening_parenthesis = ReverseCloseExpression( clean_lines, linenum, closing_brace_pos) if opening_parenthesis[2] > -1: line_prefix = opening_parenthesis[0][0:opening_parenthesis[2]] macro = Search(r'\b([A-Z_][A-Z0-9_]*)\s*$', line_prefix) func = Match(r'^(.*\])\s*$', line_prefix) if ((macro and macro.group(1) not in ( 'TEST', 'TEST_F', 'MATCHER', 'MATCHER_P', 'TYPED_TEST', 'EXCLUSIVE_LOCKS_REQUIRED', 'SHARED_LOCKS_REQUIRED', 'LOCKS_EXCLUDED', 'INTERFACE_DEF')) or (func and not Search(r'\boperator\s*\[\s*\]', func.group(1))) or Search(r'\b(?:struct|union)\s+alignas\s*$', line_prefix) or Search(r'\bdecltype$', line_prefix) or Search(r'\s+=\s*$', line_prefix)): match = None if (match and opening_parenthesis[1] > 1 and Search(r'\]\s*$', clean_lines.elided[opening_parenthesis[1] - 1])): # Multi-line lambda-expression match = None else: # Try matching cases 2-3. match = Match(r'^(.*(?:else|\)\s*const)\s*)\{', line) if not match: # Try matching cases 4-6. These are always matched on separate lines. # # Note that we can't simply concatenate the previous line to the # current line and do a single match, otherwise we may output # duplicate warnings for the blank line case: # if (cond) { # // blank line # } prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] if prevline and Search(r'[;{}]\s*$', prevline): match = Match(r'^(\s*)\{', line) # Check matching closing brace if match: (endline, endlinenum, endpos) = CloseExpression( clean_lines, linenum, len(match.group(1))) if endpos > -1 and Match(r'^\s*;', endline[endpos:]): # Current {} pair is eligible for semicolon check, and we have found # the redundant semicolon, output warning here. # # Note: because we are scanning forward for opening braces, and # outputting warnings for the matching closing brace, if there are # nested blocks with trailing semicolons, we will get the error # messages in reversed order. # We need to check the line forward for NOLINT raw_lines = clean_lines.raw_lines ParseNolintSuppressions(filename, raw_lines[endlinenum-1], endlinenum-1, error) ParseNolintSuppressions(filename, raw_lines[endlinenum], endlinenum, error) error(filename, endlinenum, 'readability/braces', 4, "You don't need a ; after a }") def CheckEmptyBlockBody(filename, clean_lines, linenum, error): """Look for empty loop/conditional body with only a single semicolon. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ # Search for loop keywords at the beginning of the line. Because only # whitespaces are allowed before the keywords, this will also ignore most # do-while-loops, since those lines should start with closing brace. # # We also check "if" blocks here, since an empty conditional block # is likely an error. line = clean_lines.elided[linenum] matched = Match(r'\s*(for|while|if)\s*\(', line) if matched: # Find the end of the conditional expression. (end_line, end_linenum, end_pos) = CloseExpression( clean_lines, linenum, line.find('(')) # Output warning if what follows the condition expression is a semicolon. # No warning for all other cases, including whitespace or newline, since we # have a separate check for semicolons preceded by whitespace. if end_pos >= 0 and Match(r';', end_line[end_pos:]): if matched.group(1) == 'if': error(filename, end_linenum, 'whitespace/empty_conditional_body', 5, 'Empty conditional bodies should use {}') else: error(filename, end_linenum, 'whitespace/empty_loop_body', 5, 'Empty loop bodies should use {} or continue') # Check for if statements that have completely empty bodies (no comments) # and no else clauses. if end_pos >= 0 and matched.group(1) == 'if': # Find the position of the opening { for the if statement. # Return without logging an error if it has no brackets. opening_linenum = end_linenum opening_line_fragment = end_line[end_pos:] # Loop until EOF or find anything that's not whitespace or opening {. while not Search(r'^\s*\{', opening_line_fragment): if Search(r'^(?!\s*$)', opening_line_fragment): # Conditional has no brackets. return opening_linenum += 1 if opening_linenum == len(clean_lines.elided): # Couldn't find conditional's opening { or any code before EOF. return opening_line_fragment = clean_lines.elided[opening_linenum] # Set opening_line (opening_line_fragment may not be entire opening line). opening_line = clean_lines.elided[opening_linenum] # Find the position of the closing }. opening_pos = opening_line_fragment.find('{') if opening_linenum == end_linenum: # We need to make opening_pos relative to the start of the entire line. opening_pos += end_pos (closing_line, closing_linenum, closing_pos) = CloseExpression( clean_lines, opening_linenum, opening_pos) if closing_pos < 0: return # Now construct the body of the conditional. This consists of the portion # of the opening line after the {, all lines until the closing line, # and the portion of the closing line before the }. if (clean_lines.raw_lines[opening_linenum] != CleanseComments(clean_lines.raw_lines[opening_linenum])): # Opening line ends with a comment, so conditional isn't empty. return if closing_linenum > opening_linenum: # Opening line after the {. Ignore comments here since we checked above. bodylist = list(opening_line[opening_pos+1:]) # All lines until closing line, excluding closing line, with comments. bodylist.extend(clean_lines.raw_lines[opening_linenum+1:closing_linenum]) # Closing line before the }. Won't (and can't) have comments. bodylist.append(clean_lines.elided[closing_linenum][:closing_pos-1]) body = '\n'.join(bodylist) else: # If statement has brackets and fits on a single line. body = opening_line[opening_pos+1:closing_pos-1] # Check if the body is empty if not _EMPTY_CONDITIONAL_BODY_PATTERN.search(body): return # The body is empty. Now make sure there's not an else clause. current_linenum = closing_linenum current_line_fragment = closing_line[closing_pos:] # Loop until EOF or find anything that's not whitespace or else clause. while Search(r'^\s*$|^(?=\s*else)', current_line_fragment): if Search(r'^(?=\s*else)', current_line_fragment): # Found an else clause, so don't log an error. return current_linenum += 1 if current_linenum == len(clean_lines.elided): break current_line_fragment = clean_lines.elided[current_linenum] # The body is empty and there's no else clause until EOF or other code. error(filename, end_linenum, 'whitespace/empty_if_body', 4, ('If statement had no body and no else clause')) def FindCheckMacro(line): """Find a replaceable CHECK-like macro. Args: line: line to search on. Returns: (macro name, start position), or (None, -1) if no replaceable macro is found. """ for macro in _CHECK_MACROS: i = line.find(macro) if i >= 0: # Find opening parenthesis. Do a regular expression match here # to make sure that we are matching the expected CHECK macro, as # opposed to some other macro that happens to contain the CHECK # substring. matched = Match(r'^(.*\b' + macro + r'\s*)\(', line) if not matched: continue return (macro, len(matched.group(1))) return (None, -1) def CheckCheck(filename, clean_lines, linenum, error): """Checks the use of CHECK and EXPECT macros. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ # Decide the set of replacement macros that should be suggested lines = clean_lines.elided (check_macro, start_pos) = FindCheckMacro(lines[linenum]) if not check_macro: return # Find end of the boolean expression by matching parentheses (last_line, end_line, end_pos) = CloseExpression( clean_lines, linenum, start_pos) if end_pos < 0: return # If the check macro is followed by something other than a # semicolon, assume users will log their own custom error messages # and don't suggest any replacements. if not Match(r'\s*;', last_line[end_pos:]): return if linenum == end_line: expression = lines[linenum][start_pos + 1:end_pos - 1] else: expression = lines[linenum][start_pos + 1:] for i in xrange(linenum + 1, end_line): expression += lines[i] expression += last_line[0:end_pos - 1] # Parse expression so that we can take parentheses into account. # This avoids false positives for inputs like "CHECK((a < 4) == b)", # which is not replaceable by CHECK_LE. lhs = '' rhs = '' operator = None while expression: matched = Match(r'^\s*(<<|<<=|>>|>>=|->\*|->|&&|\|\||' r'==|!=|>=|>|<=|<|\()(.*)$', expression) if matched: token = matched.group(1) if token == '(': # Parenthesized operand expression = matched.group(2) (end, _) = FindEndOfExpressionInLine(expression, 0, ['(']) if end < 0: return # Unmatched parenthesis lhs += '(' + expression[0:end] expression = expression[end:] elif token in ('&&', '||'): # Logical and/or operators. This means the expression # contains more than one term, for example: # CHECK(42 < a && a < b); # # These are not replaceable with CHECK_LE, so bail out early. return elif token in ('<<', '<<=', '>>', '>>=', '->*', '->'): # Non-relational operator lhs += token expression = matched.group(2) else: # Relational operator operator = token rhs = matched.group(2) break else: # Unparenthesized operand. Instead of appending to lhs one character # at a time, we do another regular expression match to consume several # characters at once if possible. Trivial benchmark shows that this # is more efficient when the operands are longer than a single # character, which is generally the case. matched = Match(r'^([^-=!<>()&|]+)(.*)$', expression) if not matched: matched = Match(r'^(\s*\S)(.*)$', expression) if not matched: break lhs += matched.group(1) expression = matched.group(2) # Only apply checks if we got all parts of the boolean expression if not (lhs and operator and rhs): return # Check that rhs do not contain logical operators. We already know # that lhs is fine since the loop above parses out && and ||. if rhs.find('&&') > -1 or rhs.find('||') > -1: return # At least one of the operands must be a constant literal. This is # to avoid suggesting replacements for unprintable things like # CHECK(variable != iterator) # # The following pattern matches decimal, hex integers, strings, and # characters (in that order). lhs = lhs.strip() rhs = rhs.strip() match_constant = r'^([-+]?(\d+|0[xX][0-9a-fA-F]+)[lLuU]{0,3}|".*"|\'.*\')$' if Match(match_constant, lhs) or Match(match_constant, rhs): # Note: since we know both lhs and rhs, we can provide a more # descriptive error message like: # Consider using CHECK_EQ(x, 42) instead of CHECK(x == 42) # Instead of: # Consider using CHECK_EQ instead of CHECK(a == b) # # We are still keeping the less descriptive message because if lhs # or rhs gets long, the error message might become unreadable. error(filename, linenum, 'readability/check', 2, 'Consider using %s instead of %s(a %s b)' % ( _CHECK_REPLACEMENT[check_macro][operator], check_macro, operator)) def CheckAltTokens(filename, clean_lines, linenum, error): """Check alternative keywords being used in boolean expressions. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # Avoid preprocessor lines if Match(r'^\s*#', line): return # Last ditch effort to avoid multi-line comments. This will not help # if the comment started before the current line or ended after the # current line, but it catches most of the false positives. At least, # it provides a way to workaround this warning for people who use # multi-line comments in preprocessor macros. # # TODO(unknown): remove this once cpplint has better support for # multi-line comments. if line.find('/*') >= 0 or line.find('*/') >= 0: return for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line): error(filename, linenum, 'readability/alt_tokens', 2, 'Use operator %s instead of %s' % ( _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) def GetLineWidth(line): """Determines the width of the line in column positions. Args: line: A string, which may be a Unicode string. Returns: The width of the line in column positions, accounting for Unicode combining characters and wide characters. """ if isinstance(line, unicode): width = 0 for uc in unicodedata.normalize('NFC', line): if unicodedata.east_asian_width(uc) in ('W', 'F'): width += 2 elif not unicodedata.combining(uc): # Issue 337 # https://mail.python.org/pipermail/python-list/2012-August/628809.html if (sys.version_info.major, sys.version_info.minor) <= (3, 2): # https://github.com/python/cpython/blob/2.7/Include/unicodeobject.h#L81 is_wide_build = sysconfig.get_config_var("Py_UNICODE_SIZE") >= 4 # https://github.com/python/cpython/blob/2.7/Objects/unicodeobject.c#L564 is_low_surrogate = 0xDC00 <= ord(uc) <= 0xDFFF if not is_wide_build and is_low_surrogate: width -= 1 width += 1 return width else: return len(line) def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, error): """Checks rules from the 'C++ style rules' section of cppguide.html. Most of these rules are hard to test (naming, comment style), but we do what we can. In particular we check for 2-space indents, line lengths, tab usage, spaces inside code, etc. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. file_extension: The extension (without the dot) of the filename. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found. """ # Don't use "elided" lines here, otherwise we can't check commented lines. # Don't want to use "raw" either, because we don't want to check inside C++11 # raw strings, raw_lines = clean_lines.lines_without_raw_strings line = raw_lines[linenum] prev = raw_lines[linenum - 1] if linenum > 0 else '' if line.find('\t') != -1: error(filename, linenum, 'whitespace/tab', 1, 'Tab found; better to use spaces') # One or three blank spaces at the beginning of the line is weird; it's # hard to reconcile that with 2-space indents. # NOTE: here are the conditions rob pike used for his tests. Mine aren't # as sophisticated, but it may be worth becoming so: RLENGTH==initial_spaces # if(RLENGTH > 20) complain = 0; # if(match($0, " +(error|private|public|protected):")) complain = 0; # if(match(prev, "&& *$")) complain = 0; # if(match(prev, "\\|\\| *$")) complain = 0; # if(match(prev, "[\",=><] *$")) complain = 0; # if(match($0, " <<")) complain = 0; # if(match(prev, " +for \\(")) complain = 0; # if(prevodd && match(prevprev, " +for \\(")) complain = 0; scope_or_label_pattern = r'\s*(?:public|private|protected|signals)(?:\s+(?:slots\s*)?)?:\s*\\?$' classinfo = nesting_state.InnermostClass() initial_spaces = 0 cleansed_line = clean_lines.elided[linenum] while initial_spaces < len(line) and line[initial_spaces] == ' ': initial_spaces += 1 # There are certain situations we allow one space, notably for # section labels, and also lines containing multi-line raw strings. # We also don't check for lines that look like continuation lines # (of lines ending in double quotes, commas, equals, or angle brackets) # because the rules for how to indent those are non-trivial. if (not Search(r'[",=><] *$', prev) and (initial_spaces == 1 or initial_spaces == 3) and not Match(scope_or_label_pattern, cleansed_line) and not (clean_lines.raw_lines[linenum] != line and Match(r'^\s*""', line))): error(filename, linenum, 'whitespace/indent', 3, 'Weird number of spaces at line-start. ' 'Are you using a 2-space indent?') if line and line[-1].isspace(): error(filename, linenum, 'whitespace/end_of_line', 4, 'Line ends in whitespace. Consider deleting these extra spaces.') # Check if the line is a header guard. is_header_guard = False if IsHeaderExtension(file_extension): cppvar = GetHeaderGuardCPPVariable(filename) if (line.startswith('#ifndef %s' % cppvar) or line.startswith('#define %s' % cppvar) or line.startswith('#endif // %s' % cppvar)): is_header_guard = True # #include lines and header guards can be long, since there's no clean way to # split them. # # URLs can be long too. It's possible to split these, but it makes them # harder to cut&paste. # # The "$Id:...$" comment may also get very long without it being the # developers fault. # # Doxygen documentation copying can get pretty long when using an overloaded # function declaration if (not line.startswith('#include') and not is_header_guard and not Match(r'^\s*//.*http(s?)://\S*$', line) and not Match(r'^\s*//\s*[^\s]*$', line) and not Match(r'^// \$Id:.*#[0-9]+ \$$', line) and not Match(r'^\s*/// [@\\](copydoc|copydetails|copybrief) .*$', line)): line_width = GetLineWidth(line) if line_width > _line_length: error(filename, linenum, 'whitespace/line_length', 2, 'Lines should be <= %i characters long' % _line_length) if (cleansed_line.count(';') > 1 and # allow simple single line lambdas not Match(r'^[^{};]*\[[^\[\]]*\][^{}]*\{[^{}\n\r]*\}', line) and # for loops are allowed two ;'s (and may run over two lines). cleansed_line.find('for') == -1 and (GetPreviousNonBlankLine(clean_lines, linenum)[0].find('for') == -1 or GetPreviousNonBlankLine(clean_lines, linenum)[0].find(';') != -1) and # It's ok to have many commands in a switch case that fits in 1 line not ((cleansed_line.find('case ') != -1 or cleansed_line.find('default:') != -1) and cleansed_line.find('break;') != -1)): error(filename, linenum, 'whitespace/newline', 0, 'More than one command on the same line') # Some more style checks CheckBraces(filename, clean_lines, linenum, error) CheckTrailingSemicolon(filename, clean_lines, linenum, error) CheckEmptyBlockBody(filename, clean_lines, linenum, error) CheckSpacing(filename, clean_lines, linenum, nesting_state, error) CheckOperatorSpacing(filename, clean_lines, linenum, error) CheckParenthesisSpacing(filename, clean_lines, linenum, error) CheckCommaSpacing(filename, clean_lines, linenum, error) CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error) CheckSpacingForFunctionCall(filename, clean_lines, linenum, error) CheckCheck(filename, clean_lines, linenum, error) CheckAltTokens(filename, clean_lines, linenum, error) classinfo = nesting_state.InnermostClass() if classinfo: CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error) _RE_PATTERN_INCLUDE = re.compile(r'^\s*#\s*include\s*([<"])([^>"]*)[>"].*$') # Matches the first component of a filename delimited by -s and _s. That is: # _RE_FIRST_COMPONENT.match('foo').group(0) == 'foo' # _RE_FIRST_COMPONENT.match('foo.cc').group(0) == 'foo' # _RE_FIRST_COMPONENT.match('foo-bar_baz.cc').group(0) == 'foo' # _RE_FIRST_COMPONENT.match('foo_bar-baz.cc').group(0) == 'foo' _RE_FIRST_COMPONENT = re.compile(r'^[^-_.]+') def _DropCommonSuffixes(filename): """Drops common suffixes like _test.cc or -inl.h from filename. For example: >>> _DropCommonSuffixes('foo/foo-inl.h') 'foo/foo' >>> _DropCommonSuffixes('foo/bar/foo.cc') 'foo/bar/foo' >>> _DropCommonSuffixes('foo/foo_internal.h') 'foo/foo' >>> _DropCommonSuffixes('foo/foo_unusualinternal.h') 'foo/foo_unusualinternal' Args: filename: The input filename. Returns: The filename with the common suffix removed. """ for suffix in itertools.chain( ('%s.%s' % (test_suffix.lstrip('_'), ext) for test_suffix, ext in itertools.product(_test_suffixes, GetNonHeaderExtensions())), ('%s.%s' % (suffix, ext) for suffix, ext in itertools.product(['inl', 'imp', 'internal'], GetHeaderExtensions()))): if (filename.endswith(suffix) and len(filename) > len(suffix) and filename[-len(suffix) - 1] in ('-', '_')): return filename[:-len(suffix) - 1] return os.path.splitext(filename)[0] def _ClassifyInclude(fileinfo, include, used_angle_brackets, include_order="default"): """Figures out what kind of header 'include' is. Args: fileinfo: The current file cpplint is running over. A FileInfo instance. include: The path to a #included file. used_angle_brackets: True if the #include used <> rather than "". include_order: "default" or other value allowed in program arguments Returns: One of the _XXX_HEADER constants. For example: >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'stdio.h', True) _C_SYS_HEADER >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'string', True) _CPP_SYS_HEADER >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/foo.h', True, "standardcfirst") _OTHER_SYS_HEADER >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/foo.h', False) _LIKELY_MY_HEADER >>> _ClassifyInclude(FileInfo('foo/foo_unknown_extension.cc'), ... 'bar/foo_other_ext.h', False) _POSSIBLE_MY_HEADER >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/bar.h', False) _OTHER_HEADER """ # This is a list of all standard c++ header files, except # those already checked for above. is_cpp_header = include in _CPP_HEADERS # Mark include as C header if in list or in a known folder for standard-ish C headers. is_std_c_header = (include_order == "default") or (include in _C_HEADERS # additional linux glibc header folders or Search(r'(?:%s)\/.*\.h' % "|".join(C_STANDARD_HEADER_FOLDERS), include)) # Headers with C++ extensions shouldn't be considered C system headers is_system = used_angle_brackets and not os.path.splitext(include)[1] in ['.hpp', '.hxx', '.h++'] if is_system: if is_cpp_header: return _CPP_SYS_HEADER if is_std_c_header: return _C_SYS_HEADER else: return _OTHER_SYS_HEADER # If the target file and the include we're checking share a # basename when we drop common extensions, and the include # lives in . , then it's likely to be owned by the target file. target_dir, target_base = ( os.path.split(_DropCommonSuffixes(fileinfo.RepositoryName()))) include_dir, include_base = os.path.split(_DropCommonSuffixes(include)) target_dir_pub = os.path.normpath(target_dir + '/../public') target_dir_pub = target_dir_pub.replace('\\', '/') if target_base == include_base and ( include_dir == target_dir or include_dir == target_dir_pub): return _LIKELY_MY_HEADER # If the target and include share some initial basename # component, it's possible the target is implementing the # include, so it's allowed to be first, but we'll never # complain if it's not there. target_first_component = _RE_FIRST_COMPONENT.match(target_base) include_first_component = _RE_FIRST_COMPONENT.match(include_base) if (target_first_component and include_first_component and target_first_component.group(0) == include_first_component.group(0)): return _POSSIBLE_MY_HEADER return _OTHER_HEADER def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): """Check rules that are applicable to #include lines. Strings on #include lines are NOT removed from elided line, to make certain tasks easier. However, to prevent false positives, checks applicable to #include lines in CheckLanguage must be put here. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. include_state: An _IncludeState instance in which the headers are inserted. error: The function to call with any errors found. """ fileinfo = FileInfo(filename) line = clean_lines.lines[linenum] # "include" should use the new style "foo/bar.h" instead of just "bar.h" # Only do this check if the included header follows google naming # conventions. If not, assume that it's a 3rd party API that # requires special include conventions. # # We also make an exception for Lua headers, which follow google # naming convention but not the include convention. match = Match(r'#include\s*"([^/]+\.h)"', line) if match and not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1)): error(filename, linenum, 'build/include_subdir', 4, 'Include the directory when naming .h files') # we shouldn't include a file more than once. actually, there are a # handful of instances where doing so is okay, but in general it's # not. match = _RE_PATTERN_INCLUDE.search(line) if match: include = match.group(2) used_angle_brackets = (match.group(1) == '<') duplicate_line = include_state.FindHeader(include) if duplicate_line >= 0: error(filename, linenum, 'build/include', 4, '"%s" already included at %s:%s' % (include, filename, duplicate_line)) return for extension in GetNonHeaderExtensions(): if (include.endswith('.' + extension) and os.path.dirname(fileinfo.RepositoryName()) != os.path.dirname(include)): error(filename, linenum, 'build/include', 4, 'Do not include .' + extension + ' files from other packages') return # We DO want to include a 3rd party looking header if it matches the # filename. Otherwise we get an erroneous error "...should include its # header" error later. third_src_header = False for ext in GetHeaderExtensions(): basefilename = filename[0:len(filename) - len(fileinfo.Extension())] headerfile = basefilename + '.' + ext headername = FileInfo(headerfile).RepositoryName() if headername in include or include in headername: third_src_header = True break if third_src_header or not _THIRD_PARTY_HEADERS_PATTERN.match(include): include_state.include_list[-1].append((include, linenum)) # We want to ensure that headers appear in the right order: # 1) for foo.cc, foo.h (preferred location) # 2) c system files # 3) cpp system files # 4) for foo.cc, foo.h (deprecated location) # 5) other google headers # # We classify each include statement as one of those 5 types # using a number of techniques. The include_state object keeps # track of the highest type seen, and complains if we see a # lower type after that. error_message = include_state.CheckNextIncludeOrder( _ClassifyInclude(fileinfo, include, used_angle_brackets, _include_order)) if error_message: error(filename, linenum, 'build/include_order', 4, '%s. Should be: %s.h, c system, c++ system, other.' % (error_message, fileinfo.BaseName())) canonical_include = include_state.CanonicalizeAlphabeticalOrder(include) if not include_state.IsInAlphabeticalOrder( clean_lines, linenum, canonical_include): error(filename, linenum, 'build/include_alpha', 4, 'Include "%s" not in alphabetical order' % include) include_state.SetLastHeader(canonical_include) def _GetTextInside(text, start_pattern): r"""Retrieves all the text between matching open and close parentheses. Given a string of lines and a regular expression string, retrieve all the text following the expression and between opening punctuation symbols like (, [, or {, and the matching close-punctuation symbol. This properly nested occurrences of the punctuations, so for the text like printf(a(), b(c())); a call to _GetTextInside(text, r'printf\(') will return 'a(), b(c())'. start_pattern must match string having an open punctuation symbol at the end. Args: text: The lines to extract text. Its comments and strings must be elided. It can be single line and can span multiple lines. start_pattern: The regexp string indicating where to start extracting the text. Returns: The extracted text. None if either the opening string or ending punctuation could not be found. """ # TODO(unknown): Audit cpplint.py to see what places could be profitably # rewritten to use _GetTextInside (and use inferior regexp matching today). # Give opening punctuations to get the matching close-punctuations. matching_punctuation = {'(': ')', '{': '}', '[': ']'} closing_punctuation = set(itervalues(matching_punctuation)) # Find the position to start extracting text. match = re.search(start_pattern, text, re.M) if not match: # start_pattern not found in text. return None start_position = match.end(0) assert start_position > 0, ( 'start_pattern must ends with an opening punctuation.') assert text[start_position - 1] in matching_punctuation, ( 'start_pattern must ends with an opening punctuation.') # Stack of closing punctuations we expect to have in text after position. punctuation_stack = [matching_punctuation[text[start_position - 1]]] position = start_position while punctuation_stack and position < len(text): if text[position] == punctuation_stack[-1]: punctuation_stack.pop() elif text[position] in closing_punctuation: # A closing punctuation without matching opening punctuations. return None elif text[position] in matching_punctuation: punctuation_stack.append(matching_punctuation[text[position]]) position += 1 if punctuation_stack: # Opening punctuations left without matching close-punctuations. return None # punctuations match. return text[start_position:position - 1] # Patterns for matching call-by-reference parameters. # # Supports nested templates up to 2 levels deep using this messy pattern: # < (?: < (?: < [^<>]* # > # | [^<>] )* # > # | [^<>] )* # > _RE_PATTERN_IDENT = r'[_a-zA-Z]\w*' # =~ [[:alpha:]][[:alnum:]]* _RE_PATTERN_TYPE = ( r'(?:const\s+)?(?:typename\s+|class\s+|struct\s+|union\s+|enum\s+)?' r'(?:\w|' r'\s*<(?:<(?:<[^<>]*>|[^<>])*>|[^<>])*>|' r'::)+') # A call-by-reference parameter ends with '& identifier'. _RE_PATTERN_REF_PARAM = re.compile( r'(' + _RE_PATTERN_TYPE + r'(?:\s*(?:\bconst\b|[*]))*\s*' r'&\s*' + _RE_PATTERN_IDENT + r')\s*(?:=[^,()]+)?[,)]') # A call-by-const-reference parameter either ends with 'const& identifier' # or looks like 'const type& identifier' when 'type' is atomic. _RE_PATTERN_CONST_REF_PARAM = ( r'(?:.*\s*\bconst\s*&\s*' + _RE_PATTERN_IDENT + r'|const\s+' + _RE_PATTERN_TYPE + r'\s*&\s*' + _RE_PATTERN_IDENT + r')') # Stream types. _RE_PATTERN_REF_STREAM_PARAM = ( r'(?:.*stream\s*&\s*' + _RE_PATTERN_IDENT + r')') def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, nesting_state, error): """Checks rules from the 'C++ language rules' section of cppguide.html. Some of these rules are hard to test (function overloading, using uint32 inappropriately), but we do the best we can. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. file_extension: The extension (without the dot) of the filename. include_state: An _IncludeState instance in which the headers are inserted. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found. """ # If the line is empty or consists of entirely a comment, no need to # check it. line = clean_lines.elided[linenum] if not line: return match = _RE_PATTERN_INCLUDE.search(line) if match: CheckIncludeLine(filename, clean_lines, linenum, include_state, error) return # Reset include state across preprocessor directives. This is meant # to silence warnings for conditional includes. match = Match(r'^\s*#\s*(if|ifdef|ifndef|elif|else|endif)\b', line) if match: include_state.ResetSection(match.group(1)) # Perform other checks now that we are sure that this is not an include line CheckCasts(filename, clean_lines, linenum, error) CheckGlobalStatic(filename, clean_lines, linenum, error) CheckPrintf(filename, clean_lines, linenum, error) if IsHeaderExtension(file_extension): # TODO(unknown): check that 1-arg constructors are explicit. # How to tell it's a constructor? # (handled in CheckForNonStandardConstructs for now) # TODO(unknown): check that classes declare or disable copy/assign # (level 1 error) pass # Check if people are using the verboten C basic types. The only exception # we regularly allow is "unsigned short port" for port. if Search(r'\bshort port\b', line): if not Search(r'\bunsigned short port\b', line): error(filename, linenum, 'runtime/int', 4, 'Use "unsigned short" for ports, not "short"') else: match = Search(r'\b(short|long(?! +double)|long long)\b', line) if match: error(filename, linenum, 'runtime/int', 4, 'Use int16/int64/etc, rather than the C type %s' % match.group(1)) # Check if some verboten operator overloading is going on # TODO(unknown): catch out-of-line unary operator&: # class X {}; # int operator&(const X& x) { return 42; } // unary operator& # The trick is it's hard to tell apart from binary operator&: # class Y { int operator&(const Y& x) { return 23; } }; // binary operator& if Search(r'\boperator\s*&\s*\(\s*\)', line): error(filename, linenum, 'runtime/operator', 4, 'Unary operator& is dangerous. Do not use it.') # Check for suspicious usage of "if" like # } if (a == b) { if Search(r'\}\s*if\s*\(', line): error(filename, linenum, 'readability/braces', 4, 'Did you mean "else if"? If not, start a new line for "if".') # Check for potential format string bugs like printf(foo). # We constrain the pattern not to pick things like DocidForPrintf(foo). # Not perfect but it can catch printf(foo.c_str()) and printf(foo->c_str()) # TODO(unknown): Catch the following case. Need to change the calling # convention of the whole function to process multiple line to handle it. # printf( # boy_this_is_a_really_long_variable_that_cannot_fit_on_the_prev_line); printf_args = _GetTextInside(line, r'(?i)\b(string)?printf\s*\(') if printf_args: match = Match(r'([\w.\->()]+)$', printf_args) if match and match.group(1) != '__VA_ARGS__': function_name = re.search(r'\b((?:string)?printf)\s*\(', line, re.I).group(1) error(filename, linenum, 'runtime/printf', 4, 'Potential format string bug. Do %s("%%s", %s) instead.' % (function_name, match.group(1))) # Check for potential memset bugs like memset(buf, sizeof(buf), 0). match = Search(r'memset\s*\(([^,]*),\s*([^,]*),\s*0\s*\)', line) if match and not Match(r"^''|-?[0-9]+|0x[0-9A-Fa-f]$", match.group(2)): error(filename, linenum, 'runtime/memset', 4, 'Did you mean "memset(%s, 0, %s)"?' % (match.group(1), match.group(2))) # Check for 'using namespace' which pollutes namespaces. # This is tricky. Although in general 'using namespace' is a Bad Thing, # an exception is made for certain standard namespaces, like std::*literals # and std::placeholders, which are intended to be used in this fashion. # This whitelist may grow over time as needed if/when shiny new libraries # come along that are well-behaved in a 'using namespace' context. # For example, 'using namespace std::chrono_literals;' is allowed, but # 'using namespace foo;' is not allowed. # Note that headers are not permitted to use this exception. match = Search(r'\busing namespace\s+((\w|::)+)', line) if match: whitelist = [ 'std::chrono_literals', 'std::complex_literals', 'std::literals', 'std::literals::chrono_literals', 'std::literals::complex_literals', 'std::literals::string_literals', 'std::placeholders', 'std::string_literals', ] if IsHeaderExtension(file_extension) or match.group(1) not in whitelist: error(filename, linenum, 'build/namespaces', 5, 'Do not use namespace using-directives. ' 'Use using-declarations instead.') # Detect variable-length arrays. match = Match(r'\s*(.+::)?(\w+) [a-z]\w*\[(.+)];', line) if (match and match.group(2) != 'return' and match.group(2) != 'delete' and match.group(3).find(']') == -1): # Split the size using space and arithmetic operators as delimiters. # If any of the resulting tokens are not compile time constants then # report the error. tokens = re.split(r'\s|\+|\-|\*|\/|<<|>>]', match.group(3)) is_const = True skip_next = False for tok in tokens: if skip_next: skip_next = False continue if Search(r'sizeof\(.+\)', tok): continue if Search(r'arraysize\(\w+\)', tok): continue tok = tok.lstrip('(') tok = tok.rstrip(')') if not tok: continue if Match(r'\d+', tok): continue if Match(r'0[xX][0-9a-fA-F]+', tok): continue if Match(r'k[A-Z0-9]\w*', tok): continue if Match(r'(.+::)?k[A-Z0-9]\w*', tok): continue if Match(r'(.+::)?[A-Z][A-Z0-9_]*', tok): continue # A catch all for tricky sizeof cases, including 'sizeof expression', # 'sizeof(*type)', 'sizeof(const type)', 'sizeof(struct StructName)' # requires skipping the next token because we split on ' ' and '*'. if tok.startswith('sizeof'): skip_next = True continue is_const = False break if not is_const: error(filename, linenum, 'runtime/arrays', 1, 'Do not use variable-length arrays. Use an appropriately named ' "('k' followed by CamelCase) compile-time constant for the size.") # Check for use of unnamed namespaces in header files. Registration # macros are typically OK, so we allow use of "namespace {" on lines # that end with backslashes. if (IsHeaderExtension(file_extension) and Search(r'\bnamespace\s*{', line) and line[-1] != '\\'): error(filename, linenum, 'build/namespaces_headers', 4, 'Do not use unnamed namespaces in header files. See ' 'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' ' for more information.') def CheckGlobalStatic(filename, clean_lines, linenum, error): """Check for unsafe global or static objects. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # Match two lines at a time to support multiline declarations if linenum + 1 < clean_lines.NumLines() and not Search(r'[;({]', line): line += clean_lines.elided[linenum + 1].strip() # Check for people declaring static/global STL strings at the top level. # This is dangerous because the C++ language does not guarantee that # globals with constructors are initialized before the first access, and # also because globals can be destroyed when some threads are still running. # TODO(unknown): Generalize this to also find static unique_ptr instances. # TODO(unknown): File bugs for clang-tidy to find these. match = Match( r'((?:|static +)(?:|const +))(?::*std::)?string( +const)? +' r'([a-zA-Z0-9_:]+)\b(.*)', line) # Remove false positives: # - String pointers (as opposed to values). # string *pointer # const string *pointer # string const *pointer # string *const pointer # # - Functions and template specializations. # string Function(... # string Class::Method(... # # - Operators. These are matched separately because operator names # cross non-word boundaries, and trying to match both operators # and functions at the same time would decrease accuracy of # matching identifiers. # string Class::operator*() if (match and not Search(r'\bstring\b(\s+const)?\s*[\*\&]\s*(const\s+)?\w', line) and not Search(r'\boperator\W', line) and not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)*\s*\(([^"]|$)', match.group(4))): if Search(r'\bconst\b', line): error(filename, linenum, 'runtime/string', 4, 'For a static/global string constant, use a C style string ' 'instead: "%schar%s %s[]".' % (match.group(1), match.group(2) or '', match.group(3))) else: error(filename, linenum, 'runtime/string', 4, 'Static/global string variables are not permitted.') if (Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line) or Search(r'\b([A-Za-z0-9_]*_)\(CHECK_NOTNULL\(\1\)\)', line)): error(filename, linenum, 'runtime/init', 4, 'You seem to be initializing a member variable with itself.') def CheckPrintf(filename, clean_lines, linenum, error): """Check for printf related issues. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # When snprintf is used, the second argument shouldn't be a literal. match = Search(r'snprintf\s*\(([^,]*),\s*([0-9]*)\s*,', line) if match and match.group(2) != '0': # If 2nd arg is zero, snprintf is used to calculate size. error(filename, linenum, 'runtime/printf', 3, 'If you can, use sizeof(%s) instead of %s as the 2nd arg ' 'to snprintf.' % (match.group(1), match.group(2))) # Check if some verboten C functions are being used. if Search(r'\bsprintf\s*\(', line): error(filename, linenum, 'runtime/printf', 5, 'Never use sprintf. Use snprintf instead.') match = Search(r'\b(strcpy|strcat)\s*\(', line) if match: error(filename, linenum, 'runtime/printf', 4, 'Almost always, snprintf is better than %s' % match.group(1)) def IsDerivedFunction(clean_lines, linenum): """Check if current line contains an inherited function. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line contains a function with "override" virt-specifier. """ # Scan back a few lines for start of current function for i in xrange(linenum, max(-1, linenum - 10), -1): match = Match(r'^([^()]*\w+)\(', clean_lines.elided[i]) if match: # Look for "override" after the matching closing parenthesis line, _, closing_paren = CloseExpression( clean_lines, i, len(match.group(1))) return (closing_paren >= 0 and Search(r'\boverride\b', line[closing_paren:])) return False def IsOutOfLineMethodDefinition(clean_lines, linenum): """Check if current line contains an out-of-line method definition. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line contains an out-of-line method definition. """ # Scan back a few lines for start of current function for i in xrange(linenum, max(-1, linenum - 10), -1): if Match(r'^([^()]*\w+)\(', clean_lines.elided[i]): return Match(r'^[^()]*\w+::\w+\(', clean_lines.elided[i]) is not None return False def IsInitializerList(clean_lines, linenum): """Check if current line is inside constructor initializer list. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line appears to be inside constructor initializer list, False otherwise. """ for i in xrange(linenum, 1, -1): line = clean_lines.elided[i] if i == linenum: remove_function_body = Match(r'^(.*)\{\s*$', line) if remove_function_body: line = remove_function_body.group(1) if Search(r'\s:\s*\w+[({]', line): # A lone colon tend to indicate the start of a constructor # initializer list. It could also be a ternary operator, which # also tend to appear in constructor initializer lists as # opposed to parameter lists. return True if Search(r'\}\s*,\s*$', line): # A closing brace followed by a comma is probably the end of a # brace-initialized member in constructor initializer list. return True if Search(r'[{};]\s*$', line): # Found one of the following: # - A closing brace or semicolon, probably the end of the previous # function. # - An opening brace, probably the start of current class or namespace. # # Current line is probably not inside an initializer list since # we saw one of those things without seeing the starting colon. return False # Got to the beginning of the file without seeing the start of # constructor initializer list. return False def CheckForNonConstReference(filename, clean_lines, linenum, nesting_state, error): """Check for non-const references. Separate from CheckLanguage since it scans backwards from current line, instead of scanning forward. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found. """ # Do nothing if there is no '&' on current line. line = clean_lines.elided[linenum] if '&' not in line: return # If a function is inherited, current function doesn't have much of # a choice, so any non-const references should not be blamed on # derived function. if IsDerivedFunction(clean_lines, linenum): return # Don't warn on out-of-line method definitions, as we would warn on the # in-line declaration, if it isn't marked with 'override'. if IsOutOfLineMethodDefinition(clean_lines, linenum): return # Long type names may be broken across multiple lines, usually in one # of these forms: # LongType # ::LongTypeContinued &identifier # LongType:: # LongTypeContinued &identifier # LongType< # ...>::LongTypeContinued &identifier # # If we detected a type split across two lines, join the previous # line to current line so that we can match const references # accordingly. # # Note that this only scans back one line, since scanning back # arbitrary number of lines would be expensive. If you have a type # that spans more than 2 lines, please use a typedef. if linenum > 1: previous = None if Match(r'\s*::(?:[\w<>]|::)+\s*&\s*\S', line): # previous_line\n + ::current_line previous = Search(r'\b((?:const\s*)?(?:[\w<>]|::)+[\w<>])\s*$', clean_lines.elided[linenum - 1]) elif Match(r'\s*[a-zA-Z_]([\w<>]|::)+\s*&\s*\S', line): # previous_line::\n + current_line previous = Search(r'\b((?:const\s*)?(?:[\w<>]|::)+::)\s*$', clean_lines.elided[linenum - 1]) if previous: line = previous.group(1) + line.lstrip() else: # Check for templated parameter that is split across multiple lines endpos = line.rfind('>') if endpos > -1: (_, startline, startpos) = ReverseCloseExpression( clean_lines, linenum, endpos) if startpos > -1 and startline < linenum: # Found the matching < on an earlier line, collect all # pieces up to current line. line = '' for i in xrange(startline, linenum + 1): line += clean_lines.elided[i].strip() # Check for non-const references in function parameters. A single '&' may # found in the following places: # inside expression: binary & for bitwise AND # inside expression: unary & for taking the address of something # inside declarators: reference parameter # We will exclude the first two cases by checking that we are not inside a # function body, including one that was just introduced by a trailing '{'. # TODO(unknown): Doesn't account for 'catch(Exception& e)' [rare]. if (nesting_state.previous_stack_top and not (isinstance(nesting_state.previous_stack_top, _ClassInfo) or isinstance(nesting_state.previous_stack_top, _NamespaceInfo))): # Not at toplevel, not within a class, and not within a namespace return # Avoid initializer lists. We only need to scan back from the # current line for something that starts with ':'. # # We don't need to check the current line, since the '&' would # appear inside the second set of parentheses on the current line as # opposed to the first set. if linenum > 0: for i in xrange(linenum - 1, max(0, linenum - 10), -1): previous_line = clean_lines.elided[i] if not Search(r'[),]\s*$', previous_line): break if Match(r'^\s*:\s+\S', previous_line): return # Avoid preprocessors if Search(r'\\\s*$', line): return # Avoid constructor initializer lists if IsInitializerList(clean_lines, linenum): return # We allow non-const references in a few standard places, like functions # called "swap()" or iostream operators like "<<" or ">>". Do not check # those function parameters. # # We also accept & in static_assert, which looks like a function but # it's actually a declaration expression. allowed_functions = (r'(?:[sS]wap(?:<\w:+>)?|' r'operator\s*[<>][<>]|' r'static_assert|COMPILE_ASSERT' r')\s*\(') if Search(allowed_functions, line): return elif not Search(r'\S+\([^)]*$', line): # Don't see an allowed function on this line. Actually we # didn't see any function name on this line, so this is likely a # multi-line parameter list. Try a bit harder to catch this case. for i in xrange(2): if (linenum > i and Search(allowed_functions, clean_lines.elided[linenum - i - 1])): return decls = ReplaceAll(r'{[^}]*}', ' ', line) # exclude function body for parameter in re.findall(_RE_PATTERN_REF_PARAM, decls): if (not Match(_RE_PATTERN_CONST_REF_PARAM, parameter) and not Match(_RE_PATTERN_REF_STREAM_PARAM, parameter)): error(filename, linenum, 'runtime/references', 2, 'Is this a non-const reference? ' 'If so, make const or use a pointer: ' + ReplaceAll(' *<', '<', parameter)) def CheckCasts(filename, clean_lines, linenum, error): """Various cast related checks. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] # Check to see if they're using an conversion function cast. # I just try to capture the most common basic types, though there are more. # Parameterless conversion functions, such as bool(), are allowed as they are # probably a member operator declaration or default constructor. match = Search( r'(\bnew\s+(?:const\s+)?|\S<\s*(?:const\s+)?)?\b' r'(int|float|double|bool|char|int32|uint32|int64|uint64)' r'(\([^)].*)', line) expecting_function = ExpectingFunctionArgs(clean_lines, linenum) if match and not expecting_function: matched_type = match.group(2) # matched_new_or_template is used to silence two false positives: # - New operators # - Template arguments with function types # # For template arguments, we match on types immediately following # an opening bracket without any spaces. This is a fast way to # silence the common case where the function type is the first # template argument. False negative with less-than comparison is # avoided because those operators are usually followed by a space. # # function // bracket + no space = false positive # value < double(42) // bracket + space = true positive matched_new_or_template = match.group(1) # Avoid arrays by looking for brackets that come after the closing # parenthesis. if Match(r'\([^()]+\)\s*\[', match.group(3)): return # Other things to ignore: # - Function pointers # - Casts to pointer types # - Placement new # - Alias declarations matched_funcptr = match.group(3) if (matched_new_or_template is None and not (matched_funcptr and (Match(r'\((?:[^() ]+::\s*\*\s*)?[^() ]+\)\s*\(', matched_funcptr) or matched_funcptr.startswith('(*)'))) and not Match(r'\s*using\s+\S+\s*=\s*' + matched_type, line) and not Search(r'new\(\S+\)\s*' + matched_type, line)): error(filename, linenum, 'readability/casting', 4, 'Using deprecated casting style. ' 'Use static_cast<%s>(...) instead' % matched_type) if not expecting_function: CheckCStyleCast(filename, clean_lines, linenum, 'static_cast', r'\((int|float|double|bool|char|u?int(16|32|64)|size_t)\)', error) # This doesn't catch all cases. Consider (const char * const)"hello". # # (char *) "foo" should always be a const_cast (reinterpret_cast won't # compile). if CheckCStyleCast(filename, clean_lines, linenum, 'const_cast', r'\((char\s?\*+\s?)\)\s*"', error): pass else: # Check pointer casts for other than string constants CheckCStyleCast(filename, clean_lines, linenum, 'reinterpret_cast', r'\((\w+\s?\*+\s?)\)', error) # In addition, we look for people taking the address of a cast. This # is dangerous -- casts can assign to temporaries, so the pointer doesn't # point where you think. # # Some non-identifier character is required before the '&' for the # expression to be recognized as a cast. These are casts: # expression = &static_cast(temporary()); # function(&(int*)(temporary())); # # This is not a cast: # reference_type&(int* function_param); match = Search( r'(?:[^\w]&\(([^)*][^)]*)\)[\w(])|' r'(?:[^\w]&(static|dynamic|down|reinterpret)_cast\b)', line) if match: # Try a better error message when the & is bound to something # dereferenced by the casted pointer, as opposed to the casted # pointer itself. parenthesis_error = False match = Match(r'^(.*&(?:static|dynamic|down|reinterpret)_cast\b)<', line) if match: _, y1, x1 = CloseExpression(clean_lines, linenum, len(match.group(1))) if x1 >= 0 and clean_lines.elided[y1][x1] == '(': _, y2, x2 = CloseExpression(clean_lines, y1, x1) if x2 >= 0: extended_line = clean_lines.elided[y2][x2:] if y2 < clean_lines.NumLines() - 1: extended_line += clean_lines.elided[y2 + 1] if Match(r'\s*(?:->|\[)', extended_line): parenthesis_error = True if parenthesis_error: error(filename, linenum, 'readability/casting', 4, ('Are you taking an address of something dereferenced ' 'from a cast? Wrapping the dereferenced expression in ' 'parentheses will make the binding more obvious')) else: error(filename, linenum, 'runtime/casting', 4, ('Are you taking an address of a cast? ' 'This is dangerous: could be a temp var. ' 'Take the address before doing the cast, rather than after')) def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error): """Checks for a C-style cast by looking for the pattern. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. cast_type: The string for the C++ cast to recommend. This is either reinterpret_cast, static_cast, or const_cast, depending. pattern: The regular expression used to find C-style casts. error: The function to call with any errors found. Returns: True if an error was emitted. False otherwise. """ line = clean_lines.elided[linenum] match = Search(pattern, line) if not match: return False # Exclude lines with keywords that tend to look like casts context = line[0:match.start(1) - 1] if Match(r'.*\b(?:sizeof|alignof|alignas|[_A-Z][_A-Z0-9]*)\s*$', context): return False # Try expanding current context to see if we one level of # parentheses inside a macro. if linenum > 0: for i in xrange(linenum - 1, max(0, linenum - 5), -1): context = clean_lines.elided[i] + context if Match(r'.*\b[_A-Z][_A-Z0-9]*\s*\((?:\([^()]*\)|[^()])*$', context): return False # operator++(int) and operator--(int) if context.endswith(' operator++') or context.endswith(' operator--'): return False # A single unnamed argument for a function tends to look like old style cast. # If we see those, don't issue warnings for deprecated casts. remainder = line[match.end(0):] if Match(r'^\s*(?:;|const\b|throw\b|final\b|override\b|[=>{),]|->)', remainder): return False # Don't warn in C files about C-style casts if os.path.splitext(filename)[1] in ['.c', '.h']: return False # At this point, all that should be left is actual casts. error(filename, linenum, 'readability/casting', 4, 'Using C-style cast. Use %s<%s>(...) instead' % (cast_type, match.group(1))) return True def ExpectingFunctionArgs(clean_lines, linenum): """Checks whether where function type arguments are expected. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if the line at 'linenum' is inside something that expects arguments of function types. """ line = clean_lines.elided[linenum] return (Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line) or (linenum >= 2 and (Match(r'^\s*MOCK_(?:CONST_)?METHOD\d+(?:_T)?\((?:\S+,)?\s*$', clean_lines.elided[linenum - 1]) or Match(r'^\s*MOCK_(?:CONST_)?METHOD\d+(?:_T)?\(\s*$', clean_lines.elided[linenum - 2]) or Search(r'\bstd::m?function\s*\<\s*$', clean_lines.elided[linenum - 1])))) _HEADERS_CONTAINING_TEMPLATES = ( ('', ('deque',)), ('', ('unary_function', 'binary_function', 'plus', 'minus', 'multiplies', 'divides', 'modulus', 'negate', 'equal_to', 'not_equal_to', 'greater', 'less', 'greater_equal', 'less_equal', 'logical_and', 'logical_or', 'logical_not', 'unary_negate', 'not1', 'binary_negate', 'not2', 'bind1st', 'bind2nd', 'pointer_to_unary_function', 'pointer_to_binary_function', 'ptr_fun', 'mem_fun_t', 'mem_fun', 'mem_fun1_t', 'mem_fun1_ref_t', 'mem_fun_ref_t', 'const_mem_fun_t', 'const_mem_fun1_t', 'const_mem_fun_ref_t', 'const_mem_fun1_ref_t', 'mem_fun_ref', )), ('', ('numeric_limits',)), ('', ('list',)), ('', ('multimap',)), ('', ('allocator', 'make_shared', 'make_unique', 'shared_ptr', 'unique_ptr', 'weak_ptr')), ('', ('queue', 'priority_queue',)), ('', ('multiset',)), ('', ('stack',)), ('', ('char_traits', 'basic_string',)), ('', ('tuple',)), ('', ('unordered_map', 'unordered_multimap')), ('', ('unordered_set', 'unordered_multiset')), ('', ('pair',)), ('', ('vector',)), # gcc extensions. # Note: std::hash is their hash, ::hash is our hash ('', ('hash_map', 'hash_multimap',)), ('', ('hash_set', 'hash_multiset',)), ('', ('slist',)), ) _HEADERS_MAYBE_TEMPLATES = ( ('', ('copy', 'max', 'min', 'min_element', 'sort', 'transform', )), ('', ('forward', 'make_pair', 'move', 'swap')), ) _RE_PATTERN_STRING = re.compile(r'\bstring\b') _re_pattern_headers_maybe_templates = [] for _header, _templates in _HEADERS_MAYBE_TEMPLATES: for _template in _templates: # Match max(..., ...), max(..., ...), but not foo->max, foo.max or # 'type::max()'. _re_pattern_headers_maybe_templates.append( (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'), _template, _header)) # Match set, but not foo->set, foo.set _re_pattern_headers_maybe_templates.append( (re.compile(r'[^>.]\bset\s*\<'), 'set<>', '')) # Match 'map var' and 'std::map(...)', but not 'map(...)'' _re_pattern_headers_maybe_templates.append( (re.compile(r'(std\b::\bmap\s*\<)|(^(std\b::\b)map\b\(\s*\<)'), 'map<>', '')) # Other scripts may reach in and modify this pattern. _re_pattern_templates = [] for _header, _templates in _HEADERS_CONTAINING_TEMPLATES: for _template in _templates: _re_pattern_templates.append( (re.compile(r'(\<|\b)' + _template + r'\s*\<'), _template + '<>', _header)) def FilesBelongToSameModule(filename_cc, filename_h): """Check if these two filenames belong to the same module. The concept of a 'module' here is a as follows: foo.h, foo-inl.h, foo.cc, foo_test.cc and foo_unittest.cc belong to the same 'module' if they are in the same directory. some/path/public/xyzzy and some/path/internal/xyzzy are also considered to belong to the same module here. If the filename_cc contains a longer path than the filename_h, for example, '/absolute/path/to/base/sysinfo.cc', and this file would include 'base/sysinfo.h', this function also produces the prefix needed to open the header. This is used by the caller of this function to more robustly open the header file. We don't have access to the real include paths in this context, so we need this guesswork here. Known bugs: tools/base/bar.cc and base/bar.h belong to the same module according to this implementation. Because of this, this function gives some false positives. This should be sufficiently rare in practice. Args: filename_cc: is the path for the source (e.g. .cc) file filename_h: is the path for the header path Returns: Tuple with a bool and a string: bool: True if filename_cc and filename_h belong to the same module. string: the additional prefix needed to open the header file. """ fileinfo_cc = FileInfo(filename_cc) if not fileinfo_cc.Extension().lstrip('.') in GetNonHeaderExtensions(): return (False, '') fileinfo_h = FileInfo(filename_h) if not IsHeaderExtension(fileinfo_h.Extension().lstrip('.')): return (False, '') filename_cc = filename_cc[:-(len(fileinfo_cc.Extension()))] matched_test_suffix = Search(_TEST_FILE_SUFFIX, fileinfo_cc.BaseName()) if matched_test_suffix: filename_cc = filename_cc[:-len(matched_test_suffix.group(1))] filename_cc = filename_cc.replace('/public/', '/') filename_cc = filename_cc.replace('/internal/', '/') filename_h = filename_h[:-(len(fileinfo_h.Extension()))] if filename_h.endswith('-inl'): filename_h = filename_h[:-len('-inl')] filename_h = filename_h.replace('/public/', '/') filename_h = filename_h.replace('/internal/', '/') files_belong_to_same_module = filename_cc.endswith(filename_h) common_path = '' if files_belong_to_same_module: common_path = filename_cc[:-len(filename_h)] return files_belong_to_same_module, common_path def UpdateIncludeState(filename, include_dict, io=codecs): """Fill up the include_dict with new includes found from the file. Args: filename: the name of the header to read. include_dict: a dictionary in which the headers are inserted. io: The io factory to use to read the file. Provided for testability. Returns: True if a header was successfully added. False otherwise. """ headerfile = None try: with io.open(filename, 'r', 'utf8', 'replace') as headerfile: linenum = 0 for line in headerfile: linenum += 1 clean_line = CleanseComments(line) match = _RE_PATTERN_INCLUDE.search(clean_line) if match: include = match.group(2) include_dict.setdefault(include, linenum) return True except IOError: return False def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, io=codecs): """Reports for missing stl includes. This function will output warnings to make sure you are including the headers necessary for the stl containers and functions that you use. We only give one reason to include a header. For example, if you use both equal_to<> and less<> in a .h file, only one (the latter in the file) of these will be reported as a reason to include the . Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. include_state: An _IncludeState instance. error: The function to call with any errors found. io: The IO factory to use to read the header file. Provided for unittest injection. """ required = {} # A map of header name to linenumber and the template entity. # Example of required: { '': (1219, 'less<>') } for linenum in xrange(clean_lines.NumLines()): line = clean_lines.elided[linenum] if not line or line[0] == '#': continue # String is special -- it is a non-templatized type in STL. matched = _RE_PATTERN_STRING.search(line) if matched: # Don't warn about strings in non-STL namespaces: # (We check only the first match per line; good enough.) prefix = line[:matched.start()] if prefix.endswith('std::') or not prefix.endswith('::'): required[''] = (linenum, 'string') for pattern, template, header in _re_pattern_headers_maybe_templates: if pattern.search(line): required[header] = (linenum, template) # The following function is just a speed up, no semantics are changed. if not '<' in line: # Reduces the cpu time usage by skipping lines. continue for pattern, template, header in _re_pattern_templates: matched = pattern.search(line) if matched: # Don't warn about IWYU in non-STL namespaces: # (We check only the first match per line; good enough.) prefix = line[:matched.start()] if prefix.endswith('std::') or not prefix.endswith('::'): required[header] = (linenum, template) # The policy is that if you #include something in foo.h you don't need to # include it again in foo.cc. Here, we will look at possible includes. # Let's flatten the include_state include_list and copy it into a dictionary. include_dict = dict([item for sublist in include_state.include_list for item in sublist]) # Did we find the header for this file (if any) and successfully load it? header_found = False # Use the absolute path so that matching works properly. abs_filename = FileInfo(filename).FullName() # For Emacs's flymake. # If cpplint is invoked from Emacs's flymake, a temporary file is generated # by flymake and that file name might end with '_flymake.cc'. In that case, # restore original file name here so that the corresponding header file can be # found. # e.g. If the file name is 'foo_flymake.cc', we should search for 'foo.h' # instead of 'foo_flymake.h' abs_filename = re.sub(r'_flymake\.cc$', '.cc', abs_filename) # include_dict is modified during iteration, so we iterate over a copy of # the keys. header_keys = list(include_dict.keys()) for header in header_keys: (same_module, common_path) = FilesBelongToSameModule(abs_filename, header) fullpath = common_path + header if same_module and UpdateIncludeState(fullpath, include_dict, io): header_found = True # If we can't find the header file for a .cc, assume it's because we don't # know where to look. In that case we'll give up as we're not sure they # didn't include it in the .h file. # TODO(unknown): Do a better job of finding .h files so we are confident that # not having the .h file means there isn't one. if not header_found: for extension in GetNonHeaderExtensions(): if filename.endswith('.' + extension): return # All the lines have been processed, report the errors found. for required_header_unstripped in sorted(required, key=required.__getitem__): template = required[required_header_unstripped][1] if required_header_unstripped.strip('<>"') not in include_dict: error(filename, required[required_header_unstripped][0], 'build/include_what_you_use', 4, 'Add #include ' + required_header_unstripped + ' for ' + template) _RE_PATTERN_EXPLICIT_MAKEPAIR = re.compile(r'\bmake_pair\s*<') def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error): """Check that make_pair's template arguments are deduced. G++ 4.6 in C++11 mode fails badly if make_pair's template arguments are specified explicitly, and such use isn't intended in any case. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] match = _RE_PATTERN_EXPLICIT_MAKEPAIR.search(line) if match: error(filename, linenum, 'build/explicit_make_pair', 4, # 4 = high confidence 'For C++11-compatibility, omit template arguments from make_pair' ' OR use pair directly OR if appropriate, construct a pair directly') def CheckRedundantVirtual(filename, clean_lines, linenum, error): """Check if line contains a redundant "virtual" function-specifier. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ # Look for "virtual" on current line. line = clean_lines.elided[linenum] virtual = Match(r'^(.*)(\bvirtual\b)(.*)$', line) if not virtual: return # Ignore "virtual" keywords that are near access-specifiers. These # are only used in class base-specifier and do not apply to member # functions. if (Search(r'\b(public|protected|private)\s+$', virtual.group(1)) or Match(r'^\s+(public|protected|private)\b', virtual.group(3))): return # Ignore the "virtual" keyword from virtual base classes. Usually # there is a column on the same line in these cases (virtual base # classes are rare in google3 because multiple inheritance is rare). if Match(r'^.*[^:]:[^:].*$', line): return # Look for the next opening parenthesis. This is the start of the # parameter list (possibly on the next line shortly after virtual). # TODO(unknown): doesn't work if there are virtual functions with # decltype() or other things that use parentheses, but csearch suggests # that this is rare. end_col = -1 end_line = -1 start_col = len(virtual.group(2)) for start_line in xrange(linenum, min(linenum + 3, clean_lines.NumLines())): line = clean_lines.elided[start_line][start_col:] parameter_list = Match(r'^([^(]*)\(', line) if parameter_list: # Match parentheses to find the end of the parameter list (_, end_line, end_col) = CloseExpression( clean_lines, start_line, start_col + len(parameter_list.group(1))) break start_col = 0 if end_col < 0: return # Couldn't find end of parameter list, give up # Look for "override" or "final" after the parameter list # (possibly on the next few lines). for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())): line = clean_lines.elided[i][end_col:] match = Search(r'\b(override|final)\b', line) if match: error(filename, linenum, 'readability/inheritance', 4, ('"virtual" is redundant since function is ' 'already declared as "%s"' % match.group(1))) # Set end_col to check whole lines after we are done with the # first line. end_col = 0 if Search(r'[^\w]\s*$', line): break def CheckRedundantOverrideOrFinal(filename, clean_lines, linenum, error): """Check if line contains a redundant "override" or "final" virt-specifier. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ # Look for closing parenthesis nearby. We need one to confirm where # the declarator ends and where the virt-specifier starts to avoid # false positives. line = clean_lines.elided[linenum] declarator_end = line.rfind(')') if declarator_end >= 0: fragment = line[declarator_end:] else: if linenum > 1 and clean_lines.elided[linenum - 1].rfind(')') >= 0: fragment = line else: return # Check that at most one of "override" or "final" is present, not both if Search(r'\boverride\b', fragment) and Search(r'\bfinal\b', fragment): error(filename, linenum, 'readability/inheritance', 4, ('"override" is redundant since function is ' 'already declared as "final"')) # Returns true if we are at a new block, and it is directly # inside of a namespace. def IsBlockInNameSpace(nesting_state, is_forward_declaration): """Checks that the new block is directly in a namespace. Args: nesting_state: The _NestingState object that contains info about our state. is_forward_declaration: If the class is a forward declared class. Returns: Whether or not the new block is directly in a namespace. """ if is_forward_declaration: return len(nesting_state.stack) >= 1 and ( isinstance(nesting_state.stack[-1], _NamespaceInfo)) return (len(nesting_state.stack) > 1 and nesting_state.stack[-1].check_namespace_indentation and isinstance(nesting_state.stack[-2], _NamespaceInfo)) def ShouldCheckNamespaceIndentation(nesting_state, is_namespace_indent_item, raw_lines_no_comments, linenum): """This method determines if we should apply our namespace indentation check. Args: nesting_state: The current nesting state. is_namespace_indent_item: If we just put a new class on the stack, True. If the top of the stack is not a class, or we did not recently add the class, False. raw_lines_no_comments: The lines without the comments. linenum: The current line number we are processing. Returns: True if we should apply our namespace indentation check. Currently, it only works for classes and namespaces inside of a namespace. """ is_forward_declaration = IsForwardClassDeclaration(raw_lines_no_comments, linenum) if not (is_namespace_indent_item or is_forward_declaration): return False # If we are in a macro, we do not want to check the namespace indentation. if IsMacroDefinition(raw_lines_no_comments, linenum): return False return IsBlockInNameSpace(nesting_state, is_forward_declaration) # Call this method if the line is directly inside of a namespace. # If the line above is blank (excluding comments) or the start of # an inner namespace, it cannot be indented. def CheckItemIndentationInNamespace(filename, raw_lines_no_comments, linenum, error): line = raw_lines_no_comments[linenum] if Match(r'^\s+', line): error(filename, linenum, 'runtime/indentation_namespace', 4, 'Do not indent within a namespace') def ProcessLine(filename, file_extension, clean_lines, line, include_state, function_state, nesting_state, error, extra_check_functions=None): """Processes a single line in the file. Args: filename: Filename of the file that is being processed. file_extension: The extension (dot not included) of the file. clean_lines: An array of strings, each representing a line of the file, with comments stripped. line: Number of line being processed. include_state: An _IncludeState instance in which the headers are inserted. function_state: A _FunctionState instance which counts function lines, etc. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: A callable to which errors are reported, which takes 4 arguments: filename, line number, error level, and message extra_check_functions: An array of additional check functions that will be run on each source line. Each function takes 4 arguments: filename, clean_lines, line, error """ raw_lines = clean_lines.raw_lines ParseNolintSuppressions(filename, raw_lines[line], line, error) nesting_state.Update(filename, clean_lines, line, error) CheckForNamespaceIndentation(filename, nesting_state, clean_lines, line, error) if nesting_state.InAsmBlock(): return CheckForFunctionLengths(filename, clean_lines, line, function_state, error) CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error) CheckStyle(filename, clean_lines, line, file_extension, nesting_state, error) CheckLanguage(filename, clean_lines, line, file_extension, include_state, nesting_state, error) CheckForNonConstReference(filename, clean_lines, line, nesting_state, error) CheckForNonStandardConstructs(filename, clean_lines, line, nesting_state, error) CheckVlogArguments(filename, clean_lines, line, error) CheckPosixThreading(filename, clean_lines, line, error) CheckInvalidIncrement(filename, clean_lines, line, error) CheckMakePairUsesDeduction(filename, clean_lines, line, error) CheckRedundantVirtual(filename, clean_lines, line, error) CheckRedundantOverrideOrFinal(filename, clean_lines, line, error) if extra_check_functions: for check_fn in extra_check_functions: check_fn(filename, clean_lines, line, error) def FlagCxx11Features(filename, clean_lines, linenum, error): """Flag those c++11 features that we only allow in certain places. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line) # Flag unapproved C++ TR1 headers. if include and include.group(1).startswith('tr1/'): error(filename, linenum, 'build/c++tr1', 5, ('C++ TR1 headers such as <%s> are unapproved.') % include.group(1)) # Flag unapproved C++11 headers. if include and include.group(1) in ('cfenv', 'condition_variable', 'fenv.h', 'future', 'mutex', 'thread', 'chrono', 'ratio', 'regex', 'system_error', ): error(filename, linenum, 'build/c++11', 5, ('<%s> is an unapproved C++11 header.') % include.group(1)) # The only place where we need to worry about C++11 keywords and library # features in preprocessor directives is in macro definitions. if Match(r'\s*#', line) and not Match(r'\s*#\s*define\b', line): return # These are classes and free functions. The classes are always # mentioned as std::*, but we only catch the free functions if # they're not found by ADL. They're alphabetical by header. for top_name in ( # type_traits 'alignment_of', 'aligned_union', ): if Search(r'\bstd::%s\b' % top_name, line): error(filename, linenum, 'build/c++11', 5, ('std::%s is an unapproved C++11 class or function. Send c-style ' 'an example of where it would make your code more readable, and ' 'they may let you use it.') % top_name) def FlagCxx14Features(filename, clean_lines, linenum, error): """Flag those C++14 features that we restrict. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ line = clean_lines.elided[linenum] include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line) # Flag unapproved C++14 headers. if include and include.group(1) in ('scoped_allocator', 'shared_mutex'): error(filename, linenum, 'build/c++14', 5, ('<%s> is an unapproved C++14 header.') % include.group(1)) def ProcessFileData(filename, file_extension, lines, error, extra_check_functions=None): """Performs lint checks and reports any errors to the given error function. Args: filename: Filename of the file that is being processed. file_extension: The extension (dot not included) of the file. lines: An array of strings, each representing a line of the file, with the last element being empty if the file is terminated with a newline. error: A callable to which errors are reported, which takes 4 arguments: filename, line number, error level, and message extra_check_functions: An array of additional check functions that will be run on each source line. Each function takes 4 arguments: filename, clean_lines, line, error """ lines = (['// marker so line numbers and indices both start at 1'] + lines + ['// marker so line numbers end in a known way']) include_state = _IncludeState() function_state = _FunctionState() nesting_state = NestingState() ResetNolintSuppressions() CheckForCopyright(filename, lines, error) ProcessGlobalSuppresions(lines) RemoveMultiLineComments(filename, lines, error) clean_lines = CleansedLines(lines) if IsHeaderExtension(file_extension): CheckForHeaderGuard(filename, clean_lines, error) for line in xrange(clean_lines.NumLines()): ProcessLine(filename, file_extension, clean_lines, line, include_state, function_state, nesting_state, error, extra_check_functions) FlagCxx11Features(filename, clean_lines, line, error) nesting_state.CheckCompletedBlocks(filename, error) CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) # Check that the .cc file has included its header if it exists. if _IsSourceExtension(file_extension): CheckHeaderFileIncluded(filename, include_state, error) # We check here rather than inside ProcessLine so that we see raw # lines rather than "cleaned" lines. CheckForBadCharacters(filename, lines, error) CheckForNewlineAtEOF(filename, lines, error) def ProcessConfigOverrides(filename): """ Loads the configuration files and processes the config overrides. Args: filename: The name of the file being processed by the linter. Returns: False if the current |filename| should not be processed further. """ abs_filename = os.path.abspath(filename) cfg_filters = [] keep_looking = True while keep_looking: abs_path, base_name = os.path.split(abs_filename) if not base_name: break # Reached the root directory. cfg_file = os.path.join(abs_path, "CPPLINT.cfg") abs_filename = abs_path if not os.path.isfile(cfg_file): continue try: with open(cfg_file) as file_handle: for line in file_handle: line, _, _ = line.partition('#') # Remove comments. if not line.strip(): continue name, _, val = line.partition('=') name = name.strip() val = val.strip() if name == 'set noparent': keep_looking = False elif name == 'filter': cfg_filters.append(val) elif name == 'exclude_files': # When matching exclude_files pattern, use the base_name of # the current file name or the directory name we are processing. # For example, if we are checking for lint errors in /foo/bar/baz.cc # and we found the .cfg file at /foo/CPPLINT.cfg, then the config # file's "exclude_files" filter is meant to be checked against "bar" # and not "baz" nor "bar/baz.cc". if base_name: pattern = re.compile(val) if pattern.match(base_name): if _cpplint_state.quiet: # Suppress "Ignoring file" warning when using --quiet. return False _cpplint_state.PrintInfo('Ignoring "%s": file excluded by "%s". ' 'File path component "%s" matches ' 'pattern "%s"\n' % (filename, cfg_file, base_name, val)) return False elif name == 'linelength': global _line_length try: _line_length = int(val) except ValueError: _cpplint_state.PrintError('Line length must be numeric.') elif name == 'extensions': ProcessExtensionsOption(val) elif name == 'root': global _root # root directories are specified relative to CPPLINT.cfg dir. _root = os.path.join(os.path.dirname(cfg_file), val) elif name == 'headers': ProcessHppHeadersOption(val) elif name == 'includeorder': ProcessIncludeOrderOption(val) else: _cpplint_state.PrintError( 'Invalid configuration option (%s) in file %s\n' % (name, cfg_file)) except IOError: _cpplint_state.PrintError( "Skipping config file '%s': Can't open for reading\n" % cfg_file) keep_looking = False # Apply all the accumulated filters in reverse order (top-level directory # config options having the least priority). for cfg_filter in reversed(cfg_filters): _AddFilters(cfg_filter) return True def ProcessFile(filename, vlevel, extra_check_functions=None): """Does google-lint on a single file. Args: filename: The name of the file to parse. vlevel: The level of errors to report. Every error of confidence >= verbose_level will be reported. 0 is a good default. extra_check_functions: An array of additional check functions that will be run on each source line. Each function takes 4 arguments: filename, clean_lines, line, error """ _SetVerboseLevel(vlevel) _BackupFilters() old_errors = _cpplint_state.error_count if not ProcessConfigOverrides(filename): _RestoreFilters() return lf_lines = [] crlf_lines = [] try: # Support the UNIX convention of using "-" for stdin. Note that # we are not opening the file with universal newline support # (which codecs doesn't support anyway), so the resulting lines do # contain trailing '\r' characters if we are reading a file that # has CRLF endings. # If after the split a trailing '\r' is present, it is removed # below. if filename == '-': lines = codecs.StreamReaderWriter(sys.stdin, codecs.getreader('utf8'), codecs.getwriter('utf8'), 'replace').read().split('\n') else: with codecs.open(filename, 'r', 'utf8', 'replace') as target_file: lines = target_file.read().split('\n') # Remove trailing '\r'. # The -1 accounts for the extra trailing blank line we get from split() for linenum in range(len(lines) - 1): if lines[linenum].endswith('\r'): lines[linenum] = lines[linenum].rstrip('\r') crlf_lines.append(linenum + 1) else: lf_lines.append(linenum + 1) except IOError: _cpplint_state.PrintError( "Skipping input '%s': Can't open for reading\n" % filename) _RestoreFilters() return # Note, if no dot is found, this will give the entire filename as the ext. file_extension = filename[filename.rfind('.') + 1:] # When reading from stdin, the extension is unknown, so no cpplint tests # should rely on the extension. if filename != '-' and file_extension not in GetAllExtensions(): _cpplint_state.PrintError('Ignoring %s; not a valid file name ' '(%s)\n' % (filename, ', '.join(GetAllExtensions()))) else: ProcessFileData(filename, file_extension, lines, Error, extra_check_functions) # If end-of-line sequences are a mix of LF and CR-LF, issue # warnings on the lines with CR. # # Don't issue any warnings if all lines are uniformly LF or CR-LF, # since critique can handle these just fine, and the style guide # doesn't dictate a particular end of line sequence. # # We can't depend on os.linesep to determine what the desired # end-of-line sequence should be, since that will return the # server-side end-of-line sequence. if lf_lines and crlf_lines: # Warn on every line with CR. An alternative approach might be to # check whether the file is mostly CRLF or just LF, and warn on the # minority, we bias toward LF here since most tools prefer LF. for linenum in crlf_lines: Error(filename, linenum, 'whitespace/newline', 1, 'Unexpected \\r (^M) found; better to use only \\n') # Suppress printing anything if --quiet was passed unless the error # count has increased after processing this file. if not _cpplint_state.quiet or old_errors != _cpplint_state.error_count: _cpplint_state.PrintInfo('Done processing %s\n' % filename) _RestoreFilters() def PrintUsage(message): """Prints a brief usage string and exits, optionally with an error message. Args: message: The optional error message. """ sys.stderr.write(_USAGE % (sorted(list(GetAllExtensions())), ','.join(sorted(list(GetAllExtensions()))), sorted(GetHeaderExtensions()), ','.join(sorted(GetHeaderExtensions())))) if message: sys.exit('\nFATAL ERROR: ' + message) else: sys.exit(0) def PrintVersion(): sys.stdout.write('Cpplint fork (https://github.com/cpplint/cpplint)\n') sys.stdout.write('cpplint ' + __VERSION__ + '\n') sys.stdout.write('Python ' + sys.version + '\n') sys.exit(0) def PrintCategories(): """Prints a list of all the error-categories used by error messages. These are the categories used to filter messages via --filter. """ sys.stderr.write(''.join(' %s\n' % cat for cat in _ERROR_CATEGORIES)) sys.exit(0) def ParseArguments(args): """Parses the command line arguments. This may set the output format and verbosity level as side-effects. Args: args: The command line arguments: Returns: The list of filenames to lint. """ try: (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', 'v=', 'version', 'counting=', 'filter=', 'root=', 'repository=', 'linelength=', 'extensions=', 'exclude=', 'recursive', 'headers=', 'includeorder=', 'quiet']) except getopt.GetoptError: PrintUsage('Invalid arguments.') verbosity = _VerboseLevel() output_format = _OutputFormat() filters = '' quiet = _Quiet() counting_style = '' recursive = False for (opt, val) in opts: if opt == '--help': PrintUsage(None) if opt == '--version': PrintVersion() elif opt == '--output': if val not in ('emacs', 'vs7', 'eclipse', 'junit', 'sed', 'gsed'): PrintUsage('The only allowed output formats are emacs, vs7, eclipse ' 'sed, gsed and junit.') output_format = val elif opt == '--quiet': quiet = True elif opt == '--verbose' or opt == '--v': verbosity = int(val) elif opt == '--filter': filters = val if not filters: PrintCategories() elif opt == '--counting': if val not in ('total', 'toplevel', 'detailed'): PrintUsage('Valid counting options are total, toplevel, and detailed') counting_style = val elif opt == '--root': global _root _root = val elif opt == '--repository': global _repository _repository = val elif opt == '--linelength': global _line_length try: _line_length = int(val) except ValueError: PrintUsage('Line length must be digits.') elif opt == '--exclude': global _excludes if not _excludes: _excludes = set() _excludes.update(glob.glob(val)) elif opt == '--extensions': ProcessExtensionsOption(val) elif opt == '--headers': ProcessHppHeadersOption(val) elif opt == '--recursive': recursive = True elif opt == '--includeorder': ProcessIncludeOrderOption(val) if not filenames: PrintUsage('No files were specified.') if recursive: filenames = _ExpandDirectories(filenames) if _excludes: filenames = _FilterExcludedFiles(filenames) _SetOutputFormat(output_format) _SetQuiet(quiet) _SetVerboseLevel(verbosity) _SetFilters(filters) _SetCountingStyle(counting_style) filenames.sort() return filenames def _ExpandDirectories(filenames): """Searches a list of filenames and replaces directories in the list with all files descending from those directories. Files with extensions not in the valid extensions list are excluded. Args: filenames: A list of files or directories Returns: A list of all files that are members of filenames or descended from a directory in filenames """ expanded = set() for filename in filenames: if not os.path.isdir(filename): expanded.add(filename) continue for root, _, files in os.walk(filename): for loopfile in files: fullname = os.path.join(root, loopfile) if fullname.startswith('.' + os.path.sep): fullname = fullname[len('.' + os.path.sep):] expanded.add(fullname) filtered = [] for filename in expanded: if os.path.splitext(filename)[1][1:] in GetAllExtensions(): filtered.append(filename) return filtered def _FilterExcludedFiles(fnames): """Filters out files listed in the --exclude command line switch. File paths in the switch are evaluated relative to the current working directory """ exclude_paths = [os.path.abspath(f) for f in _excludes] # because globbing does not work recursively, exclude all subpath of all excluded entries return [f for f in fnames if not any(e for e in exclude_paths if _IsParentOrSame(e, os.path.abspath(f)))] def _IsParentOrSame(parent, child): """Return true if child is subdirectory of parent. Assumes both paths are absolute and don't contain symlinks. """ parent = os.path.normpath(parent) child = os.path.normpath(child) if parent == child: return True prefix = os.path.commonprefix([parent, child]) if prefix != parent: return False # Note: os.path.commonprefix operates on character basis, so # take extra care of situations like '/foo/ba' and '/foo/bar/baz' child_suffix = child[len(prefix):] child_suffix = child_suffix.lstrip(os.sep) return child == os.path.join(prefix, child_suffix) def main(): filenames = ParseArguments(sys.argv[1:]) backup_err = sys.stderr try: # Change stderr to write with replacement characters so we don't die # if we try to print something containing non-ASCII characters. sys.stderr = codecs.StreamReader(sys.stderr, 'replace') _cpplint_state.ResetErrorCounts() for filename in filenames: ProcessFile(filename, _cpplint_state.verbose_level) # If --quiet is passed, suppress printing error count unless there are errors. if not _cpplint_state.quiet or _cpplint_state.error_count > 0: _cpplint_state.PrintErrorCounts() if _cpplint_state.output_format == 'junit': sys.stderr.write(_cpplint_state.FormatJUnitXML()) finally: sys.stderr = backup_err sys.exit(_cpplint_state.error_count > 0) if __name__ == '__main__': main() ament_lint-0.12.0/ament_cpplint/ament_cpplint/main.py000077500000000000000000000273371420377356500227470ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import glob import os import re import sys import time from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr from ament_cpplint import cpplint from ament_cpplint.cpplint import _cpplint_state from ament_cpplint.cpplint import ParseArguments from ament_cpplint.cpplint import ProcessFile # use custom header guard with two underscore between the name parts def custom_get_header_guard_cpp_variable(filename): from ament_cpplint.cpplint import _root from ament_cpplint.cpplint import FileInfo # Restores original filename in case that cpplint is invoked from Emacs's # flymake. filename = re.sub(r'_flymake\.h$', '.h', filename) filename = re.sub(r'/\.flymake/([^/]*)$', r'/\1', filename) # Replace 'c++' with 'cpp'. filename = filename.replace('C++', 'cpp').replace('c++', 'cpp') fileinfo = FileInfo(filename) file_path_from_root = fileinfo.RepositoryName() if _root: prefix = _root + os.sep # use consistent separator on Windows if os.sep != '/': prefix = prefix.replace(os.sep, '/') if file_path_from_root.startswith(prefix): file_path_from_root = file_path_from_root[len(prefix):] else: filename = filename.replace(os.sep, '/') if filename.startswith(prefix): file_path_from_root = filename[len(prefix):] # use double separator file_path_from_root = file_path_from_root.replace('/', '//') return re.sub(r'[^a-zA-Z0-9]', '_', file_path_from_root).upper() + '_' cpplint.GetHeaderGuardCPPVariable = custom_get_header_guard_cpp_variable def main(argv=sys.argv[1:]): extensions = ['c', 'cc', 'cpp', 'cxx'] headers = ['h', 'hh', 'hpp', 'hxx'] parser = argparse.ArgumentParser( description='Check code against the Google style conventions using ' 'cpplint.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '--filters', metavar='FILTER,FILTER,...', type=str, help='A comma separated list of category filters to apply') parser.add_argument( '--linelength', metavar='N', type=int, default=100, help='The maximum line length') parser.add_argument( '--root', type=str, help='The --root option for cpplint') parser.add_argument( '--exclude', default=[], nargs='*', help='Exclude C/C++ files from being checked.') parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files ending ' 'in %s will be considered.' % ', '.join(["'.%s'" % e for e in extensions + headers])) # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if args.xunit_file: start_time = time.time() argv = [] # collect category based counts argv.append('--counting=detailed') argv.append('--extensions=%s' % ','.join(extensions)) argv.append('--headers=%s' % ','.join(headers)) filters = [ # we do allow C++11 '-build/c++11', # we consider passing non-const references to be ok '-runtime/references', # we wrap open curly braces for namespaces, classes and functions '-whitespace/braces', # we don't indent keywords like public, protected and private with one space '-whitespace/indent', # we allow closing parenthesis to be on the next line '-whitespace/parens', # we allow the developer to decide about whitespace after a semicolon '-whitespace/semicolon', ] if args.filters: filters += args.filters.split(',') argv.append('--filter=%s' % ','.join(filters)) argv.append('--linelength=%d' % args.linelength) groups = get_file_groups(args.paths, extensions + headers, args.exclude) if not groups: print('No files found', file=sys.stderr) return 1 # hook into error reporting DefaultError = cpplint.Error # noqa: N806 report = [] # invoke cpplint for each root group of files _cpplint_state.ResetErrorCounts() for root in sorted(groups.keys()): files = groups[root] arguments = list(argv) if args.root: root = os.path.abspath(args.root) if root: root_arg = '--root=%s' % root arguments.append(root_arg) print("Using '%s' argument" % root_arg) else: print("Not using '--root'") print('') arguments += files filenames = ParseArguments(arguments) for filename in filenames: # hook into error reporting errors = [] def custom_error(filename, linenum, category, confidence, message): if cpplint._ShouldPrintError(category, confidence, linenum): errors.append({ 'linenum': linenum, 'category': category, 'confidence': confidence, 'message': message, }) DefaultError(filename, linenum, category, confidence, message) cpplint.Error = custom_error ProcessFile(filename, _cpplint_state.verbose_level) report.append((filename, errors)) print('') # output summary for category in sorted(_cpplint_state.errors_by_category.keys()): count = _cpplint_state.errors_by_category[category] print("Category '%s' errors found: %d" % (category, count), file=sys.stderr) if _cpplint_state.error_count: print('Total errors found: %d' % _cpplint_state.error_count, file=sys.stderr) else: print('No problems found') # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return 1 if _cpplint_state.error_count else 0 def get_file_groups(paths, extensions, exclude_patterns): excludes = [] for exclude_pattern in exclude_patterns: excludes.extend(glob.glob(exclude_pattern)) excludes = {os.path.realpath(x) for x in excludes} # dict mapping root path to files groups = {} for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] dirnames.sort() # select files by extension for filename in sorted(filenames): _, ext = os.path.splitext(filename) if ext in ('.%s' % e for e in extensions): filepath = os.path.join(dirpath, filename) if os.path.realpath(filepath) not in excludes: append_file_to_group(groups, filepath) if os.path.isfile(path): if os.path.realpath(path) not in excludes: append_file_to_group(groups, path) return groups def append_file_to_group(groups, path): path = os.path.abspath(path) root = '' # try to determine root from path base_path = os.path.dirname(path) # find longest subpath which ends with one of the following subfolder names subfolder_names = ['include', 'src', 'test'] matches = [ re.search( '^(.+%s%s)%s' % (re.escape(os.sep), re.escape(subfolder_name), re.escape(os.sep)), path) for subfolder_name in subfolder_names] match_groups = [match.group(1) for match in matches if match] if match_groups: match_groups = [{'group_len': len(x), 'group': x} for x in match_groups] sorted_groups = sorted(match_groups, key=lambda k: k['group_len']) base_path = sorted_groups[-1]['group'] root = base_path # try to find repository root repo_root = None p = path while p and repo_root is None: # abort if root is reached if os.path.dirname(p) == p: break p = os.path.dirname(p) for marker in ['.git', '.hg', '.svn']: if os.path.exists(os.path.join(p, marker)): repo_root = p break # compute relative --root argument if repo_root and repo_root > base_path: root = os.path.relpath(base_path, repo_root) # add the path to the appropriate group if root not in groups: groups[root] = [] groups[root].append(path) def get_xunit_content(report, testname, elapsed): test_count = sum(max(len(r[1]), 1) for r in report) error_count = sum(len(r[1]) for r in report) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for (filename, errors) in report: if errors: # report each cpplint error as a failing testcase for error in errors: data = { 'quoted_name': quoteattr( '%s [%s] (%s:%d)' % ( error['category'], error['confidence'], filename, error['linenum'])), 'testname': testname, 'quoted_message': quoteattr(error['message']), } xml += """ """ % data else: # if there are no cpplint errors report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % r[0] for r in report])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_cpplint/doc/000077500000000000000000000000001420377356500173425ustar00rootroot00000000000000ament_lint-0.12.0/ament_cpplint/doc/index.rst000066400000000000000000000012311420377356500212000ustar00rootroot00000000000000ament_cpplint ========== Checks the code style of C / C++ source files using `cpplint `_. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_cpplint [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_cpplint `_. ament_lint-0.12.0/ament_cpplint/package.xml000066400000000000000000000017171420377356500207200ustar00rootroot00000000000000 ament_cpplint 0.12.0 The ability to check code against the Google style conventions using cpplint and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 BSD Audrow Nash Claire Wang Dirk Thomas ament_copyright ament_flake8 ament_pep257 python3-pytest ament_python ament_lint-0.12.0/ament_cpplint/pytest.ini000066400000000000000000000000351420377356500206240ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_cpplint/resource/000077500000000000000000000000001420377356500204245ustar00rootroot00000000000000ament_lint-0.12.0/ament_cpplint/resource/ament_cpplint000066400000000000000000000000001420377356500231720ustar00rootroot00000000000000ament_lint-0.12.0/ament_cpplint/setup.py000066400000000000000000000025421420377356500203120ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_cpplint' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], zip_safe=True, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check C++ code style using cpplint.', long_description="""\ The ability to check code against the Google style conventions using cpplint and generate xUnit test result files.""", license='Apache License, Version 2.0, BSD', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_cpplint = ament_cpplint.main:main', ], }, ) ament_lint-0.12.0/ament_cpplint/test/000077500000000000000000000000001420377356500175545ustar00rootroot00000000000000ament_lint-0.12.0/ament_cpplint/test/test_copyright.py000066400000000000000000000015151420377356500231770ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_copyright.main import main import pytest @pytest.mark.copyright @pytest.mark.linter def test_copyright(): excluded = ['ament_cpplint/cpplint.py'] rc = main(argv=['--exclude'] + excluded) assert rc == 0, 'Found errors' ament_lint-0.12.0/ament_cpplint/test/test_flake8.py000066400000000000000000000016661420377356500223500ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): excluded = ['ament_cpplint/cpplint.py'] rc, errors = main_with_errors(argv=['--exclude'] + excluded) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_cpplint/test/test_pep257.py000066400000000000000000000015231420377356500222100ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pep257.main import main import pytest @pytest.mark.linter @pytest.mark.pep257 def test_pep257(): excluded = ['ament_cpplint/cpplint.py'] rc = main(argv=['--exclude'] + excluded) assert rc == 0, 'Found docblock style errors' ament_lint-0.12.0/ament_flake8/000077500000000000000000000000001420377356500162765ustar00rootroot00000000000000ament_lint-0.12.0/ament_flake8/CHANGELOG.rst000066400000000000000000000226451420377356500203300ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_flake8 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- * Remove use of distutils.version.LooseVersion. (`#346 `_) * Contributors: Chris Lalancette 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Ignore .*/_* dirs in ament_flake8 (`#335 `_) Other ament\_* linters specifically ignore directories starting with a dot or underscore when crawling for files to lint. They also do so implicitly, so this change mimics that same pattern so that the behavior is consistent. * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash, Scott K Logan 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- * Ignore flake8-blind-except B902 (`#292 `_) * Contributors: Scott K Logan 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Contributors: Audrow Nash 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ * support flake8 3.8 (`#242 `_) * Contributors: Dirk Thomas 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * add new main_with_errors() API that also returns the error strings if any (`#221 `_) * return custom int subclass to include the error strings * expose errors through separate function rather than magic return code object * Generate xunit files valid for the junit10.xsd (`#220 `_) * Exclude folders having AMENT_IGNORE in ament_flake8 script (`#211 `_) * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dirk Thomas, Hao Peng, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * Install manifest file in ament_flake8 (`#189 `_) Follow-up to `#185 `_ * re-add path insertion removed from wrong package (`#178 `_) * add mypy support for linters/testing (`#154 `_) * add mypy support for linters/testing * Update ament_cmake_mypy/doc/index.rst Co-Authored-By: Kyle Fazzari * fix whitespace in file and in generated xml * fixes, package versioning, and test suite * fix wrong separator in cmake file * readd copied from comment * Update ament_mypy/ament_mypy/main.py Co-Authored-By: Kyle Fazzari * remove mypypath auto populating * add default configuration ignoring missing imports * update test to remove MYPYPATH check, default config check * remove extraneous path insert statement * remove extraneous path insert statement * update test cases for default config file change * added tests for error code forwarding, fixed linter errors * linter failures relating to quotes and docs * add handling for notes * remove ament_lint dep * update regex to match drive letter on windows * Contributors: Scott K Logan, Ted Kern 0.7.4 (2019-07-31) ------------------ * declare pytest markers (`#164 `_) * declare pytest markers * add markers to ament_xmllint tests * Contributors: Dirk Thomas 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ * readd listener if available (`#141 `_) * Contributors: Dirk Thomas 0.7.1 (2019-05-07) ------------------ * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ * Remove make_notifier() call (`#124 `_) * use --extend-ignore for flake8 to keep default ignores (`#122 `_) * Contributors: Dirk Thomas, Shane Loretz 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ * Change spelling of maintainer name. (`#115 `_) This is causing failures in CI at the moment. Until I figure out where the issue lies let's just mispell it to unbreak CI. * Contributors: Steven! Ragnarök 0.6.1 (2018-11-15) ------------------ * Update maintainer for ament{,_cmake}_flake8. (`#114 `_) * Contributors: Steven! Ragnarök 0.6.0 (2018-11-14) ------------------ * Ignore flake8 W504 (`#110 `_) * Contributors: Jacob Perron 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ * level setup.py versions to 0.5.1 * Contributors: Mikael Arguedas 0.5.0 (2018-06-18 10:09) ------------------------ * set zip_safe to avoid warning during installation (`#96 `_) * Contributors: Dirk Thomas 0.4.0 (2017-12-08) ------------------ * remove test_suite, add pytest as test_requires * Add I202 to the list of ignored flake8 errors. (`#89 `_) I202 warns about newlines between groups of imports in python. A recent change in flake8 (https://github.com/PyCQA/flake8-import-order/commit/37dafcc35eec9343641d489ac01d316cd10a6c03) made this start showing up in ROS2. Since we use whitespace between imports in lots of places in ROS2, disable this warning, which should get rid of this error almost everywhere. * Adapt to flake8 v3.5.0 changes (`#88 `_) * Adapt to flake8 v3.5.0 changes * Add comment why this fork of get_style_guide exists * Add new D106, D107 linter errors to ignored list (`#86 `_) * Add new D107 linter error to ignored list * Ignore D106 also * 0.0.3 * Merge pull request `#84 `_ from ament/flake8_plugins update style to satisfy new flake8 plugins * update style to satisfy new flake8 plugins * implicitly inherit from object (only in files not copied from somewhe… (`#83 `_) * implicitly inherit from object (only in files not copied from somewhere else) * don't modify file copied from elsewhere * 0.0.2 * Merge pull request `#77 `_ from ament/fix_flake8_excludes fix --exclude with ament_flake8 * fix --exclude with ament_flake8 * Make get_error_type_counts work for legacy api too (`#70 `_) * Test python module import order using flake8 (`#63 `_) * Add flake8 linter * Don't deal with flake8-import-order just yet * Debugging prints * Reinstate import order rule * Fix reporting bug by using the inner flake8 style guide * Fixup * Add comment on wrapper StyleGuide use * use flake8 v3 (`#1 `_) * Reorder package.xml * Get the filenames from the file checkers because input_file isn't called by flake8 anymore * Output count of all error types * Get flake8 to use the config file The current implementation of get_style_guide does not process the config file correctly. * Error when flake8 v2 found * Print errors like pep8 * remove __future_\_ imports * add schema to manifest files * Support flake8 v2 as well as v3 * Output checked files otherwise it's not present in xunit files for tests run directly with nose (not ament_cmake_flake8) * Prevent v2 imports from happening on systems with v3 * Flake8 replaces pep8+pyflakes * Contributors: Chris Lalancette, Dirk Thomas, Mikael Arguedas, dhood ament_lint-0.12.0/ament_flake8/ament_flake8/000077500000000000000000000000001420377356500206345ustar00rootroot00000000000000ament_lint-0.12.0/ament_flake8/ament_flake8/__init__.py000066400000000000000000000000001420377356500227330ustar00rootroot00000000000000ament_lint-0.12.0/ament_flake8/ament_flake8/configuration/000077500000000000000000000000001420377356500235035ustar00rootroot00000000000000ament_lint-0.12.0/ament_flake8/ament_flake8/configuration/ament_flake8.ini000066400000000000000000000002651420377356500265450ustar00rootroot00000000000000[flake8] extend-ignore = B902,C816,D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404,I202 import-order-style = google max-line-length = 99 show-source = true statistics = true ament_lint-0.12.0/ament_flake8/ament_flake8/main.py000077500000000000000000000234111420377356500221360ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import os import sys import time from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr import flake8 from flake8.api.legacy import StyleGuide from flake8.main import application as flake8_app def main(argv=sys.argv[1:]): rc, _ = main_with_errors(argv=argv) return rc def main_with_errors(argv=sys.argv[1:]): config_file = os.path.join( os.path.dirname(__file__), 'configuration', 'ament_flake8.ini') parser = argparse.ArgumentParser( description='Check code using flake8.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '--config', metavar='path', default=config_file, dest='config_file', help='The config file') parser.add_argument( '--linelength', metavar='N', type=int, help='The maximum line length (default: specified in the config file)') parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files ending ' "in '.py' will be considered.") parser.add_argument( '--exclude', metavar='filename', nargs='*', dest='excludes', help='The filenames to exclude.') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if args.xunit_file: start_time = time.time() if not os.path.exists(args.config_file): print("Could not find config file '%s'" % args.config_file, file=sys.stderr) return 1 # Filter out folders having AMENT_IGNORE if args.excludes is None: args.excludes = [] for dirpath, dirnames, filenames in os.walk(os.getcwd()): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] args.excludes.append(dirpath) else: # ignore folder starting with . or _ args.excludes.extend(d for d in dirnames if d[0] in ['.', '_']) report = generate_flake8_report( args.config_file, args.paths, args.excludes, max_line_length=args.linelength) # print statistics about errors if report.total_errors: print('') report.print_statistics() # print summary print('') print('%d files checked' % len(report.files)) if not report.total_errors: print('No problems found') rc = 0 else: print('%d errors' % (report.total_errors)) print('') error_type_counts = get_error_type_counts(report.get_error_codes()) for k, v in error_type_counts.items(): print("'%s'-type errors: %d" % (k, v)) rc = 1 print('') print('Checked files:') print(''.join(['\n* %s' % f for f in report.files])) # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return rc, [format_error(e) for e in report.errors] def get_flake8_style_guide(argv): # This is a modified version of flake8.legacy.get_style_guide() in which we pass argv through # to parse_configuration_and_cli(), as opposed to a dict of flake8 options. # Since we are using config files and a mix plugins, it is not trivial to determine the # appropriate options to pass into the standard flake8.legacy.get_style_guide(); # passing argv gets it to determine the options for us. application = flake8_app.Application() if hasattr(application, 'parse_preliminary_options'): prelim_opts, remaining_args = application.parse_preliminary_options( argv) flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file) from flake8.options import config config_finder = config.ConfigFileFinder( application.program, prelim_opts.append_config, config_file=prelim_opts.config, ignore_config_files=prelim_opts.isolated) application.find_plugins(config_finder) application.register_plugin_options() application.parse_configuration_and_cli(config_finder, remaining_args) else: application.parse_preliminary_options_and_args([]) flake8.configure_logging( application.prelim_opts.verbose, application.prelim_opts.output_file) application.make_config_finder() application.find_plugins() application.register_plugin_options() application.parse_configuration_and_cli(argv) application.make_formatter() try: # needed in older flake8 versions to populate the listener application.make_notifier() except AttributeError: pass application.make_guide() application.make_file_checker_manager() return StyleGuide(application) def generate_flake8_report(config_file, paths, excludes, max_line_length=None): flake8_argv = [] if config_file is not None: flake8_argv.append('--config={0}'.format(config_file)) if len(excludes) > 0: flake8_argv.append('--exclude={0}'.format(','.join(excludes))) if max_line_length is not None: flake8_argv.append('--max-line-length={0}'.format(max_line_length)) style = get_flake8_style_guide(flake8_argv) # Monkey patch formatter to collect all errors format_func = style._application.formatter.format report = CustomReport() def custom_format(error): format_func(error) report.add_error(error) print('') print(format_error(error)) style._application.formatter.format = custom_format # Get the names of files checked report.report = style.check_files(paths) file_checkers = style._application.file_checker_manager.checkers report.files = [file_checker.filename for file_checker in file_checkers] assert report.report.total_errors == len(report.errors) return report def format_error(error): return '%s:%d:%d: %s %s' % ( error.filename, error.line_number, error.column_number, error.code, error.text) def get_xunit_content(report, testname, elapsed): data = { 'testname': testname, 'test_count': max(report.total_errors, 1), 'error_count': report.total_errors, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data if report.errors: # report each flake8 error/warning as a failing testcase for error in report.errors: data = { 'quoted_name': quoteattr( '%s (%s:%d:%d)' % ( error.code, error.filename, error.line_number, error.column_number)), 'testname': testname, 'quoted_message': quoteattr( '%s:\n%s' % (error.text, error.physical_line)), } xml += """ """ % data else: # if there are no flake8 problems report a single successful test data = { 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % f for f in report.files])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml def get_error_type_counts(error_codes): # Determine the type of error by the first character in its error code # e.g. 'E261' is type 'E' error_types = sorted({e[0] for e in error_codes}) # Create dictionary of error code types and their counts error_type_counts = {} for error_type in error_types: error_type_counts[error_type] = len([ e for e in error_codes if e.startswith(error_type)]) return error_type_counts class CustomReport: def __init__(self): self.files = [] self.errors = [] self.report = None @property def total_errors(self): return len(self.errors) def add_error(self, error): self.errors.append(error) def get_error_codes(self): return [e.code for e in self.errors] def print_statistics(self): self.report._application.report_statistics() if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_flake8/ament_flake8/pytest_marker.py000066400000000000000000000013371420377356500241030ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def pytest_configure(config): config.addinivalue_line( 'markers', 'flake8: marks tests checking for flake8 compliance') ament_lint-0.12.0/ament_flake8/doc/000077500000000000000000000000001420377356500170435ustar00rootroot00000000000000ament_lint-0.12.0/ament_flake8/doc/index.rst000066400000000000000000000011321420377356500207010ustar00rootroot00000000000000ament_flake8 ============ Checks the code syntax and style of Python source files using `flake8 `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_flake8 [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_flake8 `_. ament_lint-0.12.0/ament_flake8/package.xml000066400000000000000000000014541420377356500204170ustar00rootroot00000000000000 ament_flake8 0.12.0 The ability to check code for style and syntax conventions with flake8. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang D. Hood ament_lint python3-flake8 ament_python ament_lint-0.12.0/ament_flake8/pytest.ini000066400000000000000000000000351420377356500203250ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_flake8/resource/000077500000000000000000000000001420377356500201255ustar00rootroot00000000000000ament_lint-0.12.0/ament_flake8/resource/ament_flake8000066400000000000000000000000001420377356500223740ustar00rootroot00000000000000ament_lint-0.12.0/ament_flake8/setup.py000066400000000000000000000027201420377356500200110ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_flake8' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], package_data={'': [ 'configuration/ament_flake8.ini', ]}, zip_safe=False, author='D. Hood', author_email='dhood@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check Python code style using flake8.', long_description="""\ The ability to check code for syntax and style conventions with flake8.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_flake8 = ament_flake8.main:main', ], 'pytest11': [ 'ament_flake8 = ament_flake8.pytest_marker', ], }, ) ament_lint-0.12.0/ament_flake8/test/000077500000000000000000000000001420377356500172555ustar00rootroot00000000000000ament_lint-0.12.0/ament_flake8/test/test_flake8.py000066400000000000000000000016341420377356500220440ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from ament_flake8.main import main_with_errors # noqa def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_lint/000077500000000000000000000000001420377356500160725ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint/CHANGELOG.rst000066400000000000000000000057031420377356500201200ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_lint ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Contributors: Chris Lalancette 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Contributors: Dirk Thomas 0.7.4 (2019-07-31) ------------------ * declare pytest markers (`#164 `_) * declare pytest markers * add markers to ament_xmllint tests * Contributors: Dirk Thomas 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_lint/ament_lint/000077500000000000000000000000001420377356500202245ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint/ament_lint/__init__.py000066400000000000000000000000001420377356500223230ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint/ament_lint/pytest_marker.py000066400000000000000000000013101420377356500234620ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def pytest_configure(config): config.addinivalue_line('markers', 'linter: marks tests as linter checks') ament_lint-0.12.0/ament_lint/package.xml000066400000000000000000000013011420377356500202020ustar00rootroot00000000000000 ament_lint 0.12.0 Providing common API for ament linter packages. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_python ament_lint-0.12.0/ament_lint/pytest.ini000066400000000000000000000000351420377356500201210ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_lint/resource/000077500000000000000000000000001420377356500177215ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint/resource/ament_lint000066400000000000000000000000001420377356500217640ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint/setup.py000066400000000000000000000024411420377356500176050ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_lint' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], zip_safe=True, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Providing common API for ament linter packages.', long_description="""\ Providing common API for ament linter packages, e.g. the `linter` marker for pytest.""", license='Apache License, Version 2.0', entry_points={ 'pytest11': [ 'ament_lint = ament_lint.pytest_marker', ], }, ) ament_lint-0.12.0/ament_lint_auto/000077500000000000000000000000001420377356500171225ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_auto/CHANGELOG.rst000066400000000000000000000106311420377356500211440ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_lint_auto ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Use correct lint package dependencies (`#278 `_) * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang, Esteve Fernandez 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Rename pep8 packages to pycodestyle (part 2 of 2) The python package 'pep8' has been renamed to 'pycodestyle'. This change follows suit by renaming ament_pep8 and ament_cmake_pep8 to ament_pycodestyle and ament_cmake_pycodestyle respectively. * Contributors: Chris Lalancette, Scott K Logan 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * Fix unused-arg check in auto find test deps: (`#136 `_) - Arguments to a macro are not variables, so it's not possible to do 'if(ARGN)' to check for arguments; however, copying ARGN to a variable works * add version dependency for new feature (`#133 `_) * Use exclude option of ament_execute_extensions in ament_lint_auto (`#133 `_) * Contributors: Dirk Thomas, jpsamper2009 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#50 `_ from ament/ctest_build_testing use CTest BUILD_TESTING * use CTest BUILD_TESTING * Merge pull request `#26 `_ from ament/error_when_used_after_ament_package ensure that ament_package() was called before finding ament_lint_auto * ensure that ament_package() was called before finding ament_lint_auto * add explicit build type * disable debug output * add missing copyright / license information * Merge pull request `#9 `_ from ament/docs add docs for linters * add docs for linters * Merge pull request `#2 `_ from ament/ament_lint_auto allow linting based on test dependencies only * add ament_lint_auto and ament_lint_common, update all linter packages to implement extension point of ament_lint_auto * Contributors: Dirk Thomas ament_lint-0.12.0/ament_lint_auto/CMakeLists.txt000066400000000000000000000003571420377356500216670ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_lint_auto NONE) find_package(ament_cmake_core REQUIRED) ament_package( CONFIG_EXTRAS "ament_lint_auto-extras.cmake" ) install( DIRECTORY cmake DESTINATION share/${PROJECT_NAME} ) ament_lint-0.12.0/ament_lint_auto/ament_lint_auto-extras.cmake000066400000000000000000000020621420377356500246120ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # copied from ament_lint_auto/ament_lint_auto-extras.cmake if(_${PROJECT_NAME}_AMENT_PACKAGE) message(FATAL_ERROR "find_package(ament_lint_auto) must be called before ament_package()") endif() find_package(ament_cmake_core QUIET REQUIRED) find_package(ament_cmake_test QUIET REQUIRED) include( "${ament_lint_auto_DIR}/ament_lint_auto_find_test_dependencies.cmake") ament_register_extension("ament_package" "ament_lint_auto" "ament_lint_auto_package_hook.cmake") ament_lint-0.12.0/ament_lint_auto/cmake/000077500000000000000000000000001420377356500202025ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake000066400000000000000000000024141420377356500311340ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Invoke find_package() for all test dependencies. # # All found package names are appended to the # ``${PROJECT_NAME}_FOUND_TEST_DEPENDS`` variables. # # @public # macro(ament_lint_auto_find_test_dependencies) set(_ARGN "${ARGN}") if(_ARGN) message(FATAL_ERROR "ament_lint_auto_find_test_dependencies() called with " "unused arguments: ${_ARGN}") endif() if(NOT _AMENT_PACKAGE_NAME) ament_package_xml() endif() # try to find_package() all test dependencies foreach(_dep ${${PROJECT_NAME}_TEST_DEPENDS}) find_package(${_dep} QUIET) if(${_dep}_FOUND) list(APPEND ${PROJECT_NAME}_FOUND_TEST_DEPENDS ${_dep}) endif() endforeach() endmacro() ament_lint-0.12.0/ament_lint_auto/cmake/ament_lint_auto_package_hook.cmake000066400000000000000000000016631420377356500270670ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Use the AMENT_LINT_AUTO_EXCLUDE variable to exclude linter packages from # running using the ament_lint_auto hook. # It is still possible, however, to use the linter by calling it explicitly. # # :variable AMENT_LINT_AUTO_EXCLUDE: List of strings (package names) ament_execute_extensions(ament_lint_auto EXCLUDE "${AMENT_LINT_AUTO_EXCLUDE}") ament_lint-0.12.0/ament_lint_auto/doc/000077500000000000000000000000001420377356500176675ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_auto/doc/index.rst000066400000000000000000000023651420377356500215360ustar00rootroot00000000000000ament_lint_auto =============== The package simplifies using multiple linters as part of the CMake tests. It reduces the amount of CMake code to a bare minimum. ``CMakeLists.txt``: .. code:: cmake # this must happen before the invocation of ament_package() if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) ament_lint_auto_find_test_dependencies() endif() The set of linters to be used is then only specified in the package manifest as test dependencies. ``package.xml``: .. code:: xml ament_lint_auto ament_cmake_clang_format ament_cmake_cppcheck ament_cmake_pycodestyle Since recursive dependencies are also being used a single test dependency is sufficient to test with a set of common linters. ``package.xml``: .. code:: xml ament_lint_auto ament_lint_common The documentation of the package `ament_cmake_test `_ provides more information on testing in CMake ament packages. ament_lint-0.12.0/ament_lint_auto/package.xml000066400000000000000000000017471420377356500212500ustar00rootroot00000000000000 ament_lint_auto 0.12.0 The auto-magic functions for ease to use of the ament linters in CMake. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_test ament_cmake_core ament_cmake_test ament_cmake ament_lint-0.12.0/ament_lint_cmake/000077500000000000000000000000001420377356500172325ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_cmake/CHANGELOG.rst000066400000000000000000000242031420377356500212540ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_lint_cmake ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * [ament_copyright] Fix file exclusion behavior (`#327 `_) * [ament_copyright] Fix file exclusion behavior This commit fixes the faulty file exclusion behavior reported in https://github.com/ament/ament_lint/issues/326. Specifically, the exclusion list is matched against traversed files in the `crawler` module. Changes inspired by https://github.com/ament/ament_lint/pull/299/. * Update excluded file path in copyright tests Since file names are not indiscriminately matched throughout the search tree anymore, the excluded files listed in the copyright tests need to be updated relative to the root of the package. * Add test cases to check exclusion behavior Specifically, these tests check for: - Incorrect exclusion of single filenames. - Correct exclusion of relatively/absolutely addressed filenames. - Correct exclusion of wildcarded paths. * Add unit tests for crawler module These unit tests make sure both search and exclusion behaviors are correctly demonstrated by the `ament_copyright.crawler` module. * Contributors: Abrar Rahman Protyasha, Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- * ament_lint_cmake: default linelength in argumentparser for consistency (`#306 `_) * Contributors: Emerson Knapp 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Fix ament_lint_cmake line length expression (`#236 `_) This regular expression is using the re.VERBOSE flag, meaning that characters after an un-escaped '#' character are interpreted as a comment and are not part of the expression. Also set the default maximum line length to 140 columns. * Add Audrow as a maintainer (`#294 `_) * Make CMake linter line length configurable (`#235 `_) Co-authored-by: Miaofei * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ * Close source files after reading them (`#249 `_) Resolves the ResourceWarning messages coming to the console during testing with debug-enabled Python. * Contributors: Scott K Logan 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * Generate xunit files valid for the junit10.xsd (`#220 `_) * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dirk Thomas, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Contributors: Dirk Thomas 0.7.4 (2019-07-31) ------------------ * Raw strings in cmakelint.py. This fixes DeprecationWarning on Windows. * Contributors: Chris Lalancette 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ * level setup.py versions to 0.5.1 * Contributors: Mikael Arguedas 0.5.0 (2018-06-18 10:09) ------------------------ * add pytest markers to linter tests * set zip_safe to avoid warning during installation (`#96 `_) * Contributors: Dirk Thomas 0.4.0 (2017-12-08) ------------------ * remove test_suite, add pytest as test_requires * 0.0.3 * Merge pull request `#84 `_ from ament/flake8_plugins update style to satisfy new flake8 plugins * update style to satisfy new flake8 plugins * Merge pull request `#81 `_ from ament/ignore_build_spaces ignore folders with an AMENT_IGNORE file, e.g. build spaces * ignore folders with an AMENT_IGNORE file, e.g. build spaces * 0.0.2 * Merge pull request `#78 `_ from ament/use_flake8 use flake8 instead of pep8 and pyflakes * fix style warnings * Test python module import order using flake8 (`#63 `_) * Add flake8 linter * Don't deal with flake8-import-order just yet * Debugging prints * Reinstate import order rule * Fix reporting bug by using the inner flake8 style guide * Fixup * Add comment on wrapper StyleGuide use * use flake8 v3 (`#1 `_) * Reorder package.xml * Get the filenames from the file checkers because input_file isn't called by flake8 anymore * Output count of all error types * Get flake8 to use the config file The current implementation of get_style_guide does not process the config file correctly. * Error when flake8 v2 found * Print errors like pep8 * remove __future_\_ imports * add schema to manifest files * Support flake8 v2 as well as v3 * Output checked files otherwise it's not present in xunit files for tests run directly with nose (not ament_cmake_flake8) * Prevent v2 imports from happening on systems with v3 * Flake8 replaces pep8+pyflakes * remove __future_\_ imports * update schema url * add schema to manifest files * Merge pull request `#42 `_ from ament/remove_second_extension remove result type extension from testsuite name * remove result type extension from testsuite name * Merge pull request `#28 `_ from ament/pep257 add packages to check pep257 compliance * use ament_pep257 * apply normpath to prevent './' prefix (fix `#24 `_) * Merge pull request `#22 `_ from ament/`fix_tests-ros2/ros2#21 `_ add missing error category in lint_cmake * add missing error category in lint_cmake * also check style of .cmake.in files * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * make use of python linter packages * move cmake part of ament_lint_cmake to ament_cmake_lint_cmake * disable debug output * Merge pull request `#16 `_ from ament/fixup_ament_lint_cmake Some fixes to ament_lint_cmake * add trailing newline to generated test result files * add note about change from upstream * fixup file name ends with check * add --filters to ament_lint_cmake * filter errors in a file using a CMake comment For example you can do something like: # lint_cmake: -package/consistency, -convention/filename To suppress those two categories of warnings. The filter is limited to the current file. * improve SetFilters ability to parse new filters * fix typo * add missing copyright / license information * Merge pull request `#14 `_ from ament/test_runner_windows change test runner to work on windows * update cmakelint to work on windows * change test runner to work on windows * Merge pull request `#9 `_ from ament/docs add docs for linters * add docs for linters * modify generated unit test files for a better hierarchy in Jenkins * make testname argument optional for all linters * use other linters for the linter packages where possible * Merge pull request `#2 `_ from ament/ament_lint_auto allow linting based on test dependencies only * add ament_lint_auto and ament_lint_common, update all linter packages to implement extension point of ament_lint_auto * avoid unnecessary newlines * use project(.. NONE) * update to latest refactoring of ament_cmake * add dependency on ament_cmake_environment * add ament_lint_cmake * Contributors: Dirk Thomas, William Woodall, dhood ament_lint-0.12.0/ament_lint_cmake/ament_lint_cmake/000077500000000000000000000000001420377356500225245ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_cmake/ament_lint_cmake/__init__.py000066400000000000000000000000001420377356500246230ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_cmake/ament_lint_cmake/cmakelint.py000066400000000000000000000441231420377356500250510ustar00rootroot00000000000000""" Copyright 2009 Richard Quirk Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. https://github.com/richq/cmake-lint/blob/7b85fe46b9bd66fe11ecfef20060f976a49d9662/cmakelint/main.py - removed __version__ import - allow closing parenthesis to be on the same level as the opening one (lines 281-282) - ignore lines with exceeding length if they only contain a single string (lines 35, 196-207) - improve SetFilters ability to parse new filters (lines 89-92) - implement in file pragmas to control filters on a per file basis (lines 389 - 430) """ from __future__ import print_function import sys import re import os import getopt if sys.version_info < (3,): # xrange slightly faster than range on python2 range = xrange _RE_CLEAN_COMMENT = re.compile(r'(\s*\#.*)', re.VERBOSE) _RE_COMMAND = re.compile(r'^\s*(\w+)(\s*)\(', re.VERBOSE) _RE_COMMAND_START_SPACES = re.compile(r'^\s*\w+\s*\((\s*)', re.VERBOSE) _RE_COMMAND_END_SPACES = re.compile(r'(\s*)\)', re.VERBOSE) _RE_LOGIC_CHECK = re.compile(r'(\w+)\s*\(\s*\S+[^)]+\)', re.VERBOSE) _RE_COMMAND_ARG = re.compile(r'(\w+)', re.VERBOSE) _RE_STRING = re.compile(r'^\s*\#?\s*"[^"]+"\)?', re.VERBOSE) _logic_commands = """ else endforeach endfunction endif endmacro endwhile """.split() _USAGE = """ Syntax: cmakelint.py [--version] [--config=file] [--filter=-x,+y] [--spaces=N] [file] ... filter=-x,+y,... Specify a comma separated list of filters to apply spaces=N Indentation should be a multiple of N spaces config=file Use the given file for configuration. By default the file ~/.cmakelintrc is used if it exists. Use the value "None" to use no configuration file (./None for a file called literally None) Only the option "filter=" is currently supported in this file. version Show the version number and end """ _ERROR_CATEGORIES = """\ convention/filename linelength package/consistency package/stdargs readability/logic readability/mixedcase readability/wonkycase syntax whitespace/eol whitespace/extra whitespace/indent whitespace/mismatch whitespace/newline whitespace/tabs """ _DEFAULT_CMAKELINTRC = os.path.join(os.path.expanduser('~'), '.cmakelintrc') class _CMakeLintState(object): def __init__(self): self.filters = [] self.config = 0 self.errors = 0 self.spaces = 2 self.linelength = 80 self.allowed_categories = _ERROR_CATEGORIES.split() def SetFilters(self, filters): if not filters: return assert isinstance(self.filters, list) if isinstance(filters, list): self.filters.extend(filters) elif isinstance(filters, str): self.filters.extend([f.strip() for f in filters.split(',') if f]) else: raise ValueError('Filters should be a list or a comma separated string') for f in self.filters: if f.startswith('-') or f.startswith('+'): allowed = False for c in self.allowed_categories: if c.startswith(f[1:]): allowed = True if not allowed: raise ValueError('Filter not allowed: %s'%f) else: raise ValueError('Filter should start with - or +') def SetSpaces(self, spaces): self.spaces = int(spaces.strip()) def SetLineLength(self, linelength): self.linelength = int(linelength) class _CMakePackageState(object): def __init__(self): self.sets = [] self.have_included_stdargs = False self.have_used_stdargs = False def Check(self, filename, linenumber, clean_lines, errors): pass def _GetExpected(self, filename): package = os.path.basename(filename) package = re.sub(r'^Find(.*)\.cmake', lambda m: m.group(1), package) return package.upper() def Done(self, filename, errors): try: if not IsFindPackage(filename): return if self.have_included_stdargs and self.have_used_stdargs: return if not self.have_included_stdargs: errors( filename, 0, 'package/consistency', 'Package should include FindPackageHandleStandardArgs') if not self.have_used_stdargs: errors( filename, 0, 'package/consistency', 'Package should use FIND_PACKAGE_HANDLE_STANDARD_ARGS') finally: self.have_used_stdargs = False self.have_included_stdargs = False def HaveUsedStandardArgs(self, filename, linenumber, var, errors): expected = self._GetExpected(filename) self.have_used_stdargs = True if expected != var: errors( filename, linenumber, 'package/stdargs', 'Weird variable passed to std args, should be ' + expected + ' not ' + var) def HaveIncluded(self, var): if var == 'FindPackageHandleStandardArgs': self.have_included_stdargs = True def Set(self, var): self.sets.append(var) _lint_state = _CMakeLintState() _package_state = _CMakePackageState() def CleanComments(line): return _RE_CLEAN_COMMENT.sub('', line) class CleansedLines(object): def __init__(self, lines): self.have_seen_uppercase = None self.raw_lines = lines self.lines = [CleanComments(line) for line in lines] def LineNumbers(self): return range(0, len(self.lines)) def ShouldPrintError(category): should_print = True for f in _lint_state.filters: if f.startswith('-') and category.startswith(f[1:]): should_print = False elif f.startswith('+') and category.startswith(f[1:]): should_print = True return should_print def Error(filename, linenumber, category, message): if ShouldPrintError(category): _lint_state.errors += 1 print('%s:%d: %s [%s]' % (filename, linenumber, message, category)) def CheckLineLength(filename, linenumber, clean_lines, errors): """ Check for lines longer than the recommended length """ line = clean_lines.raw_lines[linenumber] if len(line) > _lint_state.linelength: if _RE_STRING.match(line): lineno = linenumber while lineno > 0: lineno -= 1 line = clean_lines.raw_lines[lineno] cmd = GetCommand(line) if cmd == 'message': # message string can be split so warning is feasible break if cmd: # since single strings can't be split don't warn about it return return errors( filename, linenumber, 'linelength', 'Lines should be <= %d characters long' % (_lint_state.linelength)) def ContainsCommand(line): return _RE_COMMAND.match(line) def GetCommand(line): match = _RE_COMMAND.match(line) if match: return match.group(1) return '' def IsCommandMixedCase(command): lower = command.lower() upper = command.upper() return not (command == lower or command == upper) def IsCommandUpperCase(command): upper = command.upper() return command == upper def CheckUpperLowerCase(filename, linenumber, clean_lines, errors): """ Check that commands are either lower case or upper case, but not both """ line = clean_lines.lines[linenumber] if ContainsCommand(line): command = GetCommand(line) if IsCommandMixedCase(command): return errors( filename, linenumber, 'readability/wonkycase', 'Do not use mixed case commands') if clean_lines.have_seen_uppercase is None: clean_lines.have_seen_uppercase = IsCommandUpperCase(command) else: is_upper = IsCommandUpperCase(command) if is_upper != clean_lines.have_seen_uppercase: return errors( filename, linenumber, 'readability/mixedcase', 'Do not mix upper and lower case commands') def CheckCommandSpaces(filename, linenumber, clean_lines, errors): """ No extra spaces between command and parenthesis """ line = clean_lines.lines[linenumber] match = ContainsCommand(line) if match and len(match.group(2)): errors(filename, linenumber, 'whitespace/extra', "Extra spaces between '%s' and its ()"%(match.group(1))) if match: spaces_after_open = len(_RE_COMMAND_START_SPACES.match(line).group(1)) initial_linenumber = linenumber end = None while True: line = clean_lines.lines[linenumber] end = _RE_COMMAND_END_SPACES.search(line) linenumber += 1 if end or linenumber >= len(clean_lines.lines): break if linenumber == len(clean_lines.lines) and not end: errors(filename, initial_linenumber, 'syntax', 'Unable to find the end of this command') if end: spaces_before_end = len(end.group(1)) if spaces_after_open != spaces_before_end: spaces_before_command = match.group(0).find(match.group(1)) if spaces_before_command != spaces_before_end: errors(filename, initial_linenumber, 'whitespace/mismatch', 'Mismatching spaces inside () after command') def CheckRepeatLogic(filename, linenumber, clean_lines, errors): """ Check for logic inside else, endif etc """ line = clean_lines.lines[linenumber] for cmd in _logic_commands: if re.search(r'\b%s\b'%cmd, line.lower()): m = _RE_LOGIC_CHECK.search(line) if m: errors(filename, linenumber, 'readability/logic', 'Expression repeated inside %s; ' 'better to use only %s()'%(cmd, m.group(1))) break def CheckIndent(filename, linenumber, clean_lines, errors): initial_spaces = 0 line = clean_lines.raw_lines[linenumber] while initial_spaces < len(line) and line[initial_spaces] == ' ': initial_spaces += 1 remainder = initial_spaces % _lint_state.spaces if remainder != 0: errors(filename, linenumber, 'whitespace/indent', 'Weird indentation; use %d spaces'%(_lint_state.spaces)) def CheckStyle(filename, linenumber, clean_lines, errors): """ Check style issues. These are: No extra spaces between command and parenthesis Matching spaces between parenthesis and arguments No repeated logic in else(), endif(), endmacro() """ CheckIndent(filename, linenumber, clean_lines, errors) CheckCommandSpaces(filename, linenumber, clean_lines, errors) line = clean_lines.raw_lines[linenumber] if line.find('\t') != -1: errors(filename, linenumber, 'whitespace/tabs', 'Tab found; please use spaces') if line and line[-1].isspace(): errors(filename, linenumber, 'whitespace/eol', 'Line ends in whitespace') CheckRepeatLogic(filename, linenumber, clean_lines, errors) def CheckFileName(filename, errors): name_match = re.match(r'Find(.*)\.cmake', os.path.basename(filename)) if name_match: package = name_match.group(1) if not package.isupper(): errors(filename, 0, 'convention/filename', 'Find modules should use uppercase names; ' 'consider using Find' + package.upper() + '.cmake') else: if filename.lower() == 'cmakelists.txt' and filename != 'CMakeLists.txt': errors(filename, 0, 'convention/filename', 'File should be called CMakeLists.txt') def IsFindPackage(filename): return os.path.basename(filename).startswith('Find') and filename.endswith('.cmake') def GetCommandArgument(linenumber, clean_lines): line = clean_lines.lines[linenumber] skip = GetCommand(line) while True: line = clean_lines.lines[linenumber] m = _RE_COMMAND_ARG.finditer(line) for i in m: if i.group(1) == skip: continue return i.group(1) linenumber += 1 return '' def CheckFindPackage(filename, linenumber, clean_lines, errors): cmd = GetCommand(clean_lines.lines[linenumber]) if cmd: if cmd.lower() == 'include': var_name = GetCommandArgument(linenumber, clean_lines) _package_state.HaveIncluded(var_name) elif cmd.lower() == 'find_package_handle_standard_args': var_name = GetCommandArgument(linenumber, clean_lines) _package_state.HaveUsedStandardArgs(filename, linenumber, var_name, errors) def ProcessLine(filename, linenumber, clean_lines, errors): """ Arguments: filename the name of the file linenumber the line number index clean_lines CleansedLines instance errors the error handling function """ CheckLineLength(filename, linenumber, clean_lines, errors) CheckUpperLowerCase(filename, linenumber, clean_lines, errors) CheckStyle(filename, linenumber, clean_lines, errors) if IsFindPackage(filename): CheckFindPackage(filename, linenumber, clean_lines, errors) def IsValidFile(filename): return filename.endswith('.cmake') or os.path.basename(filename).lower() == 'cmakelists.txt' def ProcessFile(filename): # Store and then restore the filters to prevent pragmas in the file from persisting. original_filters = list(_lint_state.filters) try: return _ProcessFile(filename) finally: _lint_state.filters = original_filters def _ProcessFile(filename): linter_pragma_start = '# lint_cmake: ' lines = ['# Lines start at 1'] have_cr = False if not IsValidFile(filename): print('Ignoring file: ' + filename) return global _package_state _package_state = _CMakePackageState() with open(filename) as f: for l in f.readlines(): l = l.rstrip('\n') if l.endswith('\r'): have_cr = True l = l.rstrip('\r') lines.append(l) # Check this line to see if it is a lint_cmake pragma if l.startswith(linter_pragma_start): try: _lint_state.SetFilters(l[len(linter_pragma_start):]) except: print("Exception occurred while processing '{0}:{1}':" .format(filename, len(lines))) raise lines.append('# Lines end here') # Check file name after reading lines incase of a # lint_cmake: pragma CheckFileName(filename, Error) if have_cr and os.linesep != '\r\n': Error(filename, 0, 'whitespace/newline', 'Unexpected carriage return found; ' 'better to use only \\n') clean_lines = CleansedLines(lines) for line in clean_lines.LineNumbers(): ProcessLine(filename, line, clean_lines, Error) _package_state.Done(filename, Error) def PrintVersion(): sys.stderr.write("cmakelint 1.2.01\n") sys.exit(0) def PrintUsage(message): sys.stderr.write(_USAGE) if message: sys.exit('FATAL ERROR: '+message) else: sys.exit(1) def PrintCategories(): sys.stderr.write(_ERROR_CATEGORIES) sys.exit(0) def ParseOptionFile(contents, ignore_space): filters = None spaces = None linelength = None for line in contents: line = line.strip() if not line or line.startswith('#'): continue if line.startswith('filter='): filters = line.replace('filter=', '') if line.startswith('spaces='): spaces = line.replace('spaces=', '') if line.startswith('linelength='): linelength = line.replace('linelength=', '') _lint_state.SetFilters(filters) if spaces and not ignore_space: _lint_state.SetSpaces(spaces) if linelength is not None: _lint_state.SetLineLength(linelength) def ParseArgs(argv): try: (opts, filenames) = getopt.getopt(argv, '', ['help', 'filter=', 'config=', 'spaces=', 'version']) except getopt.GetoptError: PrintUsage('Invalid Arguments') filters = "" _lint_state.config = _DEFAULT_CMAKELINTRC ignore_space = False for (opt, val) in opts: if opt == '--version': PrintVersion() elif opt == '--help': PrintUsage(None) elif opt == '--filter': filters = val if not filters: PrintCategories() elif opt == '--config': _lint_state.config = val if _lint_state.config == 'None': _lint_state.config = None elif opt == '--spaces': try: _lint_state.SetSpaces(val) ignore_space = True except: PrintUsage('spaces expects an integer value') try: if _lint_state.config: try: ParseOptionFile(open(_lint_state.config, 'rU').readlines(), ignore_space) except IOError: pass _lint_state.SetFilters(filters) except ValueError as ex: PrintUsage(str(ex)) if not filenames: PrintUsage('No files were specified!') return filenames def main(): files = ParseArgs(sys.argv[1:]) for filename in files: ProcessFile(filename) sys.stderr.write("Total Errors: %d\n" % _lint_state.errors) ament_lint-0.12.0/ament_lint_cmake/ament_lint_cmake/main.py000077500000000000000000000154131420377356500240310ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import os import sys import time from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr import ament_lint_cmake.cmakelint as cmakelint # override filename check to allow any filename to be checked def is_valid_file(filename): return True cmakelint.IsValidFile = is_valid_file def main(argv=sys.argv[1:]): parser = argparse.ArgumentParser( description='Check CMake code against the style conventions.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files named ' "'CMakeLists.txt' and ending in '.cmake' or '.cmake.in' will be " 'considered.') parser.add_argument( '--filters', default='', help='Filters for lint_cmake, for a list of filters see: ' 'https://github.com/richq/cmake-lint/blob/master/README.md#usage') parser.add_argument( '--linelength', metavar='N', type=int, default=140, help='The maximum line length') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if args.xunit_file: start_time = time.time() files = get_files(args.paths) if not files: print('No files found', file=sys.stderr) return 1 # hook into error reporting DefaultError = cmakelint.Error # noqa: N806 report = [] # invoke cmake lint cmakelint._lint_state.config = cmakelint._DEFAULT_CMAKELINTRC cmakelint._lint_state.SetFilters(args.filters) if args.linelength is not None: cmakelint._lint_state.SetLineLength(str(args.linelength)) for filename in files: # hook into error reporting errors = [] def custom_error(filename, linenumber, category, message): if cmakelint.ShouldPrintError(category): errors.append({ 'linenumber': linenumber, 'category': category, 'message': message, }) DefaultError(filename, linenumber, category, message) cmakelint.Error = custom_error cmakelint.ProcessFile(filename) report.append((filename, errors)) if errors: print('') # print summary print('') if not cmakelint._lint_state.errors: print('No problems found') rc = 0 else: print('%d errors' % cmakelint._lint_state.errors) rc = 1 # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return rc def get_files(paths): files = [] for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] dirnames.sort() # select files by name / extension for filename in sorted(filenames): fname_low = filename.lower() if ( fname_low == 'CMakeLists.txt'.lower() or fname_low.endswith('.cmake') or fname_low.endswith('.cmake.in') ): files.append(os.path.join(dirpath, filename)) if os.path.isfile(path): files.append(path) return [os.path.normpath(f) for f in files] def get_xunit_content(report, testname, elapsed): test_count = sum(max(len(r[1]), 1) for r in report) error_count = sum(len(r[1]) for r in report) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for (filename, errors) in report: if errors: # report each lint_cmake error as a failing testcase for error in errors: data = { 'quoted_location': quoteattr( '%s (%s:%d)' % ( error['category'], filename, error['linenumber'])), 'testname': testname, 'quoted_message': quoteattr(error['message']), } xml += """ """ % data else: # if there are no lint_cmake errors report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % r[0] for r in report])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_lint_cmake/doc/000077500000000000000000000000001420377356500177775ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_cmake/doc/index.rst000066400000000000000000000011761420377356500216450ustar00rootroot00000000000000ament_lint_cmake ================ Checks the code style of CMake files using `CMakeLint `_. Files with the following names / extensions are being considered: ``CMakeLists.txt``, ``.cmake``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_lint_cmake [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_lint_cmake `_. ament_lint-0.12.0/ament_lint_cmake/package.xml000066400000000000000000000016361420377356500213550ustar00rootroot00000000000000 ament_lint_cmake 0.12.0 The ability to lint CMake code using cmakelint and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_copyright ament_flake8 ament_pep257 python3-pytest ament_python ament_lint-0.12.0/ament_lint_cmake/pytest.ini000066400000000000000000000000351420377356500212610ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_lint_cmake/resource/000077500000000000000000000000001420377356500210615ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_cmake/resource/ament_lint_cmake000066400000000000000000000000001420377356500242640ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_cmake/setup.py000066400000000000000000000025141420377356500207460ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_lint_cmake' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], zip_safe=True, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check CMake code style using cmakelint.', long_description="""\ The ability to lint CMake code using cmakelint and generate xUnit test result files.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_lint_cmake = ament_lint_cmake.main:main', ], }, ) ament_lint-0.12.0/ament_lint_cmake/test/000077500000000000000000000000001420377356500202115ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_cmake/test/test_copyright.py000066400000000000000000000015221420377356500236320ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_copyright.main import main import pytest @pytest.mark.copyright @pytest.mark.linter def test_copyright(): excluded = ['ament_lint_cmake/cmakelint.py'] rc = main(argv=['--exclude'] + excluded) assert rc == 0, 'Found errors' ament_lint-0.12.0/ament_lint_cmake/test/test_flake8.py000066400000000000000000000016521420377356500230000ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): excluded = ['cmakelint.py'] rc, errors = main_with_errors(argv=['--exclude'] + excluded) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_lint_cmake/test/test_pep257.py000066400000000000000000000015301420377356500226430ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pep257.main import main import pytest @pytest.mark.linter @pytest.mark.pep257 def test_pep257(): excluded = ['ament_lint_cmake/cmakelint.py'] rc = main(argv=['--exclude'] + excluded) assert rc == 0, 'Found docblock style errors' ament_lint-0.12.0/ament_lint_common/000077500000000000000000000000001420377356500174425ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_common/CHANGELOG.rst000066400000000000000000000141221420377356500214630ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_lint_common ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Fix typo in ament_lint_common/package.xml (`#336 `_) * Contributors: Audrow Nash, Kenji Miyake 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * add ament_lint_common doc (`#218 `_) * adding ament_lint_common doc * add links to common linters * change ament_uncrustify link * Contributors: Chris Lalancette, Marya Belanger 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ * Add clang tidy to ament linters (`#155 `_) * Basic clang-lint functionality * Add clang tidy cmake dir * Add Google/default config file * Add xunit output * Add lint tests * Update copyright, maintainer, verbiage * Contributors: John 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ * add ament\_(cmake\_)xmllint packages (`#104 `_) * add ament\_(cmake\_)xmllint packages * consider xsi:noNamespaceSchemaLocation of root tag * Contributors: Dirk Thomas 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ * 0.0.3 * 0.0.2 * Test python module import order using flake8 (`#63 `_) * Add flake8 linter * Don't deal with flake8-import-order just yet * Debugging prints * Reinstate import order rule * Fix reporting bug by using the inner flake8 style guide * Fixup * Add comment on wrapper StyleGuide use * use flake8 v3 (`#1 `_) * Reorder package.xml * Get the filenames from the file checkers because input_file isn't called by flake8 anymore * Output count of all error types * Get flake8 to use the config file The current implementation of get_style_guide does not process the config file correctly. * Error when flake8 v2 found * Print errors like pep8 * remove __future_\_ imports * add schema to manifest files * Support flake8 v2 as well as v3 * Output checked files otherwise it's not present in xunit files for tests run directly with nose (not ament_cmake_flake8) * Prevent v2 imports from happening on systems with v3 * Flake8 replaces pep8+pyflakes * update schema url * add schema to manifest files * Merge pull request `#56 `_ from ament/cmake35 require CMake 3.5 * require CMake 3.5 * Merge pull request `#39 `_ from ament/cpplint_python3 use Python 3 for cpplint and split into Python and CMake package * refactor ament_cpplint into Python and CMake package * Merge pull request `#36 `_ from ament/enable_cpplint add ament_cpplint as default linter * add ament_cpplint as default linter * Merge pull request `#28 `_ from ament/pep257 add packages to check pep257 compliance * use ament_cmake_pep257 as a common linter * add explicit build type * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * move cmake part of ament_uncrustify to ament_cmake_uncrustify * move cmake part of ament_pyflakes to ament_cmake_pyflakes * move cmake part of ament_pep8 to ament_cmake_pep8 * move cmake part of ament_lint_cmake to ament_cmake_lint_cmake * move cmake part of ament_cppcheck to ament_cmake_cppcheck * Merge pull request `#8 `_ from ament/ament_copyright add more options to ament_copyright * add more options to ament_copyright * disable clang_format and cpplint for now (fix `ros2/ros2#15 `_) * Merge pull request `#2 `_ from ament/ament_lint_auto allow linting based on test dependencies only * add ament_lint_auto and ament_lint_common, update all linter packages to implement extension point of ament_lint_auto * Contributors: Dirk Thomas, dhood ament_lint-0.12.0/ament_lint_common/CMakeLists.txt000066400000000000000000000004051420377356500222010ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(ament_lint_common NONE) find_package(ament_cmake_core REQUIRED) find_package(ament_cmake_export_dependencies REQUIRED) ament_package_xml() ament_export_dependencies(${${PROJECT_NAME}_EXEC_DEPENDS}) ament_package() ament_lint-0.12.0/ament_lint_common/doc/000077500000000000000000000000001420377356500202075ustar00rootroot00000000000000ament_lint-0.12.0/ament_lint_common/doc/index.rst000066400000000000000000000027211420377356500220520ustar00rootroot00000000000000ament_lint_common ================= A mechanism for running the following set of common linters: * `ament_cmake_copyright `_ : a copyright linter which checks that copyright statements and license headers are present and correct * `ament_cmake_cppcheck `_ : a C++ checker which can also find some logic tests * `ament_cmake_cpplint `_ : a C++ style checker (e.g. comment style) * `ament_cmake_flake8 `_ : a style checker for Python files * `ament_cmake_lint_cmake `_ : a cmake linter * `ament_cmake_pep257 `_ : a style checker for Python docstrings * `ament_cmake_uncrustify `_ : a C++ style checker * `ament_cmake_xmllint `_ : an xml linter The `ament_lint_auto `_ documentation provides information on using ament_lint_common. ament_lint-0.12.0/ament_lint_common/package.xml000066400000000000000000000026301420377356500215600ustar00rootroot00000000000000 ament_lint_common 0.12.0 The list of commonly used linters in the ament build system in CMake. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_cmake_core ament_cmake_export_dependencies ament_cmake_core ament_cmake_copyright ament_cmake_cppcheck ament_cmake_cpplint ament_cmake_flake8 ament_cmake_lint_cmake ament_cmake_pep257 ament_cmake_uncrustify ament_cmake_xmllint ament_cmake ament_lint-0.12.0/ament_mypy/000077500000000000000000000000001420377356500161225ustar00rootroot00000000000000ament_lint-0.12.0/ament_mypy/CHANGELOG.rst000066400000000000000000000106361420377356500201510ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_mypy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Contributors: Audrow Nash 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * Generate xunit files valid for the junit10.xsd (`#220 `_) * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dirk Thomas, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * Add pytest marker for mypy (`#191 `_) * install manifest files in Python packages (`#185 `_) * add config ini to ament_mypy site package (`#182 `_) * add config ini to ament_mypy site package * add newline to end of mypy config file * change to package_data vs MANIFEST.IN * add mypy support for linters/testing (`#154 `_) * add mypy support for linters/testing * Update ament_cmake_mypy/doc/index.rst Co-Authored-By: Kyle Fazzari * fix whitespace in file and in generated xml * fixes, package versioning, and test suite * fix wrong separator in cmake file * readd copied from comment * Update ament_mypy/ament_mypy/main.py Co-Authored-By: Kyle Fazzari * remove mypypath auto populating * add default configuration ignoring missing imports * update test to remove MYPYPATH check, default config check * remove extraneous path insert statement * remove extraneous path insert statement * update test cases for default config file change * added tests for error code forwarding, fixed linter errors * linter failures relating to quotes and docs * add handling for notes * remove ament_lint dep * update regex to match drive letter on windows * Contributors: Dirk Thomas, Emerson Knapp, Ted Kern 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_mypy/ament_mypy/000077500000000000000000000000001420377356500203045ustar00rootroot00000000000000ament_lint-0.12.0/ament_mypy/ament_mypy/__init__.py000066400000000000000000000000001420377356500224030ustar00rootroot00000000000000ament_lint-0.12.0/ament_mypy/ament_mypy/configuration/000077500000000000000000000000001420377356500231535ustar00rootroot00000000000000ament_lint-0.12.0/ament_mypy/ament_mypy/configuration/ament_mypy.ini000066400000000000000000000000451420377356500260350ustar00rootroot00000000000000[mypy] ignore_missing_imports = True ament_lint-0.12.0/ament_mypy/ament_mypy/main.py000077500000000000000000000175731420377356500216220ustar00rootroot00000000000000#!/usr/bin/env python3 # # Copyright 2019 Canonical, Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import os import re import sys import textwrap import time from typing import List, Match, Optional, Tuple from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr import mypy.api # type: ignore def main(argv: List[str] = sys.argv[1:]) -> int: """Command line tool for linting files with mypy.""" parser = argparse.ArgumentParser( description='Check code using mypy', formatter_class=argparse.ArgumentDefaultsHelpFormatter ) parser.add_argument( '--config', metavar='path', dest='config_file', default=os.path.join(os.path.dirname(__file__), 'configuration', 'ament_mypy.ini'), help='The config file' ) parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files ending ' "in '.py' will be considered." ) parser.add_argument( '--exclude', metavar='filename', nargs='*', dest='excludes', help='The filenames to exclude.' ) parser.add_argument( '--cache-dir', metavar='cache', default=os.devnull, dest='cache_dir', help='The location mypy will place its cache in. Defaults to system ' 'null device' ) # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file' ) args = parser.parse_args(argv) if args.xunit_file: start_time = time.time() if args.config_file and not os.path.exists(args.config_file): print("Could not find config file '{}'".format(args.config_file), file=sys.stderr) return 1 filenames = _get_files(args.paths) if args.excludes: filenames = [f for f in filenames if os.path.basename(f) not in args.excludes] if not filenames: print('No files found', file=sys.stderr) return 1 normal_report, error_messages, exit_code = _generate_mypy_report( filenames, args.config_file, args.cache_dir ) if error_messages: print('mypy error encountered', file=sys.stderr) print(error_messages, file=sys.stderr) print('\nRegular report continues:') print(normal_report, file=sys.stderr) return exit_code errors_parsed = _get_errors(normal_report) print('\n{} files checked'.format(len(filenames))) if not normal_report: print('No errors found') else: print('{} errors'.format(len(errors_parsed))) print(normal_report) print('\nChecked files:') print(''.join(['\n* {}'.format(f) for f in filenames])) # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[:-len(suffix)] testname = '{}.{}'.format(folder_name, file_name) xml = _get_xunit_content(errors_parsed, testname, filenames, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return exit_code def _generate_mypy_report(paths: List[str], config_file: Optional[str] = None, cache_dir: str = os.devnull) -> Tuple[str, str, int]: mypy_argv = [] mypy_argv.append('--cache-dir') mypy_argv.append(str(cache_dir)) if cache_dir == os.devnull: mypy_argv.append('--no-incremental') if config_file: mypy_argv.append('--config-file') mypy_argv.append(str(config_file)) mypy_argv.append('--show-error-context') mypy_argv.append('--show-column-numbers') mypy_argv += paths res = mypy.api.run(mypy_argv) # type: Tuple[str, str, int] return res def _get_xunit_content(errors: List[Match], testname: str, filenames: List[str], elapsed: float) -> str: xml = textwrap.dedent("""\ """).format( test_name=testname, test_count=max(len(errors), 1), error_count=len(errors), time='{:.3f}'.format(round(elapsed, 3)) ) if errors: # report each mypy error/warning as a failing testcase for error in errors: pos = '' if error.group('lineno'): pos += ':' + str(error.group('lineno')) if error.group('colno'): pos += ':' + str(error.group('colno')) xml += _dedent_to("""\ """, ' ').format( quoted_name=quoteattr( '{0[type]} ({0[filename]}'.format(error) + pos + ')'), test_name=testname, quoted_message=quoteattr('{0[msg]}'.format(error) + pos) ) else: # if there are no mypy problems report a single successful test xml += _dedent_to("""\ """, ' ').format(testname) # output list of checked files xml += ' Checked files:{escaped_files}\n \n'.format( escaped_files=escape(''.join(['\n* %s' % f for f in filenames])) ) xml += '\n' return xml def _get_files(paths: List[str]) -> List[str]: files = [] for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] dirnames.sort() # select files by extension for filename in sorted(filenames): if filename.endswith('.py'): files.append(os.path.join(dirpath, filename)) elif os.path.isfile(path): files.append(path) return [os.path.normpath(f) for f in files] def _get_errors(report_string: str) -> List[Match]: return list(re.finditer(r'^(?P([a-zA-Z]:)?([^:])+):((?P\d+):)?((?P\d+):)?\ (?Perror|warning|note):\ (?P.*)$', report_string, re.MULTILINE)) # noqa: E501 def _dedent_to(text: str, prefix: str) -> str: return textwrap.indent(textwrap.dedent(text), prefix) if __name__ == '__main__': # pragma: no cover sys.exit(main()) ament_lint-0.12.0/ament_mypy/ament_mypy/pytest_marker.py000066400000000000000000000013331420377356500235470ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def pytest_configure(config): config.addinivalue_line( 'markers', 'mypy: marks tests checking for mypy compliance') ament_lint-0.12.0/ament_mypy/doc/000077500000000000000000000000001420377356500166675ustar00rootroot00000000000000ament_lint-0.12.0/ament_mypy/doc/index.rst000066400000000000000000000011201420377356500205220ustar00rootroot00000000000000ament_mypy ============ Checks the code syntax and style of Python source files using `mypy `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_mypy [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_mypy `_. ament_lint-0.12.0/ament_mypy/package.xml000066400000000000000000000016101420377356500202350ustar00rootroot00000000000000 ament_mypy 0.12.0 Support for mypy static type checking in ament. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Ted Kern python3-mypy ament_flake8 python3-pytest python3-pytest-mock ament_python ament_lint-0.12.0/ament_mypy/pytest.ini000066400000000000000000000000351420377356500201510ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_mypy/resource/000077500000000000000000000000001420377356500177515ustar00rootroot00000000000000ament_lint-0.12.0/ament_mypy/resource/ament_mypy000066400000000000000000000000001420377356500220440ustar00rootroot00000000000000ament_lint-0.12.0/ament_mypy/setup.py000066400000000000000000000027031420377356500176360ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_mypy' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], package_data={'': [ 'configuration/ament_mypy.ini', ]}, zip_safe=False, author='Ted Kern', author_email='ted.kern@canonical.com', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check Python static typing using mypy.', long_description="""\ The ability to check code for user specified static typing with mypy.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_mypy = ament_mypy.main:main', ], 'pytest11': [ 'ament_mypy = ament_mypy.pytest_marker', ], }, ) ament_lint-0.12.0/ament_mypy/test/000077500000000000000000000000001420377356500171015ustar00rootroot00000000000000ament_lint-0.12.0/ament_mypy/test/test_ament_mypy.py000066400000000000000000000235161420377356500227030ustar00rootroot00000000000000import os from pathlib import Path import xml.etree.ElementTree as ET import ament_mypy.main import pytest @pytest.fixture() def use_dir(tmpdir_factory): """Create a sample data directory for testing. Directory layout:: use_me |-- me_too | +-- 03.py |-- 01.py |-- 02.py +-- 03.txt """ use_me = tmpdir_factory.mktemp('use_me') files = [use_me.join(arg) for arg in ['01.py', '02.py', '03.txt']] files.append(use_me.join('me_too', '03.py')) for tmp_file in files: tmp_file.write('', ensure=True) return use_me @pytest.fixture() def ignore_dir(tmpdir_factory): """Create a sample data directory for testing. Directory layout:: ignore_me |-- me_too | +-- 03.py |-- 01.py |-- 02.py |-- 03.txt +-- AMENT_IGNORE """ ignore_me = tmpdir_factory.mktemp('ignore_me') files = [ignore_me.join(arg) for arg in ['01.py', '02.py', '03.txt', 'AMENT_IGNORE']] files.append(ignore_me.join('me_too', '03.py')) for tmp_file in files: tmp_file.write('', ensure=True) return ignore_me @pytest.fixture() def mock_mypy_succ(mocker): return mocker.patch('ament_mypy.main.mypy.api.run', return_value=('', '', 0)) @pytest.fixture() def sample_errors(use_dir): def filename(slug: str): return str(use_dir.join(slug)) error_line_col = '{}:0:0: error: error message'.format(filename('lc.py')) error_line = '{}:0: error: error message'.format(filename('l.py')) error_no_pos = '{}: error: error message'.format(filename('no_pos.py')) warning = '{}: warning: warning message'.format(filename('warn.py')) return [error_line_col, error_line, error_no_pos, warning] @pytest.fixture() def mock_mypy_generate_fail(mocker, sample_errors, use_dir): mock_fail = mocker.patch('ament_mypy.main._generate_mypy_report') mock_fail.return_value = ('\n'.join(sample_errors), '', 1) return mock_fail @pytest.fixture() def mock_generate_report(mocker): return mocker.patch('ament_mypy.main._generate_mypy_report') def test__generate_mypy_report(mock_mypy_succ): # Test if correctly returns mypy output files = ['a.py', 'b.py'] assert ament_mypy.main._generate_mypy_report(files) == mock_mypy_succ.return_value # Test if paths were forwarded to mypy args, _ = mock_mypy_succ.call_args assert all(file_name in args[0] for file_name in files) # Test if config file is forwarded to mypy assert ament_mypy.main._generate_mypy_report(files, 'a.ini') == mock_mypy_succ.return_value args, _ = mock_mypy_succ.call_args assert len(args[0]) > 1 assert any(args[0][i] == '--config-file' and args[0][i + 1] == 'a.ini' for i in range(len(args[0]) - 1)) # Test if setting null cache dir prevents caching assert ament_mypy.main._generate_mypy_report(files, cache_dir=os.devnull) \ == mock_mypy_succ.return_value args, _ = mock_mypy_succ.call_args assert len(args[0]) > 1 assert any(args[0][i] == '--cache-dir' and args[0][i + 1] == os.devnull for i in range(len(args[0]) - 1)) assert '--no-incremental' in args[0] # Test if non-null cache dir uses caching assert ament_mypy.main._generate_mypy_report(files, cache_dir='/tmp') \ == mock_mypy_succ.return_value args, _ = mock_mypy_succ.call_args assert len(args[0]) > 1 assert any(args[0][i] == '--cache-dir' and args[0][i + 1] == '/tmp' for i in range(len(args[0]) - 1)) assert '--no-incremental' not in args[0] def test_main_success(mock_generate_report, use_dir): mock_generate_report.return_value = ('', '', 0) # Test that a successful lint returns 0 assert ament_mypy.main.main([str(use_dir.join('01.py'))]) == 0 # Sub-test that no other files in directory were checked, too args, _ = mock_generate_report.call_args assert str(use_dir.join('01.py')) in args[0] assert str(use_dir.join('02.py')) not in args[0] assert str(use_dir.join('03.txt')) not in args[0] # Test that a directory recursively is checked assert ament_mypy.main.main([str(use_dir)]) == 0 args, _ = mock_generate_report.call_args assert str(use_dir.join('01.py')) in args[0] assert str(use_dir.join('02.py')) in args[0] assert str(use_dir.join('03.py')) not in args[0] # Test that non-'.py' files were ignored assert str(use_dir.join('03.txt')) not in args[0] def test_main_exclude(mock_generate_report, use_dir): mock_generate_report.return_value = ('', '', 0) # Test that excluding a file that was passed as an arg works assert ament_mypy.main.main([str(use_dir.join('01.py')), str(use_dir.join('02.py')), '--exclude', '02.py']) == 0 args, _ = mock_generate_report.call_args assert str(use_dir.join('01.py')) in args[0] assert str(use_dir.join('02.py')) not in args[0] # Test that excluding a file when its directory was passed works assert ament_mypy.main.main([str(use_dir), '--exclude', '02.py']) == 0 args, _ = mock_generate_report.call_args assert str(use_dir.join('01.py')) in args[0] assert str(use_dir.join('02.py')) not in args[0] # Test that an error is raised when all files are excluded mock_generate_report.reset_mock() assert ament_mypy.main.main(['02.py', '--exclude', '02.py']) mock_generate_report.assert_not_called() def test_ignore(use_dir, ignore_dir): mock_generate_report.return_value = ('', '', 0) # Test if returns no error if at least one valid dir is presented assert ament_mypy.main.main([str(use_dir), str(ignore_dir)]) == 0 def test_fail(mocker, mock_mypy_generate_fail, use_dir): # Test if an error message from mypy causes a non-zero return assert ament_mypy.main.main([str(use_dir.join('01.py'))]) # Test that a failure correctly forwards the error code out of main ret_val = mock_mypy_generate_fail.return_value test_val = 5 mock_mypy_generate_fail.return_value = (ret_val[0], ret_val[1], test_val) assert ament_mypy.main.main([str(use_dir.join('01.py'))]) == test_val test_val = 6 mock_mypy_generate_fail.return_value = (ret_val[0], ret_val[1], test_val) assert ament_mypy.main.main([str(use_dir.join('01.py'))]) == test_val # Test that an error code even with a blank message still gets forwarded out mock_mypy_generate_fail.return_value = ('', '', test_val) assert ament_mypy.main.main([str(use_dir.join('01.py'))]) == test_val def test_main_error(mocker, use_dir): # Test if an error from mypy invocation causes a non-zero return mock_error = mocker.patch('ament_mypy.main._generate_mypy_report') mock_error.return_value = ('', 'mypy error occurred', 15) assert ament_mypy.main.main([str(use_dir)]) == 15 def test_main_config_file(mock_generate_report, mocker, use_dir): # Test that a valid config file is passed on to mypy conf_file = use_dir.join('mypy.ini') conf_file.write('[mypy]') mock_generate_report.return_value = ('', None, 0) assert ament_mypy.main.main([str(use_dir.join('01.py')), '--config', str(conf_file)]) == 0 args, _ = mock_generate_report.call_args assert args[1] == conf_file # Test program handles no config file being passed correctly assert ament_mypy.main.main([str(use_dir.join('01.py'))]) == 0 args, _ = mock_generate_report.call_args assert args[1] is not None # Test program raises error when invalid config file is presented assert ament_mypy.main.main([str(use_dir.join('01.py')), '--config', str(use_dir.join('aeiou.ini'))]) == 1 def test_main_xunit(mock_mypy_generate_fail, mocker, use_dir): mock_xunit = mocker.patch('ament_mypy.main._get_xunit_content') mock_xunit.return_value = "\n" # Test that generating report files works assert ament_mypy.main.main([str(use_dir), '--xunit-file', str(use_dir.join('testgen'))]) assert mock_xunit.call_args[0][1].endswith('testgen') assert Path(use_dir.join('testgen')).is_file() # Test that .xml file suffix is processed correctly assert ament_mypy.main.main([str(use_dir), '--xunit-file', str(use_dir.join('testgen.xml'))]) assert mock_xunit.call_args[0][1].endswith('testgen') assert Path(use_dir.join('testgen.xml')).is_file() # Test that .xunit suffix is also handled assert ament_mypy.main.main([str(use_dir), '--xunit-file', str(use_dir.join('testgen.xunit.xml'))]) assert mock_xunit.call_args[0][1].endswith('testgen') assert Path(use_dir.join('testgen.xunit.xml')).is_file() # Test that intermediate directories are handled assert ament_mypy.main.main([str(use_dir), '--xunit-file', str(use_dir.join('testdir', 'testgen'))]) assert mock_xunit.call_args[0][1].endswith('testgen') assert Path(use_dir.join('testdir', 'testgen')).is_file() # Test that the errors/warnings generated are all forwarded to the xml generator assert len(mock_xunit.call_args[0][0]) == 4 def test__get_xunit_content(mocker, sample_errors): # Test that all errors are accounted for in xml errors = ament_mypy.main._get_errors('\n'.join(sample_errors)) xml = ament_mypy.main._get_xunit_content(errors, 'tst', [err.group('filename') for err in errors], .01) root = ET.fromstring(xml) assert root.get('name') == 'tst' assert root.get('failures') == str(len(errors)) assert len(root) == len(errors) + 1 # Test that a no failure case works xml = ament_mypy.main._get_xunit_content([], 'tst', [err.group('filename') for err in errors], .01) root = ET.fromstring(xml) assert root.get('failures') == '0' assert(len(root)) == 2 ament_lint-0.12.0/ament_mypy/test/test_flake8.py000066400000000000000000000015371420377356500216720ustar00rootroot00000000000000# Copyright 2019 Canonical, Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_mypy/test/test_mypy.py000066400000000000000000000013341420377356500215110ustar00rootroot00000000000000# Copyright 2019 Canonical, Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_mypy.main import main def test_mypy(): rc = main(argv=['--exclude', 'test']) assert rc == 0, 'Found code style errors / warnings' ament_lint-0.12.0/ament_pclint/000077500000000000000000000000001420377356500164155ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/CHANGELOG.rst000066400000000000000000000143231420377356500204410ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_pclint ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * [ament_copyright] Fix file exclusion behavior (`#327 `_) * [ament_copyright] Fix file exclusion behavior This commit fixes the faulty file exclusion behavior reported in https://github.com/ament/ament_lint/issues/326. Specifically, the exclusion list is matched against traversed files in the `crawler` module. Changes inspired by https://github.com/ament/ament_lint/pull/299/. * Update excluded file path in copyright tests Since file names are not indiscriminately matched throughout the search tree anymore, the excluded files listed in the copyright tests need to be updated relative to the root of the package. * Add test cases to check exclusion behavior Specifically, these tests check for: - Incorrect exclusion of single filenames. - Correct exclusion of relatively/absolutely addressed filenames. - Correct exclusion of wildcarded paths. * Add unit tests for crawler module These unit tests make sure both search and exclusion behaviors are correctly demonstrated by the `ament_copyright.crawler` module. * Contributors: Abrar Rahman Protyasha, Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Add pytest marks to ament_pclint tests. (`#202 `_) * Add pytest marks to ament_pclint tests. * fix failed tests Co-authored-by: Miaofei * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan, Steven! Ragnarök 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * Generate xunit files valid for the junit10.xsd (`#220 `_) * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dirk Thomas, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Convert list comprehension to generator (`#179 `_) Addresses flake8 C412 errors introduced by flake8-comprehension 2.2.0 * Contributors: Dirk Thomas, Scott K Logan 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ * Fix another occurrence of flake8 f999. (`#123 `_) * Contributors: Chris Lalancette 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ * Improvements to ament_pclint configuration (`#112 `_) * Improvements to ament_pclint configuration * Improvement to ament_cmake_pclint * Contributors: jpsamper2009 0.5.2 (2018-06-27) ------------------ * Add ament_pclint and ament_cmake_pclint packages (`#101 `_) * Add ament_pclint and ament_cmake_pclint packages * Skip pclint creation if pclint executable not found * Update license to Apache 2.0 - Use config file with permissive license: http://www.gimpel.com/html/pub90/au-misra3.lnt * Fixing copyright and formatting issues. * Add test dependencies * Fix remaining copyright/license notices. * Version Bump to 0.5.1 for pclint packages. * Contributors: Michael Carroll 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ * Revert "Add ament package for pclint" (`#100 `_) * Merge pull request `#98 `_ from jpsamper2009/ament_pclint Add ament package for pclint * Update license to Apache 2.0 - Use config file with permissive license: http://www.gimpel.com/html/pub90/au-misra3.lnt * Add ament_pclint and ament_cmake_pclint packages * Contributors: Juan Pablo Samper, Michael Carroll 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_pclint/ament_pclint/000077500000000000000000000000001420377356500210725ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/ament_pclint/__init__.py000066400000000000000000000000001420377356500231710ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/ament_pclint/config/000077500000000000000000000000001420377356500223375ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/ament_pclint/config/au-misra-cpp.lnt000066400000000000000000001455611420377356500253700ustar00rootroot00000000000000// --------------------------------------------------------------------- // This file is provided by Gimpel Software (www.gimpel.com) for use with // PC-lint Plus. // // Redistribution and use of this file, with or without modification, is // permitted provided that any such redistribution retains this notice. // --------------------------------------------------------------------- // au-misra-cpp.lnt -- Author options - MISRA C++ /* This options file can be used to explicitly activate those checks advocated by the Motor Industry Software Reliability Association for C++ code. You can use this file directly when linting your programs as in: lin au-misra-cpp files Gimpel Software relies on the document, "MISRA-C++:2008 Guidelines for the use of the C++ language in critical systems", copyright 2008 by MIRA Limited, as the primary source for this file. Gimpel Software makes no warranty as to the completeness or applicability of this options file and reserves the right to amend or alter the official contents of such at any time. "MISRA" is a registered trademark of MIRA Limited, held on behalf of the MISRA Consortium. */ /* Rule 0-1-1 (req) *********************************/ /* 527 - statement is unreachable due to unconditional transfer of control */ +e527 // +elib(527) -append(527,[MISRA C++ Rule 0-1-1]) /* 506 - integer constant expression used in boolean context */ +e506 // +elib(506) -append(506,[MISRA C++ Rule 0-1-1]) /* 681 - loop is likely not entered */ +e681 // +elib(681) -append(681,[MISRA C++ Rule 0-1-1]) /* 827 - loop can only be reached via goto due to unconditional transfer of control */ +e827 // +elib(827) -append(827,[MISRA C++ Rule 0-1-1]) /* 685 - relational operator always evaluates to true/false */ +e685 // +elib(685) -append(685,[MISRA C++ Rule 0-1-1]) /* 774 - boolean condition always evaluates to true/false */ +e774 // +elib(774) -append(774,[MISRA C++ Rule 0-1-1]) /* 944 - left/right operand always evaluates to true/false */ +e944 // +elib(944) -append(944,[MISRA C++ Rule 0-1-1]) /* Rule 0-1-2 (req) *********************************/ /* 685 - relational operator always evaluates to true/false */ +e685 // +elib(685) -append(685,[MISRA C++ Rule 0-1-2]) /* 774 - boolean condition always evaluates to true/false */ +e774 // +elib(774) -append(774,[MISRA C++ Rule 0-1-2]) /* 827 - loop can only be reached via goto due to unconditional transfer of control */ +e827 // +elib(827) -append(827,[MISRA C++ Rule 0-1-2]) /* 944 - left/right operand always evaluates to true/false */ +e944 // +elib(944) -append(944,[MISRA C++ Rule 0-1-2]) /* Rule 0-1-3 (req) *********************************/ /* 528 - static symbol not referenced */ +e528 // +elib(528) -append(528,[MISRA C++ Rule 0-1-3]) /* 529 - local variable not subsequently referenced */ +e529 // +elib(529) -append(529,[MISRA C++ Rule 0-1-3]) /* 714 - external symbol was defined but not referenced */ +e714 // +elib(714) -append(714,[MISRA C++ Rule 0-1-3]) /* 752 - local declarator not referenced */ +e752 // +elib(752) -append(752,[MISRA C++ Rule 0-1-3]) /* 757 - global declarator not referenced */ +e757 // +elib(757) -append(757,[MISRA C++ Rule 0-1-3]) /* 1715 - static member symbol not referenced */ +e1715 // +elib(1715) -append(1715,[MISRA C++ Rule 0-1-3]) /* Rule 0-1-4 (req) *********************************/ /* 528 - static symbol not referenced */ +e528 // +elib(528) -append(528,[MISRA C++ Rule 0-1-4]) /* 529 - local variable not subsequently referenced */ +e529 // +elib(529) -append(529,[MISRA C++ Rule 0-1-4]) /* 550 - local variable not subsequently accessed */ +e550 // +elib(550) -append(550,[MISRA C++ Rule 0-1-4]) /* 551 - static variable not accessed */ +e551 // +elib(551) -append(551,[MISRA C++ Rule 0-1-4]) /* 552 - external variable not accessed */ +e552 // +elib(552) -append(552,[MISRA C++ Rule 0-1-4]) /* Rule 0-1-5 (req) *********************************/ /* 751 - local typedef not referenced */ +e751 // +elib(751) -append(751,[MISRA C++ Rule 0-1-5]) /* 753 - local tag not referenced */ +e753 // +elib(753) -append(753,[MISRA C++ Rule 0-1-5]) /* 756 - global typedef not referenced */ +e756 // +elib(756) -append(756,[MISRA C++ Rule 0-1-5]) /* 758 - global tag not referenced */ +e758 // +elib(758) -append(758,[MISRA C++ Rule 0-1-5]) /* Rule 0-1-6 (req) *********************************/ /* 438 - last value assigned to symbol not used */ +e438 // +elib(438) -append(438,[MISRA C++ Rule 0-1-6]) /* 838 - previous value assigned to symbol not used */ +e838 // +elib(838) -append(838,[MISRA C++ Rule 0-1-6]) /* Rule 0-1-7 (req) *********************************/ /* 534 - ignoring return value of function */ +e534 // +elib(534) -append(534,[MISRA C++ Rule 0-1-7]) /* Rule 0-1-8 (req) *********************************/ /* 9175 - function has void return type and no external side-effects */ +e9175 // +elib(9175) -append(9175,[MISRA C++ Rule 0-1-8]) /* Rule 0-1-9 (req) *********************************/ /* 438 - last value assigned to symbol not used */ +e438 // +elib(438) -append(438,[MISRA C++ Rule 0-1-9]) /* 587 - predicate can be pre-determined and always evaluates to true/false */ +e587 // +elib(587) -append(587,[MISRA C++ Rule 0-1-9]) /* 685 - relational operator always evaluates to true/false */ +e685 // +elib(685) -append(685,[MISRA C++ Rule 0-1-9]) /* 774 - boolean condition always evaluates to true/false */ +e774 // +elib(774) -append(774,[MISRA C++ Rule 0-1-9]) /* 838 - previous value assigned to symbol not used */ +e838 // +elib(838) -append(838,[MISRA C++ Rule 0-1-9]) /* 944 - left/right operand always evaluates to true/false */ +e944 // +elib(944) -append(944,[MISRA C++ Rule 0-1-9]) /* 948 - operator always evaluates to true/false */ +e948 // +elib(948) -append(948,[MISRA C++ Rule 0-1-9]) /* Rule 0-1-10 (req) *********************************/ /* 528 - static symbol not referenced */ +e528 // +elib(528) -append(528,[MISRA C++ Rule 0-1-10]) /* 714 - external symbol was defined but not referenced */ +e714 // +elib(714) -append(714,[MISRA C++ Rule 0-1-10]) /*1714 - member function not referenced */ +e1714 // +elib(1714) -append(1714,[MISRA C++ Rule 0-1-10]) /* default constructor not referenced */ +e1914 // +elib(1914) -append(1914,[MISRA C++ Rule 0-1-10]) /* Rule 0-1-11 (req) *********************************/ /* 715 - named parameter not subsequently referenced */ +e715 // +elib(715) -append(715,[MISRA C++ Rule 0-1-11]) /* Rule 0-1-12 (req) *********************************/ /* 715 - named parameter not subsequently referenced */ +e715 // +elib(715) -append(715,[MISRA C++ Rule 0-1-12]) /* Rule 0-2-1 (req) *********************************/ /* See rule 9-5-1. */ /* Rule 0-3-1 (doc) *********************************/ /* Static Analysis is provided by using PC-lint Plus */ /* Rule 0-3-2 (req) *********************************/ /* 534 - ignoring return value of function */ +e534 // +elib(534) -append(534,[MISRA C++ Rule 0-3-2]) /* Rule 0-4-1 (doc) *********************************/ /* not statically checkable */ /* Rule 0-4-2 (doc) *********************************/ /* not statically checkable */ /* Rule 0-4-3 (doc) *********************************/ /* not statically checkable */ /* Rule 1-0-1 (req) *********************************/ -std(c++2003) /* ensure ISO C++ 2003 compliance */ /* Rule 1-0-2 (req) *********************************/ /* not statically checkable */ /* Rule 1-0-3 (doc) *********************************/ /* not statically checkable */ /* Rule 2-2-1 (doc) *********************************/ /* not statically checkable */ /* Rule 2-3-1 (req) *********************************/ -ftg /* disable trigraph expansion */ /* 584 - trigraph sequence detected */ +e584 // +elib(584) -append(584,[MISRA C++ Rule 2-3-1]) /* 739 - trigraph sequence in string literal */ +e739 // +elib(739) -append(739,[MISRA C++ Rule 2-3-1]) /* Rule 2-5-1 (adv) *********************************/ /* 9102 - possible digraph sequence */ +e9102 // +elib(9102) -append(9102,[MISRA C++ Rule 2-5-1]) /* Rule 2-7-1 (req) *********************************/ -fnc /* disable nested comments */ /* 602 - slash star within block comment */ +e602 // +elib(602) -append(602,[MISRA C++ Rule 2-7-1]) /* Rule 2-7-2 (req) *********************************/ /* not statically checkable */ /* Rule 2-7-3 (adv) *********************************/ /* not statically checkable */ /* Rule 2-10-1 (req) *********************************/ +fta /* enable typographical ambiguity checking */ /* 9046 - symbol is typographically ambiguous with respect to string */ +e9046 // +elib(9046) -append(9046,[MISRA C++ Rule 2-10-1]) /* Rule 2-10-2 (req) *********************************/ /* 578 - declaration hides symbol */ +e578 // +elib(578) -append(578,[MISRA C++ Rule 2-10-2]) /* 1411 - member with different signature hides virtual member */ +e1411 // +elib(1411) -append(1411,[MISRA C++ Rule 2-10-2]) /* 1511 - member hides non-virtual member */ +e1511 // +elib(1511) -append(1511,[MISRA C++ Rule 2-10-2]) /* 1516 - data member hides inherited member */ +e1516 // +elib(1516) -append(1516,[MISRA C++ Rule 2-10-2]) /* Rule 2-10-3 (req) *********************************/ /* not currently supported */ /* Rule 2-10-4 (req) *********************************/ /* not currently supported */ /* Rule 2-10-5 (adv) *********************************/ /* 9103 - identifier with static storage is reused */ +e9103 // +elib(9103) -append(9103,[MISRA C++ Rule 2-10-5]) /* Rule 2-10-6 (req) *********************************/ /* 18 - redefinition of symbol as different kind of symbol */ +e18 // +elib(18) -append(18,[MISRA C++ Rule 2-10-6]) /* Rule 2-13-1 (req) *********************************/ /* 606 - non-ANSI escape sequence */ +e606 // +elib(606) -append(606,[MISRA C++ Rule 2-13-1]) /* Rule 2-13-2 (req) *********************************/ /* 9104 - octal escape sequence used */ +e9104 // +elib(9104) -append(9104,[MISRA C++ Rule 2-13-2]) /* Rule 2-13-3 (req) *********************************/ /* 9105 - unsigned octal and hexadecimal literals require a 'U' suffix */ +e9105 // +elib(9105) -append(9105,[MISRA C++ Rule 2-13-3]) /* Rule 2-13-4 (req) *********************************/ /* 9106 - lower case literal suffix */ +e9106 // +elib(9106) -append(9106,[MISRA C++ Rule 2-13-4]) /* Rule 2-13-5 (req) *********************************/ /* 707 - mixing narrow and wide string literals in concatenation */ +e707 // +elib(707) -append(707,[MISRA C++ Rule 2-13-5]) /* Rule 3-1-1 (req) *********************************/ /* 9107 - header cannot be included in more than one translation unit because of the definition of symbol */ +e9107 // +elib(9107) -append(9107,[MISRA C++ Rule 3-1-1]) /* Rule 3-1-2 (req) *********************************/ /* 9108 - function declared at block scope */ +e9108 // +elib(9108) -append(9108,[MISRA C++ Rule 3-1-2]) /* Rule 3-1-3 (req) *********************************/ /* 9067 - extern array declared without size or initializer */ +e9067 // +elib(9067) -append(9067,[MISRA C++ Rule 3-1-3]) /* Rule 3-2-1 (req) *********************************/ /* 18 - redefinition of symbol as different kind of symbol */ +e18 // +elib(18) -append(18,[MISRA C++ Rule 3-2-1]) /* 31 - redefinition of symbol */ +e31 // +elib(31) -append(31,[MISRA C++ Rule 3-2-1]) /* Rule 3-2-2 (req) *********************************/ /* 15 - symbol redeclared with different type */ +e15 // +elib(15) -append(15,[MISRA C++ Rule 3-2-2]) /* 31 - redefinition of symbol */ +e31 // +elib(31) -append(31,[MISRA C++ Rule 3-2-2]) /* Rule 3-2-3 (req) *********************************/ /* 9004 - object/function previously declared */ +e9004 // +elib(9004) -append(9004,[MISRA C++ Rule 3-2-3]) /* Rule 3-2-4 (req) *********************************/ /* 15 - symbol redeclared with different type */ +e15 // +elib(15) -append(15,[MISRA C++ Rule 3-2-4]) /* 31 - redefinition of symbol */ +e31 // +elib(31) -append(31,[MISRA C++ Rule 3-2-4]) /* Rule 3-3-1 (req) *********************************/ /* 759 - header declaration for symbol could be moved from header to module */ +e759 // +elib(759) -append(759,[MISRA C++ Rule 3-3-1]) /* 765 - external symbol could be made static */ +e765 // +elib(765) -append(765,[MISRA C++ Rule 3-3-1]) /* Rule 3-3-2 (req) *********************************/ /* 401 - not previously declared static */ +e401 // +elib(401) -append(401,[MISRA C++ Rule 3-3-2]) /* 839 - storage class of symbol assumed static */ +e839 // +elib(839) -append(839,[MISRA C++ Rule 3-3-2]) /* Rule 3-4-1 (req) *********************************/ /* 9003 - could define global variable 'Symbol' within function */ +e9003 // +elib(9003) -append(9003,[MISRA C++ Rule 3-4-1]) /* Rule 3-9-1 (req) *********************************/ /* 9073 - parameter 'Integer' of function 'Symbol' has type alias name difference with previous declaration ('Type' vs 'Type') */ +e9073 // +elib(9073) -append(9073,[MISRA C++ Rule 3-9-1]) /* 9094 - return type of function 'Symbol' has type alias name difference with previous declaration ('Type' vs 'Type') */ +e9094 // +elib(9094) -append(9094,[MISRA C++ Rule 3-9-1]) /* 9168 - variable has type alias name difference with previous declaration */ +e9168 // +elib(9168) -append(9168,[MISRA C++ Rule 3-9-1]) /* Rule 3-9-2 (adv) *********************************/ /* 970 - use of modifier or type outside of a typedef */ +e970 // +elib(970) -esym(970,wchar_t) -append(970,[MISRA C++ Rule 3-9-2]) // For the duration, we are presuming MISRA does not want // diagnostics for the bool type. -esym(970,bool) /* Rule 3-9-3 (req) *********************************/ /* 9110 - bit representation of a floating point type used */ +e9110 // +elib(9110) -append(9110,[MISRA C++ Rule 3-9-3]) /* Rule 4-5-1 (req) *********************************/ /* 9111 - boolean expression used with non-permitted operator */ +e9111 // +elib(9111) -append(9111,[MISRA C++ Rule 4-5-1]) /* Rule 4-5-2 (req) *********************************/ /* not currently supported */ /* Rule 4-5-3 (req) *********************************/ /* 9112 - plain character expression used with non-permitted operator */ +e9112 // +elib(9112) -append(9112,[MISRA C++ Rule 4-5-3]) /* Rule 4-10-1 (req) *********************************/ /* not currently supported */ /* Rule 4-10-2 (req) *********************************/ /* 910 - implicit conversion of null pointer constant to pointer */ +e910 // +elib(910) -emacro((910), NULL) /* explicit exception */ -append(910,[MISRA C++ Rule 4-10-2]) /* Rule 5-0-1 (req) *********************************/ /* 564 - variable depends on order of evaluation */ +e564 // +elib(564) -append(564,[MISRA C++ Rule 5-0-1]) /* Rule 5-0-2 (adv) *********************************/ /* 9113 - dependence placed on C++ operator precedence */ +e9113 // +elib(9113) -append(9113,[MISRA C++ Rule 5-0-2]) /* Rule 5-0-3 (req) *********************************/ /* 9114 - implicit conversion of integer cvalue expression */ +e9114 // +elib(9114) -append(9114,[MISRA C++ Rule 5-0-3]) /* 9116 - implicit conversion of floating point cvalue expression */ +e9116 // +elib(9116) -append(9116,[MISRA C++ Rule 5-0-3]) /* Rule 5-0-4 (req) *********************************/ /* 9117 - implicit conversion changes signedness */ +e9117 // +elib(9117) -append(9117,[MISRA C++ Rule 5-0-4]) /* Rule 5-0-5 (req) *********************************/ /* 9115 - implicit conversion from integer to floating point type */ +e9115 // +elib(9115) -append(9115,[MISRA C++ Rule 5-0-5]) /* 9118 - implicit conversion from floating point to integer type */ +e9118 // +elib(9118) -append(9118,[MISRA C++ Rule 5-0-5]) /* Rule 5-0-6 (req) *********************************/ /* 9119 - implicit conversion of integer to smaller type */ +e9119 // +elib(9119) -append(9119,[MISRA C++ Rule 5-0-6]) /* 9120 - implicit conversion of floating point to smaller type */ +e9120 // +elib(9120) -append(9120,[MISRA C++ Rule 5-0-6]) /* Rule 5-0-7 (req) *********************************/ /* 9121 - cast of cvalue expression from integer to floating point type */ +e9121 // +elib(9121) -append(9121,[MISRA C++ Rule 5-0-7]) /* 9122 - cast of cvalue expression from floating point to integer type */ +e9122 // +elib(9122) -append(9122,[MISRA C++ Rule 5-0-7]) /* Rule 5-0-8 (req) *********************************/ /* 9123 - cast of integer cvalue expression to larger type */ +e9123 // +elib(9123) -append(9123,[MISRA C++ Rule 5-0-8]) /* 9124 - cast of floating point cvalue expression to larger type */ +e9124 // +elib(9124) -append(9124,[MISRA C++ Rule 5-0-8]) /* Rule 5-0-9 (req) *********************************/ /* 9125 - cast of integer cvalue expression changes signedness */ +e9125 // +elib(9125) -append(9125,[MISRA C++ Rule 5-0-9]) /* Rule 5-0-10 (req) *********************************/ /* 9126 - result of operator applied to underlying type must be cast */ +e9126 // +elib(9126) -append(9126,[MISRA C++ Rule 5-0-10]) /* Rule 5-0-11 (req) *********************************/ /* 9128 - plain char type mixed with type other than plain char */ +e9128 // +elib(9128) -append(9128,[MISRA C++ Rule 5-0-11]) /* Rule 5-0-12 (req) *********************************/ /* Not currently supported */ /* Rule 5-0-13 (req) *********************************/ /* 909 - implicit boolean conversion from type 'Type' */ +e909 // +elib(909) -append(909,[MISRA C++ Rule 5-0-13]) /* Rule 5-0-14 (req) *********************************/ /* 909 - implicit boolean conversion from type 'Type' */ +e909 // +elib(909) -append(909,[MISRA C++ Rule 5-0-14]) /* Rule 5-0-15 (req) *********************************/ /* 947 - pointer subtraction */ +e947 // +elib(947) -append(947,[MISRA C++ Rule 5-0-15]) /* 9016 - performing pointer arithmetic via addition/subtraction */ +e9016 // +elib(9016) -append(9016,[MISRA C++ Rule 5-0-15]) /* Rule 5-0-16 (req) *********************************/ /* 415 - likely out of bounds pointer access */ +e415 // +elib(415) -append(415,[MISRA C++ Rule 5-0-16]) /* 416 - likely creating out-of-bounds pointer */ +e416 // +elib(416) -append(416,[MISRA C++ Rule 5-0-16]) /* 661 - potential out of bounds pointer access */ +e661 // +elib(661) -append(661,[MISRA C++ Rule 5-0-16]) /* 662 - possibly creating out-of-bounds pointer */ +e662 // +elib(662) -append(662,[MISRA C++ Rule 5-0-16]) /* Rule 5-0-17 (req) *********************************/ /* 947 - pointer subtraction */ +e947 // +elib(947) -append(947,[MISRA C++ Rule 5-0-17]) /* Rule 5-0-18 (req) *********************************/ /* 946 - relational operator applied to pointers */ +e946 // +elib(946) -append(946,[MISRA C++ Rule 5-0-18]) /* Rule 5-0-19 (req) *********************************/ /* 9025 - more than two levels of pointer indirection */ +e9025 // +elib(9025) -append(9025,[MISRA C++ Rule 5-0-19]) /* Rule 5-0-20 (req) *********************************/ /* 9172 - bitwise operator 'Operator' used with non-const operands of differing underlying types */ +e9172 // +elib(9172) -append(9172,[MISRA C++ Rule 5-0-20]) /* Rule 5-0-21 (req) *********************************/ /* 9130 - bitwise operator applied to signed underlying type */ +e9130 // +elib(9130) -append(9130,[MISRA C++ Rule 5-0-21]) /* Rule 5-2-1 (req) *********************************/ /* 9131 - left/right side of logical operator is not a postfix expression */ +e9131 // +elib(9131) -append(9131,[MISRA C++ Rule 5-2-1]) /* Rule 5-2-2 (req) *********************************/ /* 1774 - only dynamic_cast can indicate a failure by returning null */ +e1774 // +elib(1774) -append(1774,[MISRA C++ Rule 5-2-2]) /* 1939 - casting from base class to derived class */ +e1939 // +elib(1939) -append(1939,[MISRA C++ Rule 5-2-2]) /* Rule 5-2-3 (adv) *********************************/ /* 9171 - downcast of polymorphic type 'Type' to type 'Type' */ +e9171 // +elib(9171) -append(9171,[MISRA C++ Rule 5-2-3]) /* Rule 5-2-4 (req) *********************************/ /* 1924 - use of c-style cast */ +e1924 // +elib(1924) -append(1924,[MISRA C++ Rule 5-2-4]) /* Rule 5-2-5 (req) *********************************/ /* 9005 - cast drops qualifier */ +e9005 // +elib(9005) -append(9005,[MISRA C++ Rule 5-2-5]) /* Rule 5-2-6 (req) *********************************/ /* 611 - cast between pointer to function type and pointer to object type */ +e611 // +elib(611) -append(611,[MISRA C++ Rule 5-2-6]) /* Rule 5-2-7 (req) *********************************/ +e9176 // +elib(9176) -append(9176,[MISRA C++ Rule 5-2-7]) /* Rule 5-2-8 (adv) *********************************/ /* 923 - explicit cast from 'Type' to 'Type' (pointer to non-pointer) */ +e923 // +elib(923) -append(923,[MISRA C++ Rule 5-2-8]) /* 925 - explicit cast from 'Type' to 'Type' (pointer to void pointer) */ +e925 // +elib(925) -append(925,[MISRA C++ Rule 5-2-8]) /* Rule 5-2-9 (adv) *********************************/ /* 9091 - cast from pointer to integer type */ +e9091 // +elib(9091) -append(9091,[MISRA C++ Rule 5-2-9]) /* Rule 5-2-10 (adv) *********************************/ /* 9049 - increment/decrement operation combined with other operation with side-effects */ +e9049 // +elib(9049) -append(9049,[MISRA C++ Rule 5-2-10]) /* Rule 5-2-11 (req) *********************************/ /* overloading operator 'Operator' precludes short-circuit evaluation */ +e1753 // +elib(1753) -append(1753,[MISRA C++ Rule 5-2-11]) /* Rule 5-2-12 (req) *********************************/ /* 9132 - array type passed to function expecting a pointer */ +e9132 // +elib(9132) -append(9132,[MISRA C++ Rule 5-2-12]) /* Rule 5-3-1 (req) *********************************/ /* 9133 - boolean expression required for operator 'Operator' */ +e9133 // +elib(9133) -append(9133,[MISRA C++ Rule 5-3-1]) /* Rule 5-3-2 (req) *********************************/ /* 9134 - unary minus applied to operand with unsigned underlying type */ +e9134 // +elib(9134) -append(9134,[MISRA C++ Rule 5-3-2]) /* Rule 5-3-3 (req) *********************************/ /* 9135 - unary operator & overloaded */ +e9135 // +elib(9135) -append(9135,[MISRA C++ Rule 5-3-3]) /* Rule 5-3-4 (req) *********************************/ /* 9006 - 'sizeof' used on expression with side effect */ +e9006 // +elib(9006) -append(9006,[MISRA C++ Rule 5-3-4]) /* Rule 5-8-1 (req) *********************************/ /* 9136 - the shift value is at least the precision of the MISRA C++ underlying type of the left hand side */ +e9136 // +elib(9136) -append(9136,[MISRA C++ Rule 5-8-1]) /* Rule 5-14-1 (req) *********************************/ /* side effects on right hand of logical operator */ +e9007 // +elib(9007) -append(9007,[MISRA C++ Rule 5-14-1]) /* Rule 5-17-1 (req) *********************************/ /* not currently supported */ /* Rule 5-18-1 (req) *********************************/ /* 9008 - comma operator used */ +e9008 // +elib(9008) -append(9008,[MISRA C++ Rule 5-18-1]) /* Rule 5-19-1 (adv) *********************************/ /* 648 - overflow in computing constant for operation */ +e648 // +elib(648) -append(648,[MISRA C++ Rule 5-19-1]) /* Rule 6-2-1 (req) *********************************/ /* 720 - boolean test of assignment */ +e720 // +elib(720) -append(720,[MISRA C++ Rule 6-2-1]) /* 820 - boolean test of parenthesized assignment */ +e820 // +elib(820) -append(820,[MISRA C++ Rule 6-2-1]) /* 9084 - result of assignment operator used */ +e9084 // +elib(9084) -append(9084,[MISRA C++ Rule 6-2-1]) /* Rule 6-2-2 (req) *********************************/ /* 9137 - testing floating point values for equality (exact) */ +e9137 // +elib(9137) -append(9137,[MISRA C++ Rule 6-2-2]) /* Rule 6-2-3 (req) *********************************/ /* 9138 - null statement not on line by itself */ +e9138 // +elib(9138) -append(9138,[MISRA C++ Rule 6-2-3]) /* Rule 6-3-1 (req) *********************************/ /* 9012 - body should be a compound statement */ +e9012 // +elib(9012) -append(9012,[MISRA C++ Rule 6-3-1]) /* Rule 6-4-1 (req) *********************************/ /* 9012 - body should be a compound statement */ +e9012 // +elib(9012) -append(9012,[MISRA C++ Rule 6-4-1]) /* Rule 6-4-2 (req) *********************************/ /* 9013 - no 'else' at end of 'if ... else if' chain */ +e9013 // +elib(9013) -append(9013,[MISRA C++ Rule 6-4-2]) /* Rule 6-4-3 (req) *********************************/ /* 9042 - departure from MISRA switch syntax */ +e9042 // +elib(9042) -append(9042,[MISRA C++ Rule 6-4-3]) /* Rule 6-4-4 (req) *********************************/ /* 9055 - most closely enclosing compound statement of this case/default label is not a switch statement */ +e9055 // +elib(9055) -append(9055,[MISRA C++ Rule 6-4-4]) /* Rule 6-4-5 (req) *********************************/ /* 9090 - switch case lacks unconditional break or throw */ +e9090 // +elib(9090) -append(9090,[MISRA C++ Rule 6-4-5]) /* Rule 6-4-6 (req) *********************************/ /* 744 - switch statement has no default */ +e744 // +elib(744) -append(744,[MISRA C++ Rule 6-4-6]) /* 787 - enum constant not used within switch */ +e787 // +elib(787) -append(787,[MISRA C++ Rule 6-4-6]) /* 9139 - case label follows default in switch statement */ +e9139 // +elib(9139) -append(9139,[MISRA C++ Rule 6-4-6]) /* Rule 6-4-7 (req) *********************************/ /* 483 - switching on a boolean value */ +e483 // +elib(483) -append(483,[MISRA C++ Rule 6-4-7]) /* Rule 6-4-8 (req) *********************************/ /* 764 - switch with no cases */ +e764 // +elib(764) -append(764,[MISRA C++ Rule 6-4-8]) /* Rule 6-5-1 (req) *********************************/ /* not currently supported */ /* Rule 6-5-2 (req) *********************************/ /* not currently supported */ /* Rule 6-5-3 (req) *********************************/ /* 850 - for statement index variable modified in body */ +e850 // +elib(850) -append(850,[MISRA C++ Rule 6-5-3]) /* Rule 6-5-4 (req) *********************************/ /* not currently supported */ /* Rule 6-5-5 (req) *********************************/ /* not currently supported */ /* Rule 6-5-6 (req) *********************************/ /* not currently supported */ /* Rule 6-6-1 (req) *********************************/ /* 9041 - goto appears in block 'String' which is not nested in block 'String' which contains label 'Symbol' */ +e9041 // +elib(9041) -append(9041,[MISRA C++ Rule 6-6-1]) /* Rule 6-6-2 (req) *********************************/ /* 107 - label not defined */ +e107 // +elib(107) -append(107,[MISRA C++ Rule 6-6-2]) /* 9064 - goto references earlier label */ +e9064 // +elib(9064) -append(9064,[MISRA C++ Rule 6-6-2]) /* Rule 6-6-3 (req) *********************************/ /* 9254 - continue statement encountered */ +e9254 // +elib(9254) -append(9254,[MISRA C++ Rule 6-6-3]) /* Rule 6-6-4 (req) *********************************/ /* 9011 - multiple loop exits */ +e9011 // +elib(9011) -append(9011,[MISRA C++ Rule 6-6-4]) /* Rule 6-6-5 (req) *********************************/ /* 904 - return statement before end of function */ +e904 // +elib(904) -append(904,[MISRA C++ Rule 6-6-5]) /* Rule 7-1-1 (req) *********************************/ /* 952 - parameter of function could be const */ +e952 // +elib(952) -append(952,[MISRA C++ Rule 7-1-1]) /* Rule 7-1-2 (req) *********************************/ /* 818 - parameter of function could be pointer to const */ +e818 // +elib(818) -append(818,[MISRA C++ Rule 7-1-2]) /* Rule 7-2-1 (req) *********************************/ /* not currently supported */ /* Rule 7-3-1 (req) *********************************/ /* 9141 - global declaration of symbol */ +e9141 // +elib(9141) -append(9141,[MISRA C++ Rule 7-3-1]) /* 9162 - use of static_assert/using declaration at global scope */ +e9162 // +elib(9162) -append(9162,[MISRA C++ Rule 7-3-1]) /* Rule 7-3-2 (req) *********************************/ /* 9142 - function main declared outside the global namespace */ +e9142 // +elib(9142) -append(9142,[MISRA C++ Rule 7-3-2]) /* Rule 7-3-3 (req) *********************************/ /* 1751 - anonymous namespace declared in a header file */ +e1751 // +elib(1751) -append(1751,[MISRA C++ Rule 7-3-3]) /* Rule 7-3-4 (req) *********************************/ /* 9144 - using directive used */ +e9144 // +elib(9144) -append(9144,[MISRA C++ Rule 7-3-4]) /* Rule 7-3-5 (req) *********************************/ /* not currently supported */ /* Rule 7-3-6 (req) *********************************/ /* 9145 - using declaration/directive in header */ +e9145 // +elib(9145) -append(9145,[MISRA C++ Rule 7-3-6]) /* Rule 7-4-1 (doc) *********************************/ /* not statically checkable */ /* Rule 7-4-2 (req) *********************************/ /* only use the asm declaration to introduce assembly code */ -rw(_asm) -rw(__asm) -pragma(asm) -pragma(endasm) -ppw(asm) -ppw(endasm) /* Rule 7-4-3 (req) *********************************/ /* not currently supported */ /* Rule 7-5-1 (req) *********************************/ /* 604 - returning address of auto variable */ +e604 // +elib(604) -append(604,[MISRA C++ Rule 7-5-1]) /* Rule 7-5-2 (req) *********************************/ /* 789 - assigning address of auto variable to static */ +e789 // +elib(789) -append(789,[MISRA C++ Rule 7-5-2]) /* Rule 7-5-3 (req) *********************************/ /* 1780 - returning address of reference to a const parameter */ +e1780 // +elib(1780) -append(1780,[MISRA C++ Rule 7-5-3]) /* 1940 - address of non-const reference parameter transferred outside of function */ +e1940 // +elib(1940) -append(1940,[MISRA C++ Rule 7-5-3]) /* Rule 7-5-4 (req) *********************************/ /* 9070 - function is recursive */ +e9070 // +elib(9070) -append(9070,[MISRA C++ Rule 7-5-4]) /* Rule 8-0-1 (req) *********************************/ /* 9146 - multiple declarators in a declaration */ +e9146 // +elib(9146) -append(9146,[MISRA C++ Rule 8-0-1]) /* Rule 8-3-1 (req) *********************************/ /* 1735 - parameter of virtual function has default argument */ +e1735 // +elib(1735) -append(1735,[MISRA C++ Rule 8-3-1]) /* Rule 8-4-1 (req) *********************************/ /* 9165 - function defined with a variable number of arguments */ +e9165 // +elib(9165) -append(9165,[MISRA C++ Rule 8-4-1]) /* Rule 8-4-2 (req) *********************************/ /* 9072 - parameter of function has different name than previous declaration */ +e9072 // +elib(9072) -append(9072,[MISRA C++ Rule 8-4-2]) /* 9272 - parameter of function has different name than overridden function */ +e9272 // +elib(9272) -append(9272,[MISRA C++ Rule 8-4-2]) /* Rule 8-4-3 (req) *********************************/ /* 533 - function should return a value */ +e533 // +elib(533) -append(533,[MISRA C++ Rule 8-4-3]) /* Rule 8-4-4 (req) *********************************/ /* 9147 - implicit function-to-pointer decay */ +e9147 // +elib(9147) -append(9147,[MISRA C++ Rule 8-4-4]) /* Rule 8-5-1 (req) *********************************/ /* 530 - likely using an uninitialized value */ +e530 // +elib(530) -append(530,[MISRA C++ Rule 8-5-1]) /* Rule 8-5-2 (req) *********************************/ /* 940 - omitted braces within initializer */ +e940 // +elib(940) -append(940,[MISRA C++ Rule 8-5-2]) /* Rule 8-5-3 (req) *********************************/ /* 9148 - '=' should initialize either all enum members or only the first */ +e9148 // +elib(9148) -append(9148,[MISRA C++ Rule 8-5-3]) /* Rule 9-3-1 (req) *********************************/ /* 605 - pointee implicitly gains/loses qualifier in conversion */ +e605 // +elib(605) -append(605,[MISRA C++ Rule 9-3-1]) /* 1536 - member function symbol exposes lower access member symbol */ +e1536 // +elib(1536) -append(1536,[MISRA C++ Rule 9-3-1]) /* Rule 9-3-2 (req) *********************************/ /* 1536 - member function symbol exposes lower access member symbol */ +e1536 // +elib(1536) -append(1536,[MISRA C++ Rule 9-3-2]) /* Rule 9-3-3 (req) *********************************/ /* 1762 - member function could be made const */ +e1762 // +elib(1762) -append(1762,[MISRA C++ Rule 9-3-3]) /* Rule 9-5-1 (req) *********************************/ /* 9018 - union declared */ +e9018 // +elib(9018) -append(9018,[MISRA C++ Rule 9-5-1]) /* Rule 9-6-1 (doc) *********************************/ /* not statically checkable */ /* Rule 9-6-2 (req) *********************************/ /* 9149 - bit field must be explicitly signed integer, unsigned integer, or bool */ +e9149 // +elib(9149) -append(9149,[MISRA C++ Rule 9-6-2]) /* Rule 9-6-3 (req) *********************************/ /* 9149 - bit field must be explicitly signed integer, unsigned integer, or bool */ +e9149 // +elib(9149) -append(9149,[MISRA C++ Rule 9-6-3]) /* Rule 9-6-4 (req) *********************************/ /* 9088 - named signed single-bit bitfield */ +e9088 // +elib(9088) -append(9088,[MISRA C++ Rule 9-6-4]) /* Rule 10-1-1 (adv) *********************************/ /* 9174 - 'Type' is a virtual base class of 'Symbol' */ +e9174 // +elib(9174) -append(9174,[MISRA C++ Rule 10-1-1]) /* Rule 10-1-2 (req) *********************************/ /* not currently supported */ /* Rule 10-1-3 (req) *********************************/ /* 1748 - non-virtual base class symbol included twice in class symbol */ +e1748 // +elib(1748) -append(1748,[MISRA C++ Rule 10-1-3]) /* Rule 10-2-1 (adv) *********************************/ /* not currently supported */ /* Rule 10-3-1 (req) *********************************/ /* not currently supported */ /* Rule 10-3-2 (req) *********************************/ // Disabled by #1411 /* 1909 - virtual' assumed */ // +e1909 // +elib(1909) // -append(1909,[MISRA C++ Rule 10-3-2]) /* Rule 10-3-3 (req) *********************************/ /* 9170 - pure function 'Symbol' overrides non-pure function 'Symbol' */ +e9170 // +elib(9170) -append(9170,[MISRA C++ Rule 10-3-3]) /* Rule 11-0-1 (req) *********************************/ /* 9150 - non-private data member within a non-POD structure */ +e9150 // +elib(9150) -append(9150,[MISRA C++ Rule 11-0-1]) /* Rule 12-1-1 (req) *********************************/ /* 1506 - call to virtual function within a constructor/destructor */ +e1506 // +elib(1506) -append(1506,[MISRA C++ Rule 12-1-1]) /* Rule 12-1-2 (adv) *********************************/ /* 1928 - base class absent from initializer list for constructor */ +e1928 // +elib(1928) -append(1928,[MISRA C++ Rule 12-1-2]) /* Rule 12-1-3 (req) *********************************/ /* 9169 - constructor 'Symbol' can be used for implicit conversions to fundamental type 'Type' */ +e9169 // +elib(9169) -append(9169,[MISRA C++ Rule 12-1-3]) /* Rule 12-8-1 (req) *********************************/ /* 1938 - constructor accesses global data */ +e1938 // +elib(1938) -append(1938,[MISRA C++ Rule 12-8-1]) /* Rule 12-8-2 (req) *********************************/ /* 9151 - abstract class declares public copy assignment operator */ +e9151 // +elib(9151) -append(9151,[MISRA C++ Rule 12-8-2]) /* Rule 14-5-1 (req) *********************************/ /* Not currently supported */ /* Rule 14-5-2 (req) *********************************/ /* 1789 - constructor template cannot be a copy constructor */ +e1789 // +elib(1789) -append(1789,[MISRA C++ Rule 14-5-2]) /* Rule 14-5-3 (req) *********************************/ /* 1721 - operator=() for is not a copy nor move assignment operator */ +e1721 // +elib(1721) -append(1721,[MISRA C++ Rule 14-5-3]) /* Rule 14-6-1 (req) *********************************/ /* Not currently supported */ /* Rule 14-6-2 (req) *********************************/ /* awaiting clarification from MISRA */ /* Rule 14-7-1 (req) *********************************/ /* 1795 - defined template is not instantiated */ +e1795 // +elib(1795) -append(1795,[MISRA C++ Rule 14-7-1]) /* Rule 14-7-2 (req) *********************************/ /* not currently supported */ /* Rule 14-7-3 (req) *********************************/ /* 1576 - explicit specialization is not in the same file as specialized function template */ +e1576 // +elib(1576) -append(1576,[MISRA C++ Rule 14-7-3]) /* 1577 - partial or explicit specialization is not in the same file as specialized class template */ +e1577 // +elib(1577) -append(1577,[MISRA C++ Rule 14-7-3]) /* Rule 14-8-1 (req) *********************************/ /* Not currently supported */ /* Rule 14-8-2 (adv) *********************************/ /* 9153 - viable set contains both function and template */ +e9153 // +elib(9153) -append(9153,[MISRA C++ Rule 14-8-2]) /* Rule 15-0-1 (doc) *********************************/ /* not statically checkable */ /* Rule 15-0-2 (adv) *********************************/ /* 9154 - throwing a pointer */ +e9154 // +elib(9154) -append(9154,[MISRA C++ Rule 15-0-2]) /* Rule 15-0-3 (req) *********************************/ /* 646 - case/default within loop */ +estring(646,try,catch) -append(646,[MISRA C++ Rule 15-0-3]) /* Rule 15-1-1 (req) *********************************/ /* not currently supported */ /* Rule 15-1-2 (req) *********************************/ /* 1419 - throwing the NULL macro will invoke an implementation-defined handler */ +e1419 // +elib(1419) -append(1419,[MISRA C++ Rule 15-1-2]) /* Rule 15-1-3 (req) *********************************/ /* 9156 - rethrow outside of catch block will call std::terminate if no exception is being handled */ +e9156 // +elib(9156) -append(9156,[MISRA C++ Rule 15-1-3]) /* Rule 15-3-1 (req) *********************************/ /* 1546 - throw outside try in destructor body */ +e1546 // +elib(1546) -append(1546,[MISRA C++ Rule 15-3-1]) /* Rule 15-3-2 (adv) *********************************/ /* not currently supported */ /* Rule 15-3-3 (req) *********************************/ /* not currently supported */ /* Rule 15-3-4 (req) *********************************/ /* 1560 - warning uncaught exception not on throw-list of function symbol */ +e1560 // +elib(1560) -append(1560,[MISRA C++ Rule 15-3-4]) /* Rule 15-3-5 (req) *********************************/ /* 1752 - catch parameter is not a reference */ +e1752 // +elib(1752) -append(1752,[MISRA C++ Rule 15-3-5]) /* Rule 15-3-6 (req) *********************************/ /* 1775 - catch block does not catch any declared exceptions */ +e1775 // +elib(1775) -append(1775,[MISRA C++ Rule 15-3-6]) /* Rule 15-3-7 (req) *********************************/ /* 1127 - catch handler after catch(...) */ +e1127 // +elib(1127) -append(1127,[MISRA C++ Rule 15-3-7]) /* Rule 15-4-1 (req) *********************************/ /* 1548 - exception specification in declaration does not match previous declaration */ +e1548 // +elib(1548) -append(1548,[MISRA C++ Rule 15-4-1]) /* Rule 15-5-1 (req) *********************************/ /* 1546 - throw outside try in destructor body */ +e1546 // +elib(1546) -append(1546,[MISRA C++ Rule 15-5-1]) /* Rule 15-5-2 (req) *********************************/ /* 1549 - exception of type 'Type' thrown from function is not in throw list */ +e1549 // +elib(1549) -append(1549,[MISRA C++ Rule 15-5-2]) /* Rule 15-5-3 (req) *********************************/ /* 1546 - throw outside try in destructor body */ +e1546 // +elib(1546) -append(1546,[MISRA C++ Rule 15-5-3]) /* Rule 16-0-1 (req) *********************************/ /* 9019 - declaration of 'Symbol' before #include */ +e9019 // +elib(9019) -append(9019,[MISRA C++ Rule 16-0-1]) /* Rule 16-0-2 (req) *********************************/ /* 9158 - #define used within block scope */ +e9158 // +elib(9158) -append(9158,[MISRA C++ Rule 16-0-2]) /* 9159 - #undef used within block scope */ +e9159 // +elib(9159) -append(9159,[MISRA C++ Rule 16-0-2]) /* Rule 16-0-3 (req) *********************************/ /* 9021 - use of '#undef' is discouraged */ +e9021 // +elib(9021) -append(9021,[MISRA C++ Rule 16-0-3]) /* Rule 16-0-4 (req) *********************************/ /* 9026 - function-like macro defined */ +e9026 // +elib(9026) -append(9026,[MISRA C++ Rule 16-0-4]) /* Rule 16-0-5 (req) *********************************/ /* 436 - preprocessor directive in invocation of macro */ +e436 // +elib(436) -append(436,[MISRA C++ Rule 16-0-5]) /* Rule 16-0-6 (req) *********************************/ /* 9022 - unparenthesized macro parameter in definition of macro */ +e9022 // +elib(9022) -append(9022,[MISRA C++ Rule 16-0-6]) /* Rule 16-0-7 (req) *********************************/ /* 553 - undefined preprocessor variable assumed to be 0 */ +e553 // +elib(553) -append(553,[MISRA C++ Rule 16-0-7]) /* Rule 16-0-8 (req) *********************************/ /* 16 - unknown preprocessor directive */ +e16 // +elib(16) -append(16,[MISRA C++ Rule 16-0-8]) /* 544 - preprocessor directive not followed by EOL */ +e544 // +elib(544) -append(544,[MISRA C++ Rule 16-0-8]) /* 9160 - unknown preprocessor directive in conditionally excluded region */ +e9160 // +elib(9160) -append(9160,[MISRA C++ Rule 16-0-8]) /* Rule 16-1-1 (req) *********************************/ /* 491 - non-standard use of 'defined' preprocessor operator */ +e491 // +elib(491) -append(491,[MISRA C++ Rule 16-1-1]) /* Rule 16-1-2 (req) *********************************/ /* 8 - unclosed #if */ +e8 // +elib(8) -append(8,[MISRA C++ Rule 16-1-2]) /* Rule 16-2-1 (req) *********************************/ /* not currently supported */ /* Rule 16-2-2 (req) *********************************/ /* Not currently supported */ /* Rule 16-2-3 (req) *********************************/ /* 967 - header file does not have a standard include guard */ +e967 // +elib(967) -append(967,[MISRA C++ Rule 16-2-3]) /* Rule 16-2-4 (req) *********************************/ /* 9020 - header file name with non-standard character */ +e9020 -estring(9020,\) /* not covered by this rule */ -append(9020,[MISRA C++ Rule 16-2-4]) /* Rule 16-2-5 (adv) *********************************/ /* 9020 - header file name with non-standard character */ /* Note: If your system requires the '\' be used as a directory separator, comment out the following options. */ +estring(9020,\) -append(9020(\),[MISRA C++ Rule 16-2-5]) /* Rule 16-2-6 (req) *********************************/ /* 12 - need < or \ */ +e12 // +elib(12) -append(12,[MISRA C++ Rule 16-2-6]) /* Rule 16-3-1 (req) *********************************/ /* 9023 - multiple use of stringize/pasting operators in definition of macro */ +e9023 // +elib(9023) -append(9023,[MISRA C++ Rule 16-3-1]) /* Rule 16-3-2 (adv) *********************************/ /* 9024 - pasting/stringize operator used in definition of macro */ +e9024 // +elib(9024) -append(9024,[MISRA C++ Rule 16-3-2]) /* Rule 16-6-1 (doc) *********************************/ /* not statically checkable */ /* Rule 17-0-1 (req) *********************************/ /* 9052 - macro defined with the same name as a C++ keyword */ +e9052 // +elib(9052) -append(9052,[MISRA C++ Rule 17-0-1]) /* 9071 - defined macro is reserved to the compiler */ +e9071 // +elib(9071) -append(9071,[MISRA C++ Rule 17-0-1]) /* Rule 17-0-2 (req) *********************************/ /* 9093 - the name is reserved to the compiler */ +e9093 // +elib(9093) -append(9093,[MISRA C++ Rule 17-0-2]) /* Rule 17-0-3 (req) *********************************/ /* not currently supported */ /* Rule 17-0-4 (req) *********************************/ /* See various // +elib options throughout this file. */ /* Rule 17-0-5 (req) *********************************/ /* 586 - 'String' 'Name' is deprecated */ +e586 // +elib(586) -deprecate( function, longjmp, [MISRA C++ Rule 17-0-5] ) -deprecate( macro, setjmp, [MISRA C++ Rule 17-0-5] ) /* Rule 18-0-1 (req) *********************************/ /* 829 - a +headerwarn option was previously issued for header */ +e829 // +elib(829) +headerwarn(time.h) +headerwarn(limits.h) +headerwarn(float.h) +headerwarn(stddef.h) +headerwarn(errno.h) +headerwarn(locale.h) +headerwarn(stdio.h) +headerwarn(ctype.h) +headerwarn(string.h) +headerwarn(math.h) +headerwarn(stdlib.h) +headerwarn(assert.h) +headerwarn(stdarg.h) +headerwarn(setjmp.h) +headerwarn(signal.h) -append(829,[MISRA C++ Rule 18-0-1]) /* Rule 18-0-2 (req) *********************************/ /* 586 - 'String' 'Name' is deprecated */ +e586 // +elib(586) -deprecate( function, atof, [MISRA C++ Rule 18-0-2] ) -deprecate( function, atoi, [MISRA C++ Rule 18-0-2] ) -deprecate( function, atol, [MISRA C++ Rule 18-0-2] ) /* Rule 18-0-3 (req) *********************************/ /* 586 - 'String' 'Name' is deprecated */ +e586 // +elib(586) -deprecate( function, abort, [MISRA C++ Rule 18-0-3] ) -deprecate( function, exit, [MISRA C++ Rule 18-0-3] ) -deprecate( function, getenv, [MISRA C++ Rule 18-0-3] ) -deprecate( function, system, [MISRA C++ Rule 18-0-3] ) /* Rule 18-0-4 (req) *********************************/ /* 829 - a +headerwarn option was previously issued for header */ +e829 // +elib(829) +headerwarn(ctime) -append(829,[MISRA C++ Rule 18-0-4]) /* Rule 18-0-5 (req) *********************************/ /* 586 - 'String' 'Name' is deprecated */ +e586 // +elib(586) -deprecate( function, strcpy, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strcmp, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strcat, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strchr, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strspn, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strcspn, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strpbrk, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strrchr, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strstr, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strtok, [MISRA C++ Rule 18-0-5] ) -deprecate( function, strlen, [MISRA C++ Rule 18-0-5] ) /* Rule 18-2-1 (req) *********************************/ /* 586 - 'String' 'Name' is deprecated */ +e586 // +elib(586) -deprecate( macro, offsetof, [MISRA C++ Rule 18-2-1] ) /* Rule 18-4-1 (req) *********************************/ /* 9173 - use of non-placement allocation function 'Symbol' */ +e9173 // +elib(9173) -append(9173,[MISRA C++ Rule 18-4-1]) /* 586 - 'String' 'Name' is deprecated */ +e586 // +elib(586) -deprecate( function, calloc, [MISRA C++ Rule 18-4-1] ) -deprecate( function, malloc, [MISRA C++ Rule 18-4-1] ) -deprecate( function, realloc, [MISRA C++ Rule 18-4-1] ) -deprecate( function, free, [MISRA C++ Rule 18-4-1] ) /* Rule 18-7-1 (req) *********************************/ /* 829 - a +headerwarn option was previously issued for header */ +e829 // +elib(829) +headerwarn(csignal) -append(829,[MISRA C++ Rule 18-7-1]) /* Rule 19-3-1 (req) *********************************/ /* 586 - 'String' 'Name' is deprecated */ +e586 // +elib(586) -deprecate( variable, errno, [MISRA C++ Rule 19-3-1] ) /* Rule 27-0-1 (req) *********************************/ /* 829 - a +headerwarn option was previously issued for header */ +e829 // +elib(829) +headerwarn(cstdio) -append(829,[MISRA C++ Rule 27-0-1]) ament_lint-0.12.0/ament_pclint/ament_pclint/config/au-misra3-amd1.lnt000066400000000000000000000171031420377356500255010ustar00rootroot00000000000000// --------------------------------------------------------------------- // This file is provided by Gimpel Software (www.gimpel.com) for use with // PC-lint Plus. // // Redistribution and use of this file, with or without modification, is // permitted provided that any such redistribution retains this notice. // --------------------------------------------------------------------- // au-misra3-amd1.lnt -- Author options - MISRA C 2012 /* This options file can be used to explicitly activate those checks advocated by the Motor Industry Software Reliability Association. You can use this file directly when linting your programs as in: lint au-misra3-amd1.lnt hello.c Gimpel Software relies on the document, "MISRA C:2012 Amendment 1 Additional security guidelines for MISRA C:2012" copyright 2016 by HORIBA MIRA Ltd, as the primary source for this file. Gimpel Software makes no warranty as to the completeness or applicability of this options file and reserves the right to amend or alter the official contents of such at any time. "MISRA" is a registered trademark of HORIBA MIRA Ltd, held on behalf of the MISRA Consortium. */ /**** Rule 12.5 (Mand) ************/ +e682 /* sizeof applied to parameter whose type is sized array */ +elib(682) -append(682,[MISRA 2012 Rule 12.5, mandatory]) +e882 /* sizeof applied to parameter declared as incomplete array */ +elib(882) -append(882,[MISRA 2012 Rule 12.5, mandatory]) /**** Rule 21.13 (Mand) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ /* Define EOF until a proper definition is seen */ -dEOF=-1 /* Define UCHAR_MIN and UCHAR_MAX if no definition available */ -dUCHAR_MIN=0 -dUCHAR_MAX=255 /* Ensure macro versions of ctype.h functions expand to function versions to make use of the function semantics defined below */ ++disalnum(x)=(isalnum)(x) ++disalpha(x)=(isalpha)(x) ++disblank(x)=(isblank)(x) ++discntrl(x)=(iscntrl)(x) ++disdigit(x)=(isdigit)(x) ++disgraph(x)=(isgraph)(x) ++dislower(x)=(islower)(x) ++disprint(x)=(isprint)(x) ++dispunct(x)=(ispunct)(x) ++disspace(x)=(isspace)(x) ++disupper(x)=(isupper)(x) ++disxdigit(x)=(isxdigit)(x) ++dtolower(x)=(tolower)(x) ++dtoupper(x)=(toupper)(x) /* Define semantics for ctype.h functions */ -sem(isalnum, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(isalpha, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(isblank, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(iscntrl, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(isdigit, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(isgraph, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(islower, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(isprint, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(ispunct, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(isspace, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(isupper, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(isxdigit, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(tolower, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) -sem(toupper, (1n >= UCHAR_MIN && 1n <= UCHAR_MAX) || 1n == EOF) +esym(426, isalnum) +esym(426, isalpha) +esym(426, isblank) +esym(426, iscntrl) +esym(426, isdigit) +esym(426, isgraph) +esym(426, islower) +esym(426, isprint) +esym(426, ispunct) +esym(426, isspace) +esym(426, isupper) +esym(426, isxdigit) +esym(426, tolower) +esym(426, toupper) -append(426(isalnum), value passed to isalnum is not representable as unsigned char and is not EOF) -append(426(isalnum),[MISRA 2012 Rule 21.13, mandatory]) -append(426(isalpha), value passed to isalpha is not representable as unsigned char and is not EOF) -append(426(isalpha),[MISRA 2012 Rule 21.13, mandatory]) -append(426(isblank), value passed to isblank is not representable as unsigned char and is not EOF) -append(426(isblank),[MISRA 2012 Rule 21.13, mandatory]) -append(426(iscntrl), value passed to iscntrl is not representable as unsigned char and is not EOF) -append(426(iscntrl),[MISRA 2012 Rule 21.13, mandatory]) -append(426(isdigit), value passed to isdigit is not representable as unsigned char and is not EOF) -append(426(isdigit),[MISRA 2012 Rule 21.13, mandatory]) -append(426(isgraph), value passed to isgraph is not representable as unsigned char and is not EOF) -append(426(isgraph),[MISRA 2012 Rule 21.13, mandatory]) -append(426(islower), value passed to islower is not representable as unsigned char and is not EOF) -append(426(islower),[MISRA 2012 Rule 21.13, mandatory]) -append(426(isprint), value passed to isprint is not representable as unsigned char and is not EOF) -append(426(isprint),[MISRA 2012 Rule 21.13, mandatory]) -append(426(ispunct), value passed to ispunct is not representable as unsigned char and is not EOF) -append(426(ispunct),[MISRA 2012 Rule 21.13, mandatory]) -append(426(isspace), value passed to isspace is not representable as unsigned char and is not EOF) -append(426(isspace),[MISRA 2012 Rule 21.13, mandatory]) -append(426(isupper), value passed to isupper is not representable as unsigned char and is not EOF) -append(426(isupper),[MISRA 2012 Rule 21.13, mandatory]) -append(426(isxdigit), value passed to isxdigit is not representable as unsigned char and is not EOF) -append(426(isxdigit),[MISRA 2012 Rule 21.13, mandatory]) -append(426(tolower), value passed to tolower is not representable as unsigned char and is not EOF) -append(426(tolower),[MISRA 2012 Rule 21.13, mandatory]) -append(426(toupper), value passed to toupper is not representable as unsigned char and is not EOF) -append(426(toupper),[MISRA 2012 Rule 21.13, mandatory]) /**** Rule 21.14 (Req) ************/ /* Not currently supported */ /**** Rule 21.15 (Req) ************/ +e857 /* incompatible pointer arguments to memcpy/memmove/memcmp */ +elib(857) -append(857,[MISRA 2012 Rule 21.15, required]) /**** Rule 21.16 (Req) ************/ +e9098 /* pointer argument to memcmp does not point to a pointer type or an essentially signed, unsigned, boolean, or enum type */ +elib(9098) -append(9098,[MISRA 2012 Rule 21.16, required]) /**** Rule 21.17 (Mand) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ /* 419 - apparent data overrun for function */ /* 420 - apparent access beyond array for function */ +esym(419 420, strcat, strcpy) -append(419(strcat),[MISRA 2012 Rule 21.17, required]) -append(420(strcat),[MISRA 2012 Rule 21.17, required]) -append(419(strcpy),[MISRA 2012 Rule 21.17, required]) -append(420(strcpy),[MISRA 2012 Rule 21.17, required]) /**** Rule 21.18 (Mand) ************/ /* Not currently supported */ /**** Rule 21.19 (Mand) ************/ /* Not currently supported */ /**** Rule 21.20 (Mand) ************/ /* Not currently supported */ /**** Rule 22.7 (Req) ************/ /* Not currently supported */ /**** Rule 22.8 (Req) ************/ /* Not currently supported */ /**** Rule 22.9 (Req) ************/ /* Not currently supported */ /**** Rule 22.10 (Req) ************/ /* Not currently supported */ ament_lint-0.12.0/ament_pclint/ament_pclint/config/au-misra3.lnt000066400000000000000000002321151420377356500246630ustar00rootroot00000000000000 // --------------------------------------------------------------------- // This file is provided by Gimpel Software (www.gimpel.com) for use with // PC-lint Plus. // // Redistribution and use of this file, with or without modification, is // permitted provided that any such redistribution retains this notice. // --------------------------------------------------------------------- // au-misra3.lnt -- Author options - MISRA C 2012 /* This options file can be used to explicitly activate those checks advocated by the Motor Industry Software Reliability Association. You can use this file directly when linting your programs as in: lint au-misra3.lnt hello.c Gimpel Software relies on the document, "MISRA-C:2012 Guidelines for the use of the C language in critical systems", copyright 2012 by MISRA Limited, as the primary source for this file. Gimpel Software makes no warranty as to the completeness or applicability of this options file and reserves the right to amend or alter the official contents of such at any time. "MISRA" is a registered trademark of MIRA Limited, held on behalf of the MISRA Consortium. */ /**** Dir 1.1 (Req) ************/ /* not statically checkable */ /**** Dir 2.1 (Req) ************/ -std(c99) /* strict ISO C99 */ /* Note: if you code to the C90 standard instead, you may want to comment out the above option and uncomment the following option. You will also want to do likewise for other uses of the '-std(c99)' option throughout this file. */ // -std(c90) +e950 /* flag non-standard word or construct */ // +elib(950) -append(950,[MISRA 2012 Directive 2.1, required]) /**** Dir 3.1 (Req) ************/ /* not statically checkable */ /**** Dir 4.1 (Req) ************/ /* not statically checkable */ /**** Dir 4.2 (Adv) ************/ /* not statically checkable */ /**** Dir 4.3 (Req) ************/ +e586 /* to activate the deprecation message */ // +elib(586) -deprecate(keyword,asm,[MISRA 2012 Directive 4.3, required]) /**** Dir 4.4 (Adv) ************/ /* This requirement (that there be no commented-out code) is, in principle, not statically checkable. The reason given for the requirement is that comments do not nest. Thus a commented out section of code that happens to use slash-star commenting could inadvertently introduce unwanted code. Rule 3.1, however, addresses the nested comment issue and hence the major concern that this requirement seeks to address is indeed checkable. */ -fnc /* flag nested comments */ +e602 /* comment within comment */ // +elib(602) -append(602,[MISRA 2012 Directive 4.4, advisory]) /**** Dir 4.5 (Adv) ************/ +fta /* enable typographical ambiguity checking */ +e9046 /* typographical ambiguity */ // +elib(9046) -append(9046,[MISRA 2012 Directive 4.5, advisory]) /**** Dir 4.6 (Adv) ************/ // +e970 /* flag modifiers used outside of typedefs */ // +elib(970) // -append(970,[MISRA 2012 Directive 4.6, advisory]) // For the duration, we are presuming MISRA does not want // diagnostics for the bool type. // -esym(970,bool) // -esym(970,char) /**** Dir 4.7 (Req) ************/ +e534 /* ignoring return value of function */ // +elib(534) -append(534,[MISRA 2012 Directive 4.7, required]) /**** Dir 4.8 (Adv) ************/ +e9045 /* non-hidden definition of type */ // +elib(9045) -append(9045,[MISRA 2012 Directive 4.8, advisory]) /**** Dir 4.9 (Adv) ************/ // +e9026 function-like macro defined */ // +elib(9026) // -append(9026,[MISRA 2012 Directive 4.9, advisory]) /**** Dir 4.10 (Req) ************/ +e451 /* Header repeatedly included without guard */ // +elib(451) -append(451,[MISRA 2012 Directive 4.10, required]) /**** Dir 4.11 (Req) ************/ /* The arguments to over 100 calls to standard library functions are monitored; users can specify additional constraints for other functions. */ /**** Dir 4.12 (Req) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(function,calloc,[MISRA 2012 Directive 4.12, required]) -deprecate(function,malloc,[MISRA 2012 Directive 4.12, required]) -deprecate(function,realloc,[MISRA 2012 Directive 4.12, required]) -deprecate(function,free,[MISRA 2012 Directive 4.12, required]) /**** Dir 4.13 (Adv) ************/ /* Not currently supported */ /**** Rule 1.1 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ -std(c99) /* strict ISO C99 */ /* Note: if you code to the C90 standard instead, you may want to comment out the above option and uncomment the following option. You will also want to do likewise for other uses of the '-std(c99)' option throughout this file. */ // -std(c90) +e950 /* flag non-standard word or construct */ // +elib(950) -append(950,[MISRA 2012 Rule 1.1, required]) /**** Rule 1.2 (Adv) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ -std(c99) /* strict ISO C99 */ /* Note: if you code to the C90 standard instead, you may want to comment out the above option and uncomment the following option. You will also want to do likewise for other uses of the '-std(c99)' option throughout this file. */ // -std(c90) +e950 /* flag non-ANSI word or construct */ // +elib(950) -append(950,[MISRA 2012 Rule 1.2, advisory]) /**** Rule 1.3 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ /* Avoid the use of undefined or unspecified behavior as described in ISO C, Appendix A.6.1 and Appendix A.6.2 */ /* Source file not ending in a new-line character, ending in new-line character immediately preceded by a backslash character, or ending in a partial preprocessing token or comment (ISO C, Appendix A.6.2, point 1). */ +e406 /* unclosed comment */ // +elib(406) -append(406,[MISRA 2012 Rule 1.3, required]) /* Non-standard character usage (ISO C, Appendix A.6.2, point 2). */ +e27 /* illegal character */ // +elib(27) -append(27,[MISRA 2012 Rule 1.3, required]) /* Unclosed quotes (ISO C, Appendix A.6.2, point 4). */ +e2 /* unclosed quote */ // +elib(2) -append(2,[MISRA 2012 Rule 1.3, required]) /* Repeated label within a function (ISO C, Appendix A.6.2, point 5). */ +e31 /* symbol redefinition */ // +elib(31) -append(31,[MISRA 2012 Rule 1.3, required]) /* Non-visible identifier used (ISO C, Appendix A.6.2, point 6). */ +e40 /* undeclared identifier */ // +elib(40) -append(40,[MISRA 2012 Rule 1.3, required]) /* Identifiers for the same entity differ beyond the minimal significant characters (ISO C, Appendix A.6.2, point 7). See Rules 5.1, 5.2, 5.4, and 5.5. */ /* The same identifier has both internal and external linkage in the same translation unit (ISO C, Appendix A.6.2, point 8). */ +e401 /* symbol not previously declared static */ // +elib(401) -append(401,[MISRA 2012 Rule 1.3, required]) /* Multiple definitions for the same externally linked identifier (ISO C, Appendix A.6.2, point 9). */ +e31 /* symbol redefinition */ // +elib(31) /* Using automatic storage data via a pointer after the data's lifetime (ISO C, Appendix A.6.2, point 10). */ +e604 /* returning address of auto variable */ // +elib(604) -append(604,[MISRA 2012 Rule 1.3, required]) +e934 /* taking address of near auto variable */ // +elib(934) -append(934,[MISRA 2012 Rule 1.3, required]) /* Incompatible redeclarations (ISO C, Appendix A.6.2, point 11). See Rule 8.3 */ /* Non-standard escape sequence (ISO C, Appendix A.6.2, point 12). */ +e606 /* non-ANSI escape sequence */ // +elib(606) -append(606,[MISRA 2012 Rule 1.3, required]) /* Non-standard character in header name (ISO C, Appendix A.6.2, point 15). See Rule 20.2 */ +e9020 /* header name with non-standard character */ // +elib(9020) -append(9020,[MISRA 2012 Rule 1.3, required]) /* No complete type available (ISO C, Appendix A.6.2, point 16). */ +e86 /* structure has no data elements */ // +elib(86) -append(86,[MISRA 2012 Rule 1.3, required]) /* Using or converting a void expression (ISO C, Appendix A.6.2, point 17). */ +e67 /* cannot cast between types */ // +elib(67) -append(67,[MISRA 2012 Rule 1.3, required]) +e144 /* non-existent return value */ // +elib(144) -append(144,[MISRA 2012 Rule 1.3, required]) /* Modifying an object more than once or modifying and accessing between two sequence points (ISO C, Appendix A.6.2, point 18). See Rule 13.2 */ +e564 /* variable depends on order of evaluation */ // +elib(564) -append(564,[MISRA 2012 Rule 1.3, required]) /* Invalid arithmetic operations or unrepresentable results (ISO C, Appendix A.6.2, point 19). */ +e54 /* division by 0 */ // +elib(54) -append(54,[MISRA 2012 Rule 1.3, required]) +e414 /* possible division by 0 */ // +elib(414) -append(414,[MISRA 2012 Rule 1.3, required]) +e795 /* conceivable division by 0 */ // +elib(795) -append(795,[MISRA 2012 Rule 1.3, required]) /* Also, see Rule 12.4 */ /* Passing a void argument to a function (ISO C, Appendix A.6.2, point 20). */ /* Incompatible function redeclaration (ISO C, Appendix A.6.2, point 22). See Rule 8.3 */ /* An invalid array reference, null pointer reference, or reference to an object declared with automatic storage duration in a terminated block occurs (ISO C, Appendix A.6.2, point 24). */ +e413 /* likely use of null pointer */ // +elib(413) -append(413,[MISRA 2012 Rule 1.3, required]) +e415 /* out-of-bounds pointer */ // +elib(415) -append(415,[MISRA 2012 Rule 1.3, required]) +e416 /* out-of-bounds pointer */ // +elib(416) -append(416,[MISRA 2012 Rule 1.3, required]) +e428 /* negative subscript */ // +elib(428) -append(428,[MISRA 2012 Rule 1.3, required]) /* Also, see Rule 17.6 */ /* A pointer to a function is converted to a pointer to an object or a pointer to an object is converted to a pointer to a function (ISO C, Appendix A.6.2, point 26). */ +e2454 /* incompatible pointer types */ // +elib(64) -append(2454,[MISRA 2012 Rule 1.3, required]) +e740 /* unusual pointer cast */ // +elib(740) -append(740,[MISRA 2012 Rule 1.3, required]) /* Also, see Rule 11.1 and 11.2 */ /* A pointer is converted to other than an integral or pointer type (ISO C, Appendix A.6.2, point 27). */ +e71 /* cannot cast */ // +elib(71) /* An identifier for an object is declared with no linkage and the type of the object is incomplete after its declarator, or after its init-declarator if it has an initializer (ISO C, Appendix A.6.2, point 33). */ +e86 /* structure has no data elements */ // +elib(86) /* Declaring a function at block scope with a storage-class specifier other than extern (ISO C, Appendix A.6.2, point 34). */ +e629 /* static class for function */ // +elib(629) -append(629,[MISRA 2012 Rule 1.3, required]) /* A bit-field is declared with a type other than int, signed int, or unsigned int (ISO C, Appendix A.6.2, point 35). See Rule 6.1. */ /* Attempting to modify an object with const-qualified type by means of an lvalue with non-const-qualified type (ISO C, Appendix A.6.2, point 36). */ +e158 /* assignment increases capability */ // +elib(158) -append(158,[MISRA 2012 Rule 1.3, required]) /* Attempting to refer to an object with volatile-qualified type by means of an lvalue with non-volatile-qualified type (ISO C, Appendix A.6.2, point 37). */ +e158 /* assignment increases capability */ // +elib(158) /* Using the value of uninitialized automatic object (ISO C, Appendix A.6.2, point 38). See Rule 9.1 */ /* An object with aggregate or union type with static storage duration has a non-brace-enclosed initializer, or an object with aggregate or union type with automatic storage duration has either a single expression initializer with a type other than that of the object or a non-brace-enclosed initializer (ISO C, Appendix A.6.2, point 39). Also, see Rule 9.2 */ +e64 /* type mismatch */ // +elib(64) -append(2454,[MISRA 2012 Rule 1.3, required]) /* The value of a function is used, but no value was returned (ISO C, Appendix A.6.2, point 40). See Rule 17.4. */ /* A function that accepts a variable number of arguments is defined without a parameter type list that ends with the ellipsis notation (ISO C, Appendix A.6.2, point 41). */ /* An identifier for an object with internal linkage and an incomplete type is declared with a tentative definition (ISO C, Appendix A.6.2, point 42). */ +e86 /* structure has no data elements */ // +elib(86) /* Non-standard #include preprocessing directive (ISO C, Appendix A.6.2, point 44). See Rule 20.3. */ /* Non-standard #line directive (ISO C, Appendix A.6.2, point 49). */ +"estring(10,a numeric constant)" /* expecting a numeric constant */ /* #defining or #undefing any of: defined, __LINE__, __FILE__, __DATE__, __TIME__, or __STDC__ (ISO C, Appendix A.6.2, point 50). */ +e136 /* illegal macro name */ // +elib(136) -append(136,[MISRA 2012 Rule 1.3, required]) /* Format-argument mismatch in an fprintf or fscanf type of function (ISO C, Appendix A.6.2, point 75). */ +e558 /* too few arguments */ // +elib(558) -append(558,[MISRA 2012 Rule 1.3, required]) +e719 /* too many arguments */ // +elib(719) -append(719,[MISRA 2012 Rule 1.3, required]) /* A %% conversion specification for the fprintf or fscanf function contains characters between the pair of % characters (ISO C, Appendix A.6.2, point 77). */ +e557 /* unrecognized format */ // +elib(557) -append(557,[MISRA 2012 Rule 1.3, required]) /* An aggregate or union, or a pointer to an aggregate or union is an argument to the fprintf function, except for the conversion specifiers %s (for an array of character type) or %p (for a pointer to void) (ISO C, Appendix A.6.2, point 81). */ +e437 /* passing struct to ellipsis */ // +elib(437) -append(437,[MISRA 2012 Rule 1.3, required]) /* Referring to deallocated space (ISO C, Appendix A.6.2, point 87). */ +e449 /* previously deallocated pointer */ // +elib(449) -append(449,[MISRA 2012 Rule 1.3, required]) /* Misuse of free or realloc (ISO C, Appendix A.6.2, point 88). */ +esym(424,free) /* inappropriate deallocation */ -append(424,[MISRA 2012 Rule 1.3, required]) /* An array written to by a copying or concatenation function is too small (ISO C, Appendix A.6.2, point 91). */ +e419 /* data overrun */ // +elib(419) -append(419,[MISRA 2012 Rule 1.3, required]) /* Order of evaluation (ISO C, Appendix A.6.1, point 7). */ +e564 /* variable depends on order of evaluation */ // +elib(564) -append(564,[MISRA 2012 Rule 1.3, required]) /* Side effects order (ISO C, Appendix A.6.1, point 8). */ +e931 /* both sides of an expression have side-effects */ // +elib(931) -append(931,[MISRA 2012 Rule 1.3, required]) /* Function argument evaluation (ISO C, Appendix A.6.1, point 9). */ +e564 /* variable depends on order of evaluation */ // +elib(564) /* The order in which # and ## operations are evaluated during macro substitution (ISO C, Appendix A.6.1, point 12). */ +e9023 /* multiple '#/##' operators in macro definition */ // +elib(9023) -append(9023,[MISRA 2012 Rule 1.3, required]) /* Whether setjmp is a macro or an external identifier (ISO C, Appendix A.6.1, point 14). See Rule 21.2. */ /**** Rule 2.1 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e506 /* constant value boolean */ // +elib(506) -append(506,[MISRA 2012 Rule 2.1, required]) +e527 /* unreachable */ // +elib(527) -append(527,[MISRA 2012 Rule 2.1, required]) +e681 /* loop not entered */ // +elib(681) -append(681,[MISRA 2012 Rule 2.1, required]) +e827 /* loop not reachable */ // +elib(827) -append(827,[MISRA 2012 Rule 2.1, required]) /**** Rule 2.2 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e438 /* value not used */ // +elib(438) -append(438,[MISRA 2012 Rule 2.2, required]) +e505 /* redundant argument to comma */ // +elib(505) -append(505,[MISRA 2012 Rule 2.2, required]) +e520 /* highest operator has no side effects */ // +elib(520) -append(520,[MISRA 2012 Rule 2.2, required]) +e521 /* highest operator has no side effects */ // +elib(521) -append(521,[MISRA 2012 Rule 2.2, required]) +e522 /* highest operator has no side effects */ // +elib(522) -append(522,[MISRA 2012 Rule 2.2, required]) /**** Rule 2.3 (Adv) ************/ +e751 /* local typedef not referenced */ // +elib(751) -append(751,[MISRA 2012 Rule 2.3, advisory]) +e756 /* global not referenced */ // +elib(756) -append(756,[MISRA 2012 Rule 2.3, advisory]) /**** Rule 2.4 (Adv) ************/ +e753 /* local tag not referenced */ // +elib(753) -append(753,[MISRA 2012 Rule 2.4, advisory]) +e9058 // +elibsym(9058) -append(9058,[MISRA 2012 Rule 2.4, advisory]) /**** Rule 2.5 (Adv) ************/ // +e750 local macro not referenced */ // // +elib(750) // -append(750,[MISRA 2012 Rule 2.5, advisory]) // +e755 global macro not referenced */ // // +elib(755) // -append(755,[MISRA 2012 Rule 2.5, advisory]) /**** Rule 2.6 (Adv) ************/ +e563 /* label not referenced */ // +elib(563) -append(563,[MISRA 2012 Rule 2.6, advisory]) /**** Rule 2.7 (Adv) ************/ +e715 /* not referenced */ // +elib(715) -append(715,[MISRA 2012 Rule 2.7, advisory]) /**** Rule 3.1 (Req) ************/ -fnc /* flag nested comments */ +e602 /* comment within comment */ // +elib(602) -append(602,[MISRA 2012 Rule 3.1, required]) +e9059 // +elib(9059) -append(9059,[MISRA 2012 Rule 3.1, required]) +e9066 // +elib(9066) -append(9066,[MISRA 2012 Rule 3.1, required]) +e9259 // +elib(9259) -append(9259,[MISRA 2012 Rule 3.1, required]) /**** Rule 3.2 (Req) ************/ +e427 /* C++ comment ends in \\ */ // +elib(427) -append(427,[MISRA 2012 Rule 3.2, required]) /**** Rule 4.1 (Req) ************/ +e9039 /* prohibited escape sequence */ // +elib(9039) -append(9039,[MISRA 2012 Rule 4.1, required]) /**** Rule 4.2 (Adv) ************/ -ftg /* inhibit use of trigraphs */ +e584 /* activate trigraph detected message */ // +elib(584) -append(584,[MISRA 2012 Rule 4.2, advisory]) +e739 /* activate trigraph in string message */ // +elib(739) -append(739,[MISRA 2012 Rule 4.2, advisory]) +e9060 /* trigraph in comment */ // +elib(9060) -append(9060,[MISRA 2012 Rule 4.2, advisory]) /**** Rule 5.1 (Req) ************/ -idlen(31, x) /* Sets the number of significant characters in an external identifier, update as appropriate for your target. Use 'X' instead of 'x' if external identifiers are not case sensitive. C90 guarantees 6 characters are significant, C99 guarantees at least 31 characters are significant. */ +e621 /* identifier clash */ // +elib(621) -append(621("external vs external"), [MISRA 2012 Rule 5.1, required]) /**** Rule 5.2 (Req) ************/ -idlen(63, c) /* Sets the number of significant characters in an internal identifier, update as appropriate for your target. Use 'C' instead of 'c' if internal identifiers are not case sensitive. C90 guarantees 31 characters are significant, C99 guarantees at least 63 characters are significant. */ +e621 /* identifier clash */ // +elib(621) -append(621("tag vs tag"), [MISRA 2012 Rule 5.2, required]) -append(621("field vs field"), [MISRA 2012 Rule 5.2, required]) -append(621("label vs label"), [MISRA 2012 Rule 5.2, required]) -append(621("internal vs internal, same scope"), [MISRA 2012 Rule 5.2, required]) -append(621("internal vs external, same scope"), [MISRA 2012 Rule 5.2, required]) -append(621("external vs internal, same scope"), [MISRA 2012 Rule 5.2, required]) /**** Rule 5.3 (Req) ************/ +e578 /* enable reports of name hiding */ // +elib(578) -append(578,[MISRA 2012 Rule 5.3, required]) /* This rule uses the same -idlen option values as 5.2 */ +e621 /* identifier clash */ // +elib(621) -append(621("internal vs internal, enclosing scope"), [MISRA 2012 Rule 5.3, required]) -append(621("internal vs external, enclosing scope"), [MISRA 2012 Rule 5.3, required]) -append(621("external vs internal, enclosing scope"), [MISRA 2012 Rule 5.3, required]) /**** Rule 5.4 (Req) ************/ -idlen(63, p) /* Sets the number of significant characters in a preprocessor identifier, update as appropriate for your target. Use 'P' instead of 'p' if preprocessor identifiers are not case sensitive. C90 guarantees 31 characters are significant, C99 guarantees at least 63 characters are significant. */ +e547 /* conflicting macro definition */ // +elib(547) -append(547,[MISRA 2012 Rule 5.4, required]) +e760 /* macro redefined identically */ // +elib(760) -append(760,[MISRA 2012 Rule 5.4, required]) +e621 /* identifier clash */ // +elib(621) -append(621("macro vs macro"), [MISRA 2012 Rule 5.4, required]) -append(621("macro vs macro parameter"), [MISRA 2012 Rule 5.4, required]) -append(621("macro parameter vs macro parameter"), [MISRA 2012 Rule 5.4, required]) /**** Rule 5.5 (Req) ************/ /* 9095 - symbol has same name as previously defined macro */ +e9095 // +elib(123) -append(9095,[MISRA 2012 Rule 5.5, required]) /* 9096 - symbol has same name as subsequently defined macro */ +e9096 // +elib(9061) -append(9096,[MISRA 2012 Rule 5.5, required]) /**** Rule 5.6 (Req) ************/ +e578 /* enable reports of name hiding */ // +elib(578) -append(578,[MISRA 2012 Rule 5.6, required]) +e623 /* redefining the storage class of symbol */ // +elib(623) -append(623,[MISRA 2012 Rule 5.6, required]) /**** Rule 5.7 (Req) ************/ +e407 /* Inconsistent use of tag */ // +elib(407) -append(407,[MISRA 2012 Rule 5.7, required]) +e578 /* Declaration of Symbol hides Symbol */ // +elib(578) -append(578,[MISRA 2012 Rule 5.7, required]) +e14 /* Symbol previously defined */ // +elib(14) -append(14,[MISRA 2012 Rule 5.7, required]) +e15 /* Symbol redeclared */ // +elib(15) -append(15,[MISRA 2012 Rule 5.7, required]) +e631 /* Tag defined differently */ // +elib(631) -append(631,[MISRA 2012 Rule 5.7, required]) /**** Rule 5.8 (Req) ************/ +e401 /* Symbol not previously declared static */ // +elib(401) -append(401,[MISRA 2012 Rule 5.8, required]) +e578 /* Declaration of Symbol hides Symbol */ // +elib(578) -append(578,[MISRA 2012 Rule 5.8, required]) +e580 /* enable reports of name hiding */ // +elib(580) -append(580,[MISRA 2012 Rule 5.8, required]) /**** Rule 5.9 (Adv) ************/ +e578 /* enable reports of name hiding */ // +elib(578) -append(578,[MISRA 2012 Rule 5.9, advisory]) +e580 /* enable reports of name hiding */ // +elib(580) -append(580,[MISRA 2012 Rule 5.9, advisory]) /**** Rule 6.1 (Req) ************/ /* 9149 bit field must be explicitly signed integer, unsigned integer, or bool */ +e9149 // +elib(806) -append(9149,[MISRA 2012 Rule 6.1, required]) /**** Rule 6.2 (Req) ************/ +e9088 /* named signed single-bit bit-field */ // +elib(9088) -append(9088,[MISRA 2012 Rule 6.2, required]) /**** Rule 7.1 (Req) ************/ +e9001 /* Octal constant used */ // +elib(9001) -append(9001,[MISRA 2012 Rule 7.1, required]) /**** Rule 7.2 (Req) ************/ +e9048 /* unsigned literal without 'U' suffix */ // +elib(9048) -append(9048,[MISRA 2012 Rule 7.2, required]) /**** Rule 7.3 (Req) ************/ +e620 /* suspicious constant */ // +elib(620) -append(620,[MISRA 2012 Rule 7.3, required]) +e9057 /* "l" after "u" in literal suffix */ // +elib(9057) -append(9057,[MISRA 2012 Rule 7.3, required]) /**** Rule 7.4 (Req) ************/ +fsc +e489 /* attempting to modify a string literal */ // +elib(489) -append(489,[MISRA 2012 Rule 7.4, required]) +e1776 /* string literal not const safe */ // +elib(1776) -append(1776,[MISRA 2012 Rule 7.4, required]) +e1778 /* assignment of string literal not const safe */ // +elib(1778) -append(1778,[MISRA 2012 Rule 7.4, required]) /**** Rule 8.1 (Req) ************/ +e601 /* no explicit type */ // +elib(601) -append(601,[MISRA 2012 Rule 8.1, required]) +e745 /* function has no explicit type */ // +elib(745) -append(745,[MISRA 2012 Rule 8.1, required]) +e808 /* no explicit type */ // +elib(808) -append(808,[MISRA 2012 Rule 8.1, required]) +e832 /* parameter has no explicit type */ // +elib(832) -append(832,[MISRA 2012 Rule 8.1, required]) +e939 /* return type defaults to int */ // +elib(939) -append(939,[MISRA 2012 Rule 8.1, required]) /**** Rule 8.2 (Req) ************/ +e937 /* old-style function declaration */ // +elib(937) -append(937,[MISRA 2012 Rule 8.2, required]) +e745 /* function has no explicit type */ // +elib(745) -append(745,[MISRA 2012 Rule 8.2, required]) +e939 /* return type defaults to int */ // +elib(939) -append(939,[MISRA 2012 Rule 8.2, required]) +e18 /* symbol redeclared */ // +elib(18) -append(18,[MISRA 2012 Rule 8.2, required]) +e936 /* old-style function definition */ // +elib(936) -append(936,[MISRA 2012 Rule 8.2, required]) +e955 /* param name missing from prototype */ // +elib(955) -append(955,[MISRA 2012 Rule 8.2, required]) /**** Rule 8.3 (Req) ************/ +e18 /* symbol redeclared */ // +elib(18) -append(18,[MISRA 2012 Rule 8.3, required]) +e532 /* return mode of symbol inconsistent */ // +elib(532) -append(532,[MISRA 2012 Rule 8.3, required]) /* 9072 parameter has different name than previous declaration */ +e9072 // +elib(9072) -append(9072,[MISRA 2012 Rule 8.3, required]) /* 9073 parameter has type alias name type difference with previous declaration */ +e9073 // +elib(9073) -append(9073,[MISRA 2012 Rule 8.3, required]) /* 9094 return type has type alias name difference with previous declaration */ +e9094 // +elib(9094) -append(9094,[MISRA 2012 Rule 8.3, required]) /**** Rule 8.4 (Req) ************/ +e15 /* symbol redeclared */ // +elib(15) -append(15,[MISRA 2012 Rule 8.4, required]) /* 957 - function defined without prototype in scope */ +e957 // +elib(64) -append(957,[MISRA 2012 Rule 8.4, required]) /* 9075 external symbol defined without a prior declaration */ +e9075 // +elib(9075) -append(9075,[MISRA 2012 Rule 8.4, required]) /**** Rule 8.5 (Req) ************/ +e9004 /* object/function previously declared */ // +elib(9004) -append(9004,[MISRA 2012 Rule 8.5, required]) /**** Rule 8.6 (Req) ************/ +e14 /* Symbol previously defined */ // +elib(14) -append(14,[MISRA 2012 Rule 8.6, required]) /**** Rule 8.7 (Adv) ************/ +e765 /* could be made static */ // +elib(765) -append(765,[MISRA 2012 Rule 8.7, advisory]) /**** Rule 8.8 (Req) ************/ +e839 /* storage class assumed static */ // +elib(839) -append(839,[MISRA 2012 Rule 8.8, required]) /**** Rule 8.9 (Adv) ************/ +e9003 /* could define variable at block scope */ // +elib(9003) -append(9003,[MISRA 2012 Rule 8.9, advisory]) /**** Rule 8.10 (Req) ************/ +e695 /* inline function without storage-class specifier */ // +elib(695) -append(695,[MISRA 2012 Rule 8.10, required]) +estring(9056,extern) /* inline function defined with extern */ -append(9056,[MISRA 2012 Rule 8.10, required]) /**** Rule 8.11 (Adv) ************/ +e9067 /* array has no dimension or initializer */ // +elib(9067) -append(9067,[MISRA 2012 Rule 8.11, advisory]) /**** Rule 8.12 (Req) ************/ +e488 /* duplicate enumerator values */ // +elib(488) -append(488,[MISRA 2012 Rule 8.12, required]) /**** Rule 8.13 (Adv) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ // +e818 pointer could be declared pointing to const */ // // +elib(818) // -append(818,[MISRA 2012 Rule 8.13, advisory]) // +e844 pointer could be declared pointing to const */ // // +elib(844) // -append(844,[MISRA 2012 Rule 8.13, advisory]) // +e954 pointer could be declared pointing to const */ // // +elib(954) // -append(954,[MISRA 2012 Rule 8.13, advisory]) /**** Rule 8.14 (Req) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(keyword,restrict,[MISRA 2012 Rule 8.14, required]) /**** Rule 9.1 (Mand) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e644 /* Symbol may not have been initialized */ // +elib(644) -append(644,[MISRA 2012 Rule 9.1, mandatory]) +e771 /* Symbol conceivably not initialized */ // +elib(771) -append(771,[MISRA 2012 Rule 9.1, mandatory]) +e530 /* Symbol not initialized */ // +elib(530) -append(530,[MISRA 2012 Rule 9.1, mandatory]) /* 603 - argument to parameter of type pointer to const may be a pointer to uninitialized memory */ +e603 // +elib(603) -append(603,[MISRA 2012 Rule 9.1, mandatory]) /**** Rule 9.2 (Req) ************/ +e9069 /* aggregate initialize needs braces or designator */ // +elib(9069) -append(9069,[MISRA 2012 Rule 9.2, required]) /**** Rule 9.3 (Req) ************/ +e9068 /* too few initializers */ // +elib(9068) -append(9068,[MISRA 2012 Rule 9.3, required]) /**** Rule 9.4 (Req) ************/ +e485 /* duplicate initialization */ // +elib(485) -append(485,[MISRA 2012 Rule 9.4, required]) /**** Rule 9.5 (Req) ************/ +e9054 /* designated initializer and dimensionless array */ // +elib(9054) -append(9054,[MISRA 2012 Rule 9.5, required]) /**** Rule 10.1 (Req) ************/ +e48 /* bad type */ // +elib(48) -append(48,[MISRA 2012 Rule 10.1, required]) +e9027 /* unpermitted operand */ // +elib(9027) -append(9027,[MISRA 2012 Rule 10.1, required]) /**** Rule 10.2 (Req) ************/ +e9028 /* unpermitted arithmetic */ // +elib(9028) -append(9028,[MISRA 2012 Rule 10.2, required]) /**** Rule 10.3 (Req) ************/ +e9034 /* expression assigned to narrower or different essential type */ // +elib(9034) // Note: the following -d options for true and false don't apply // to C90 and should be commented out if not using C99 -estring(9052, true, false) +"dtrue=/*lint -save -e921 */(_Bool) 1/*lint -restore */" // exception +"dfalse=/*lint -save -e921 */(_Bool) 0/*lint -restore */" // exception -append(9034,[MISRA 2012 Rule 10.3, required]) /**** Rule 10.4 (Req) ************/ +e9029 /* mismatched essential type */ // +elib(9029) -append(9029,[MISRA 2012 Rule 10.4, required]) /**** Rule 10.5 (Adv) ************/ +e9030 /* impermissible cast */ // +elib(9030) -append(9030,[MISRA 2012 Rule 10.5, advisory]) /**** Rule 10.6 (Req) ************/ +e9031 /* composite expression assigned to wider essential type */ // +elib(9031) -append(9031,[MISRA 2012 Rule 10.6, required]) /**** Rule 10.7 (Req) ************/ +e9032 /* composite expression with smaller essential type than other operand*/ // +elib(9032) -append(9032,[MISRA 2012 Rule 10.7, required]) /**** Rule 10.8 (Req) ************/ +e9033 /* impermissible cast of composite expression */ // +elib(9033) -append(9033,[MISRA 2012 Rule 10.8, required]) /**** Rule 11.1 (Req) ************/ +e9074 /* conversion between a pointer to function and another type */ // +elib(9074) -append(9074,[MISRA 2012 Rule 11.1, required]) /**** Rule 11.2 (Req) ************/ +e9076 /* conversion between a pointer to incomplete type and another type */ // +elib(9076) -append(9076,[MISRA 2012 Rule 11.2, required]) /**** Rule 11.3 (Req) ************/ +e9087 /* cast from pointer to pointer */ // +elib(9087) -append(9087,[MISRA 2012 Rule 11.3, required]) /**** Rule 11.4 (Adv) ************/ +e9078 /* cast pointer/integer */ // +elib(9078) -append(9078,[MISRA 2012 Rule 11.4, advisory]) /**** Rule 11.5 (Adv) ************/ // +e9079 cast from pointer to pointer */ // +elib(9079) // -append(9079,[MISRA 2012 Rule 11.5, advisory]) /**** Rule 11.6 (Req) ************/ // +elib(923) cast pointer/non-pointer +etype(923, void *) -append(923,[MISRA 2012 Rule 11.6, required]) /**** Rule 11.7 (Req) ************/ +e177 /* type cannot be cast to object pointer */ // +elib(68) -append(177,[MISRA 2012 Rule 11.7, required]) +e179 /* object pointer cannot be cast to type */ // +elib(70) -append(179,[MISRA 2012 Rule 11.7, required]) +e9295 /* cast between object pointer and forbidden essential type */ // +elib(9295) -append(9295,[MISRA 2012 Rule 11.7, required]) /**** Rule 11.8 (Req) ************/ +e9005 /* attempt to cast away const/volatile from pointer or reference */ // +elib(9005) -append(9005,[MISRA 2012 Rule 11.8, required]) /**** Rule 11.9 (Req) ************/ +e9080 /* integer null pointer constant */ // +elib(9080) -append(9080,[MISRA 2012 Rule 11.9, required]) /**** Rule 12.1 (Adv) ************/ // +e9050 dependence placed on precedence */ // // +elib(9050) // -append(9050,[MISRA 2012 Rule 12.1, advisory]) // +e9097 unparenthesized argument to sizeof */ // // +elib(9097) // -append(9097,[MISRA 2012 Rule 12.1, advisory]) /**** Rule 12.2 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e598 /* excessive left shift */ // +elib(598) -append(598,[MISRA 2012 Rule 12.2, required]) +e9053 /* shift value exceeds size of LHS */ // +elib(9053) -append(9053,[MISRA 2012 Rule 12.2, required]) /**** Rule 12.3 (Adv) ************/ +e9008 /* comma operator used */ // +elib(9008) -append(9008,[MISRA 2012 Rule 12.3, advisory]) /**** Rule 12.4 (Adv) ************/ // +elib(648) Overflow in computing constant +estring(648,unsigned addition) +estring(648,unsigned multiplication) +estring(648,unsigned sub.) +estring(648,unsigned shift left) +estring(648,unsigned shift right) -append(648,[MISRA 2012 Rule 12.4, advisory]) /**** Rule 13.1 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e446 /* side effect in initializer */ // +elib(446) -append(446,[MISRA 2012 Rule 13.1, required]) /**** Rule 13.2 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e564 /* variable depends on order of evaluation */ // +elib(564) -append(564,[MISRA 2012 Rule 13.2, required]) +e931 /* both sides have side effects */ // +elib(931) -append(931,[MISRA 2012 Rule 13.2, required]) /**** Rule 13.3 (Adv) ************/ +e9049 /* increment/decrement combined with other operations */ // +elib(9049) -append(9049,[MISRA 2012 Rule 13.3, advisory]) /**** Rule 13.4 (Adv) ************/ +e720 /* Boolean test of assignment */ // +elib(720) -append(720,[MISRA 2012 Rule 13.4, advisory]) +e820 /* Boolean test of parenthesized assignment */ // +elib(820) -append(820,[MISRA 2012 Rule 13.4, advisory]) +e9084 /* assignment used inside larger expression */ // +elib(9084) -append(9084,[MISRA 2012 Rule 13.4, advisory]) /**** Rule 13.5 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e9007 /* side effects on right hand side of logical operator */ // +elib(9007) -append(9007,[MISRA 2012 Rule 13.5, required]) /**** Rule 13.6 (Mand) ************/ +e9006 /* sizeof used with expression with side effect */ // +elib(9006) -append(9006,[MISRA 2012 Rule 13.6, mandatory]) +e9089 /* potential side-effect in argument to sizeof */ // +elib(9089) -append(9089,[MISRA 2012 Rule 13.6, mandatory]) /**** Rule 14.1 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e9009 /* floating point variable used as loop counter */ // +elib(9009) -append(9009,[MISRA 2012 Rule 14.1, required]) /**** Rule 14.2 (Req) ************/ /* Not currently supported */ /**** Rule 14.3 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e685 /* relational always evaluates to true/false */ // +elib(685) -append(685,[MISRA 2012 Rule 14.3, required]) +e774 /* boolean always evaluates to true/false */ // +elib(774) -append(774,[MISRA 2012 Rule 14.3, required]) +e650 /* constant out of range for operator */ // +elib(650) -append(650,[MISRA 2012 Rule 14.3, required]) /**** Rule 14.4 (Req) ************/ +e9036 /* condition should have essentially Boolean type */ // +elib(9036) -append(9036,[MISRA 2012 Rule 14.4, required]) /**** Rule 15.1 (Adv) ************/ // +e801 use of 'goto' is deprecated */ // // +elib(801) // -append(801,[MISRA 2012 Rule 15.1, advisory]) /**** Rule 15.2 (Req) ************/ +e9064 /* goto references earlier label */ // +elib(9064) -append(9064,[MISRA 2012 Rule 15.2, required]) /**** Rule 15.3 (Req) ************/ +e9041 /* goto not nested in the same block as label */ // +elib(9041) -append(9041,[MISRA 2012 Rule 15.3, required]) /**** Rule 15.4 (Adv) ************/ // +e9011 more than one 'break' terminates loop */ // // +elib(9011) // -append(9011,[MISRA 2012 Rule 15.4, advisory]) /**** Rule 15.5 (Adv) ************/ // +e904 return before function end */ // // +elib(904) // -append(904,[MISRA 2012 Rule 15.5, advisory]) /**** Rule 15.6 (Req) ************/ +e9012 /* sub-statement should be a compound statement */ // +elib(9012) -append(9012,[MISRA 2012 Rule 15.6, required]) /**** Rule 15.7 (Req) ************/ +e9013 /* no 'else' at end of 'if ... else if' chain */ // +elib(9013) -append(9013,[MISRA 2012 Rule 15.7, required]) +e9063 /* no comment or action in else-branch */ // +elib(9063) -append(9063,[MISRA 2012 Rule 15.7, required]) /**** Rule 16.1 (Req) ************/ +e616 /* control flows into case/default */ // +elib(616) -append(616,[MISRA 2012 Rule 16.1, required]) +e744 /* switch statement has no default */ // +elib(744) -append(744,[MISRA 2012 Rule 16.1, required]) +e764 /* switch does not have a case */ // +elib(764) -append(764,[MISRA 2012 Rule 16.1, required]) +e825 /* control flows into case/default without -fallthrough comment */ // +elib(825) -append(825,[MISRA 2012 Rule 16.1, required]) +e9014 /* default missing from switch */ // +elib(9014) -append(9014,[MISRA 2012 Rule 16.1, required]) +e9042 /* departure from MISRA switch syntax */ // +elib(9042) -append(9042,[MISRA 2012 Rule 16.1, required]) +e9077 /* missing unconditional break */ // +elib(9077) -append(9077,[MISRA 2012 Rule 16.1, required]) +e9081 /* too few independent cases for switch */ // +elib(9081) -append(9081,[MISRA 2012 Rule 16.1, required]) +e9082 /* switch statement should either begin or end with default label */ // +elib(9082) -append(9082,[MISRA 2012 Rule 16.1, required]) +e9085 /* statement or comment should appear in default case */ // +elib(9085) -append(9085,[MISRA 2012 Rule 16.1, required]) /**** Rule 16.2 (Req) ************/ +e44 /* Need a switch */ // +elib(44) -append(44,[MISRA 2012 Rule 16.2, required]) +e9055 /* enclosing statement is not a switch */ // +elib(9055) -append(9055,[MISRA 2012 Rule 16.2, required]) /**** Rule 16.3 (Req) ************/ +e616 /* control flows into case/default */ // +elib(616) -append(616,[MISRA 2012 Rule 16.3, required]) +e825 /* control flows into case/default without -fallthrough comment */ // +elib(825) -append(825,[MISRA 2012 Rule 16.3, required]) +e9077 /* missing unconditional break */ // +elib(9077) -append(9077,[MISRA 2012 Rule 16.3, required]) +e9090 /* missing unconditional break */ // +elib(9090) -append(9090,[MISRA 2012 Rule 16.3, required]) /**** Rule 16.4 (Req) ************/ +e744 /* switch statement has no default */ // +elib(744) -append(744,[MISRA 2012 Rule 16.4, required]) +e9014 /* switch statement has no default */ // +elib(9014) -append(9014,[MISRA 2012 Rule 16.4, required]) +e9085 /* default case has no statement nor comment */ // +elib(9085) -append(9085,[MISRA 2012 Rule 16.4, required]) /**** Rule 16.5 (Req) ************/ +e9082 /* default should be first or last */ // +elib(9082) -append(9082,[MISRA 2012 Rule 16.5, required]) /**** Rule 16.6 (Req) ************/ +e764 /* switch does not have a case */ // +elib(764) -append(764,[MISRA 2012 Rule 16.6, required]) +e9081 /* too few cases */ // +elib(9081) -append(9081,[MISRA 2012 Rule 16.6, required]) /**** Rule 16.7 (Req) ************/ +e483 /* boolean value in switch expression */ // +elib(483) -append(483,[MISRA 2012 Rule 16.7, required]) /**** Rule 17.1 (Req) ************/ +e829 /* warn on header usage */ // +elib(829) +headerwarn(stdarg.h) -append(829(stdarg.h),[MISRA 2012 Rule 17.1, required]) -deprecate(macro,va_arg,[MISRA 2012 Rule 17.1, required]) -deprecate(macro,va_start,[MISRA 2012 Rule 17.1, required]) -deprecate(macro,va_end,[MISRA 2012 Rule 17.1, required]) -deprecate(macro,va_copy,[MISRA 2012 Rule 17.1, required]) /**** Rule 17.2 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e9070 -append(9070,[MISRA 2012 Rule 17.2, required]) /**** Rule 17.3 (Mand) ************/ +e718 /* symbol undeclared, assumed to return int */ // +elib(718) -append(718,[MISRA 2012 Rule 17.3, mandatory]) /**** Rule 17.4 (Mand) ************/ +e533 /* function should return a value */ // +elib(533) -append(533,[MISRA 2012 Rule 17.4, mandatory]) /**** Rule 17.5 (Adv) ************/ /* MISRA has declared this rule to be "undecidable". */ +e473 /* argument to array parameter too small */ // +elib(473) -append(473,[MISRA 2012 Rule 17.5, advisory]) /**** Rule 17.6 (Mand) ************/ +e9043 /* static between brackets of array declaration */ // +elib(9043) -append(9043,[MISRA 2012 Rule 17.6, mandatory]) /**** Rule 17.7 (Req) ************/ +e534 /* ignoring return value of function */ // +elib(534) -append(534,[MISRA 2012 Rule 17.7, required]) /**** Rule 17.8 (Adv) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e9044 /* function parameter modified */ // +elib(9044) -append(9044,[MISRA 2012 Rule 17.8, advisory]) /**** Rule 18.1 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e415 /* out-of-bounds pointer */ // +elib(415) -append(415,[MISRA 2012 Rule 18.1, required]) +e416 /* out-of-bounds pointer */ // +elib(416) -append(416,[MISRA 2012 Rule 18.1, required]) +e428 /* out-of-bounds pointer */ // +elib(428) -append(428,[MISRA 2012 Rule 18.1, required]) +e661 /* out-of-bounds pointer */ // +elib(661) -append(661,[MISRA 2012 Rule 18.1, required]) +e662 /* out-of-bounds pointer */ // +elib(662) -append(662,[MISRA 2012 Rule 18.1, required]) +e676 /* out-of-bounds pointer */ // +elib(676) -append(676,[MISRA 2012 Rule 18.1, required]) +e796 /* out-of-bounds pointer */ // +elib(796) -append(796,[MISRA 2012 Rule 18.1, required]) +e797 /* out-of-bounds pointer */ // +elib(797) -append(797,[MISRA 2012 Rule 18.1, required]) +e817 /* out-of-bounds pointer */ // +elib(817) -append(817,[MISRA 2012 Rule 18.1, required]) /**** Rule 18.2 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e946 /* relational or subtract operator applied to pointers */ // +elib(946) -append(946,[MISRA 2012 Rule 18.2, required]) +e947 /* relational or subtract operator applied to pointers */ // +elib(947) -append(947,[MISRA 2012 Rule 18.2, required]) /**** Rule 18.3 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e946 /* relational or subtract operator applied to pointers */ // +elib(946) -append(946,[MISRA 2012 Rule 18.3, required]) +e947 /* relational or subtract operator applied to pointers */ // +elib(947) -append(947,[MISRA 2012 Rule 18.3, required]) /**** Rule 18.4 (Adv) ************/ // +e9016 pointer arithmetic other than array indexing used */ // // +elib(9016) // -append(9016,[MISRA 2012 Rule 18.4, advisory]) /**** Rule 18.5 (Adv) ************/ +e9025 /* more than two pointer indirection levels used */ // +elib(9025) -append(9025,[MISRA 2012 Rule 18.5, advisory]) /**** Rule 18.6 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e733 /* assigning address of auto to outer scope symbol */ // +elib(733) -append(733,[MISRA 2012 Rule 18.6, required]) +e789 /* assigning address of auto to static */ // +elib(789) -append(789,[MISRA 2012 Rule 18.6, required]) +e604 /* returning address of auto variable */ // +elib(604) -append(604,[MISRA 2012 Rule 18.6, required]) /**** Rule 18.7 (Req) ************/ +e9038 /* flexible array member declared */ // +elib(9038) -append(9038,[MISRA 2012 Rule 18.7, required]) /**** Rule 18.8 (Req) ************/ +e9035 /* variable length array declared */ // +elib(9035) -append(9035,[MISRA 2012 Rule 18.8, required]) /**** Rule 19.1 (Mand) ************/ /* MISRA has declared this rule to be "undecidable". */ /**** Rule 19.2 (Adv) ************/ +e9018 /* union type/object declared */ // +elib(9018) -append(9018,[MISRA 2012 Rule 19.2, advisory]) /**** Rule 20.1 (Adv) ************/ +e9019 /* declaration before #include */ // +elib(9019) -append(9019,[MISRA 2012 Rule 20.1, advisory]) /**** Rule 20.2 (Req) ************/ +e9020 /* header file name with non-standard character */ // +elib(9020) -append(9020,[MISRA 2012 Rule 20.2, required]) /* Note: If your system requires the '\' be used as a directory separator, uncomment the following option. */ // -estring(9020,\) /**** Rule 20.3 (Req) ************/ +e12 /* Need < or " after #include */ // +elib(12) -append(12,[MISRA 2012 Rule 20.3, required]) /* 544 directive not followed by EOL */ +estring(544,include) // +elib(544) -append(544(include),[MISRA 2012 Rule 20.3, required]) /**** Rule 20.4 (Req) ************/ +e9051 /* macro with same name as a keyword */ // +elib(9051) -append(9051,[MISRA 2012 Rule 20.4, required]) /**** Rule 20.5 (Adv) ************/ +e9021 /* use of '#undef' is discouraged */ // +elib(9021) -append(9021,[MISRA 2012 Rule 20.5, advisory]) /**** Rule 20.6 (Req) ************/ +e436 /* preprocessor directive in invocation of macro */ // +elib(436) -append(436,[MISRA 2012 Rule 20.6, required]) /**** Rule 20.7 (Req) ************/ +e665 /* expression passed to unparenthesized macro */ // +elib(665) -append(665,[MISRA 2012 Rule 20.7, required]) /**** Rule 20.8 (Req) ************/ +e9037 /* conditional of #if/#elif does not evaluate to 0 or 1 */ // +elib(9037) -append(9037,[MISRA 2012 Rule 20.8, required]) /**** Rule 20.9 (Req) ************/ +e553 /* Undefined preprocessor variable, assumed 0 */ // +elib(553) -append(553,[MISRA 2012 Rule 20.9, required]) /**** Rule 20.10 (Adv) ************/ // +e9024 '#/##' operators used */ // // +elib(9024) // -append(9024,[MISRA 2012 Rule 20.10, advisory]) /**** Rule 20.11 (Req) ************/ +e484 /* stringize operator followed by macro parameter followed by pasting operator */ // +elib(484) -append(484,[MISRA 2012 Rule 20.11, required]) /**** Rule 20.12 (Req) ************/ +e9015 /* macro parameter used with and without '#/##' subject to further replacement */ // +elib(9015) -append(9015,[MISRA 2012 Rule 20.12, required]) /**** Rule 20.13 (Req) ************/ /* 544 - directive not followed by EOL */ +e544 // +elib(544) -append(544,[MISRA 2012 Rule 20.13, required]) /* 16 - unknown preprocessor directive */ +e16 // +elib(16) -append(16,[MISRA 2012 Rule 20.13, required]) /* 9160 - unknown preprocessor directive in conditionally excluded region */ +e9160 // +elib(9160) -append(9160,[MISRA 2012 Rule 20.13, required]) /**** Rule 20.14 (Req) ************/ +e405 /* #if/#ifdef/#ifndef not closed off */ // +elib(405) -append(405,[MISRA 2012 Rule 20.14, required]) /**** Rule 21.1 (Req) ************/ +e136 /* Illegal macro name */ // +elib(136) -append(136,[MISRA 2012 Rule 21.1, required]) /* Undefining standard library macros is covered by rule 20.5. */ /* Defining/redefining reserved/standard identifiers is covered by rules 20.4 and 21.2. */ +e9071 /* defined macro reserved to the compiler */ // +elib(9071) -append(9071,[MISRA 2012 Rule 21.1, required]) // explicit exemptions -estring(9071,* because *) -estring(9071,cerf) -estring(9071,cerfc) -estring(9071,cexp2) -estring(9071,cexpm1) -estring(9071,clog10) -estring(9071,clog1p) -estring(9071,clog2) -estring(9071,clgamma) -estring(9071,ctgamma) -estring(9071,cerff) -estring(9071,cerfcf) -estring(9071,cexp2f) -estring(9071,cexpm1f) -estring(9071,clog10f) -estring(9071,clog1pf) -estring(9071,clog2f) -estring(9071,clgammaf) -estring(9071,ctgammaf) -estring(9071,cerfl) -estring(9071,cerfcl) -estring(9071,cexp2l) -estring(9071,cexpm1l) -estring(9071,clog10l) -estring(9071,clog1pl) -estring(9071,clog2l) -estring(9071,clgammal) -estring(9071,ctgammal) -estring(9071,E0*) -estring(9071,E1*) -estring(9071,E2*) -estring(9071,E3*) -estring(9071,E4*) -estring(9071,E5*) -estring(9071,E6*) -estring(9071,E7*) -estring(9071,E8*) -estring(9071,E9*) -estring(9071,NDEBUG) -estring(9071,PRIa*) -estring(9071,PRIb*) -estring(9071,PRIc*) -estring(9071,PRId*) -estring(9071,PRIe*) -estring(9071,PRIf*) -estring(9071,PRIg*) -estring(9071,PRIh*) -estring(9071,PRIi*) -estring(9071,PRIj*) -estring(9071,PRIk*) -estring(9071,PRIl*) -estring(9071,PRIm*) -estring(9071,PRIn*) -estring(9071,PRIo*) -estring(9071,PRIp*) -estring(9071,PRIq*) -estring(9071,PRIr*) -estring(9071,PRIs*) -estring(9071,PRIt*) -estring(9071,PRIu*) -estring(9071,PRIv*) -estring(9071,PRIw*) -estring(9071,PRIx*) -estring(9071,PRIy*) -estring(9071,PRIz*) -estring(9071,PRIX*) -estring(9071,SCNa*) -estring(9071,SCNb*) -estring(9071,SCNc*) -estring(9071,SCNd*) -estring(9071,SCNe*) -estring(9071,SCNf*) -estring(9071,SCNg*) -estring(9071,SCNh*) -estring(9071,SCNi*) -estring(9071,SCNj*) -estring(9071,SCNk*) -estring(9071,SCNl*) -estring(9071,SCNm*) -estring(9071,SCNn*) -estring(9071,SCNo*) -estring(9071,SCNp*) -estring(9071,SCNq*) -estring(9071,SCNr*) -estring(9071,SCNs*) -estring(9071,SCNt*) -estring(9071,SCNu*) -estring(9071,SCNv*) -estring(9071,SCNw*) -estring(9071,SCNx*) -estring(9071,SCNy*) -estring(9071,SCNz*) -estring(9071,SCNX*) +e9083 /* undefined macro reserved to the compiler */ // +elib(9083) -append(9083,[MISRA 2012 Rule 21.1, required]) // explicit exemptions -estring(9083,* because *) -estring(9083,cerf) -estring(9083,cerfc) -estring(9083,cexp2) -estring(9083,cexpm1) -estring(9083,clog10) -estring(9083,clog1p) -estring(9083,clog2) -estring(9083,clgamma) -estring(9083,ctgamma) -estring(9083,cerff) -estring(9083,cerfcf) -estring(9083,cexp2f) -estring(9083,cexpm1f) -estring(9083,clog10f) -estring(9083,clog1pf) -estring(9083,clog2f) -estring(9083,clgammaf) -estring(9083,ctgammaf) -estring(9083,cerfl) -estring(9083,cerfcl) -estring(9083,cexp2l) -estring(9083,cexpm1l) -estring(9083,clog10l) -estring(9083,clog1pl) -estring(9083,clog2l) -estring(9083,clgammal) -estring(9083,ctgammal) -estring(9083,E0*) -estring(9083,E1*) -estring(9083,E2*) -estring(9083,E3*) -estring(9083,E4*) -estring(9083,E5*) -estring(9083,E6*) -estring(9083,E7*) -estring(9083,E8*) -estring(9083,E9*) -estring(9083,NDEBUG) -estring(9083,PRIa*) -estring(9083,PRIb*) -estring(9083,PRIc*) -estring(9083,PRId*) -estring(9083,PRIe*) -estring(9083,PRIf*) -estring(9083,PRIg*) -estring(9083,PRIh*) -estring(9083,PRIi*) -estring(9083,PRIj*) -estring(9083,PRIk*) -estring(9083,PRIl*) -estring(9083,PRIm*) -estring(9083,PRIn*) -estring(9083,PRIo*) -estring(9083,PRIp*) -estring(9083,PRIq*) -estring(9083,PRIr*) -estring(9083,PRIs*) -estring(9083,PRIt*) -estring(9083,PRIu*) -estring(9083,PRIv*) -estring(9083,PRIw*) -estring(9083,PRIx*) -estring(9083,PRIy*) -estring(9083,PRIz*) -estring(9083,PRIX*) -estring(9083,SCNa*) -estring(9083,SCNb*) -estring(9083,SCNc*) -estring(9083,SCNd*) -estring(9083,SCNe*) -estring(9083,SCNf*) -estring(9083,SCNg*) -estring(9083,SCNh*) -estring(9083,SCNi*) -estring(9083,SCNj*) -estring(9083,SCNk*) -estring(9083,SCNl*) -estring(9083,SCNm*) -estring(9083,SCNn*) -estring(9083,SCNo*) -estring(9083,SCNp*) -estring(9083,SCNq*) -estring(9083,SCNr*) -estring(9083,SCNs*) -estring(9083,SCNt*) -estring(9083,SCNu*) -estring(9083,SCNv*) -estring(9083,SCNw*) -estring(9083,SCNx*) -estring(9083,SCNy*) -estring(9083,SCNz*) -estring(9083,SCNX*) /**** Rule 21.2 (Req) ************/ +e683 /* complain about #define standard functions */ // +elib(683) -append(683,[MISRA 2012 Rule 21.2, required]) /* Undefining standard library macros is covered by rule 20.5. */ /* Defining/redefining reserved/standard identifiers is covered by rule 20.4 and 21.2. */ /**** Rule 21.3 (Req) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(function,calloc,[MISRA 2012 Rule 21.3, required]) -deprecate(macro,calloc,[MISRA 2012 Rule 21.3, required]) -deprecate(function,malloc,[MISRA 2012 Rule 21.3, required]) -deprecate(macro,malloc,[MISRA 2012 Rule 21.3, required]) -deprecate(function,realloc,[MISRA 2012 Rule 21.3, required]) -deprecate(macro,realloc,[MISRA 2012 Rule 21.3, required]) -deprecate(function,free,[MISRA 2012 Rule 21.3, required]) -deprecate(macro,free,[MISRA 2012 Rule 21.3, required]) /**** Rule 21.4 (Req) ************/ +e829 /* warn on header usage */ // +elib(829) +headerwarn(setjmp.h) -append(829(setjmp.h),[MISRA 2012 Rule 21.4, required]) -deprecate(function,setjmp,[MISRA 2012 Rule 21.4, required]) -deprecate(function,longjmp,[MISRA 2012 Rule 21.4, required]) -deprecate(macro,setjmp,[MISRA 2012 Rule 21.4, required]) -deprecate(macro,longjmp,[MISRA 2012 Rule 21.4, required]) /**** Rule 21.5 (Req) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(function,signal,[MISRA 2012 Rule 21.5, required]) -deprecate(function,raise,[MISRA 2012 Rule 21.5, required]) -deprecate(macro,SIGABRT,[MISRA 2012 Rule 21.5, required]) -deprecate(macro,SIGFPE,[MISRA 2012 Rule 21.5, required]) -deprecate(macro,SIGILL,[MISRA 2012 Rule 21.5, required]) -deprecate(macro,SIGINT,[MISRA 2012 Rule 21.5, required]) -deprecate(macro,SIGSEGV,[MISRA 2012 Rule 21.5, required]) -deprecate(macro,SIGTERM,[MISRA 2012 Rule 21.5, required]) -deprecate(macro,SIG_DFL,[MISRA 2012 Rule 21.5, required]) -deprecate(macro,SIG_ERR,[MISRA 2012 Rule 21.5, required]) -deprecate(macro,SIG_IGN,[MISRA 2012 Rule 21.5, required]) +e829 /* warn on header usage */ // +elib(829) +headerwarn(signal.h) -append(829(signal.h),[MISRA 2012 Rule 21.5, required]) /**** Rule 21.6 (Req) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(function,clearerr,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fclose,[MISRA 2012 Rule 21.6, required]) -deprecate(function,feof,[MISRA 2012 Rule 21.6, required]) -deprecate(function,ferror,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fflush,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fgetc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fgetpos,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fgets,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fgetwc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fgetws,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fopen,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fputc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fputs,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fputwc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fputws,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fread,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fseek,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fsetpos,[MISRA 2012 Rule 21.6, required]) -deprecate(function,freopen,[MISRA 2012 Rule 21.6, required]) -deprecate(function,ftell,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fwide,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fwprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fwrite,[MISRA 2012 Rule 21.6, required]) -deprecate(function,fwscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,getc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,getchar,[MISRA 2012 Rule 21.6, required]) -deprecate(function,gets,[MISRA 2012 Rule 21.6, required]) -deprecate(function,getwc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,getwchar,[MISRA 2012 Rule 21.6, required]) -deprecate(function,perror,[MISRA 2012 Rule 21.6, required]) -deprecate(function,printf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,putc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,putchar,[MISRA 2012 Rule 21.6, required]) -deprecate(function,puts,[MISRA 2012 Rule 21.6, required]) -deprecate(function,putwc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,putwchar,[MISRA 2012 Rule 21.6, required]) -deprecate(function,remove,[MISRA 2012 Rule 21.6, required]) -deprecate(function,rename,[MISRA 2012 Rule 21.6, required]) -deprecate(function,rewind,[MISRA 2012 Rule 21.6, required]) -deprecate(function,scanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,setbuf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,setvbuf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,snprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,sprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,sscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,swprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,swscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,tmpfile,[MISRA 2012 Rule 21.6, required]) -deprecate(function,tmpnam,[MISRA 2012 Rule 21.6, required]) -deprecate(function,ungetc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,ungetwc,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vfprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vfscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vfwprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vfwscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vsnprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vsprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vsscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vswprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vswscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vwprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,vwscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,wprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(function,wscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,clearerr,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fclose,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,feof,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,ferror,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fflush,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fgetc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fgets,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fgetpos,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fgetwc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fgetws,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fopen,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fputc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fputs,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fputwc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fputws,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fread,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fseek,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fsetpos,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,freopen,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,ftell,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fwide,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fwprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fwrite,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,fwscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,getc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,getchar,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,gets,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,getwc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,getwchar,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,perror,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,printf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,putc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,putchar,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,puts,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,putwc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,putwchar,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,remove,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,rename,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,rewind,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,scanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,setbuf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,setvbuf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,snprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,sprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,sscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,swprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,swscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,tmpfile,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,tmpnam,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,ungetc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,ungetwc,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vfprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vfscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vfwprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vfwscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vsnprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vsprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vsscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vswprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vswscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vwprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,vwscanf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,wprintf,[MISRA 2012 Rule 21.6, required]) -deprecate(macro,wscanf,[MISRA 2012 Rule 21.6, required]) /**** Rule 21.7 (Req) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(function,atof,[MISRA 2012 Rule 21.7, required]) -deprecate(function,atoi,[MISRA 2012 Rule 21.7, required]) -deprecate(function,atol,[MISRA 2012 Rule 21.7, required]) -deprecate(function,atoll,[MISRA 2012 Rule 21.7, required]) -deprecate(macro,atof,[MISRA 2012 Rule 21.7, required]) -deprecate(macro,atoi,[MISRA 2012 Rule 21.7, required]) -deprecate(macro,atol,[MISRA 2012 Rule 21.7, required]) -deprecate(macro,atoll,[MISRA 2012 Rule 21.7, required]) /**** Rule 21.8 (Req) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(function,abort,[MISRA 2012 Rule 21.8, required]) -deprecate(function,exit,[MISRA 2012 Rule 21.8, required]) -deprecate(function,getenv,[MISRA 2012 Rule 21.8, required]) -deprecate(function,system,[MISRA 2012 Rule 21.8, required]) -deprecate(macro,abort,[MISRA 2012 Rule 21.8, required]) -deprecate(macro,exit,[MISRA 2012 Rule 21.8, required]) -deprecate(macro,getenv,[MISRA 2012 Rule 21.8, required]) -deprecate(macro,system,[MISRA 2012 Rule 21.8, required]) /**** Rule 21.9 (Req) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(function,bsearch,[MISRA 2012 Rule 21.9, required]) -deprecate(function,qsort,[MISRA 2012 Rule 21.9, required]) -deprecate(macro,bsearch,[MISRA 2012 Rule 21.9, required]) -deprecate(macro,qsort,[MISRA 2012 Rule 21.9, required]) /**** Rule 21.10 (Req) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(macro,wcsftime,[MISRA 2012 Rule 21.10, required]) -deprecate(function,wcsftime,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,clock,[MISRA 2012 Rule 21.10, required]) -deprecate(function,clock,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,difftime,[MISRA 2012 Rule 21.10, required]) -deprecate(function,difftime,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,mktime,[MISRA 2012 Rule 21.10, required]) -deprecate(function,mktime,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,time,[MISRA 2012 Rule 21.10, required]) -deprecate(function,time,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,asctime,[MISRA 2012 Rule 21.10, required]) -deprecate(function,asctime,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,ctime,[MISRA 2012 Rule 21.10, required]) -deprecate(function,ctime,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,gmtime,[MISRA 2012 Rule 21.10, required]) -deprecate(function,gmtime,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,localtime,[MISRA 2012 Rule 21.10, required]) -deprecate(function,localtime,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,strftime,[MISRA 2012 Rule 21.10, required]) -deprecate(function,strftime,[MISRA 2012 Rule 21.10, required]) -deprecate(macro,CLOCKS_PER_SEC,[MISRA 2012 Rule 21.10, required]) +e829 /* warn on header usage */ // +elib(829) // +headerwarn(time.h) // -append(829(time.h),[MISRA 2012 Rule 21.10, required]) /**** Rule 21.11 (Req) ************/ +e829 /* warn on header usage */ // +elib(829) +headerwarn(tgmath.h) -append(829(tgmath.h),[MISRA 2012 Rule 21.11, required]) /**** Rule 21.12 (Adv) ************/ +e586 /* Symbol is deprecated */ // +elib(586) -deprecate(function,feclearexcept,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,feclearexcept,[MISRA 2012 Rule 21.12, advisory]) -deprecate(function,fegetexceptflag,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,fegetexceptflag,[MISRA 2012 Rule 21.12, advisory]) -deprecate(function,feraiseexcept,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,feraiseexcept,[MISRA 2012 Rule 21.12, advisory]) -deprecate(function,fesetexceptflag,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,fesetexceptflag,[MISRA 2012 Rule 21.12, advisory]) -deprecate(function,fetestexcept,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,fetestexcept,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,FE_INEXACT,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,FE_DIVBYZERO,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,FE_UNDERFLOW,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,FE_OVERFLOW,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,FE_INVALID,[MISRA 2012 Rule 21.12, advisory]) -deprecate(macro,FE_ALL_EXCEPT,[MISRA 2012 Rule 21.12, advisory]) /**** Rule 22.1 (Req) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e429 /* custodial pointer neither free'd nor returned */ // +elib(429) -append(429,[MISRA 2012 Rule 22.1, required]) //-function_pair(fopen,fclose) // not yet implemented +e480 /* no balancing call */ // +elib(480) -append(480,[MISRA 2012 Rule 22.1, required]) +e481 /* different balance call states */ // +elib(481) -append(481,[MISRA 2012 Rule 22.1, required]) /**** Rule 22.2 (Mand) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e424 /* inappropriate deallocation */ // +elib(424) -append(424,[MISRA 2012 Rule 22.2, mandatory]) +e449 /* pointer previously deallocated */ // +elib(449) -append(449,[MISRA 2012 Rule 22.2, mandatory]) /**** Rule 22.3 (Req) ************/ /* MISRA has declared this rule to be "undecidable". */ /**** Rule 22.4 (Mand) ************/ /* MISRA has declared this rule to be "undecidable". */ /**** Rule 22.5 (Mand) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel Software provides the following message to assist: */ +e9047 /* FILE pointer dereferenced */ // +elib(9047) -append(9047,[MISRA 2012 Rule 22.5, mandatory]) /**** Rule 22.6 (Mand) ************/ /* While MISRA has declared this rule to be "undecidable", Gimpel * Software provides the following options to assist: */ +e449 /* previously deallocated pointer */ // +elib(449) -append(449,[MISRA 2012 Rule 22.6, mandatory])ament_lint-0.12.0/ament_pclint/ament_pclint/config/c++.lnt000066400000000000000000000006341420377356500234310ustar00rootroot00000000000000/////////////////////////////////////////////////////////////////////// -v -t4 -u -b -width(0,4) ++"d__thread=" --u_GLIBCXX_USE_INT128 /////////////////////////////////////////////////////////////////////////////// ../au-misra-cpp.lnt ../deprecate.lnt -std=c++14 -e1731 // public virtual function symbol -e1790 // public base 'rclcpp::Node' of 'my_cool_pkg::MyCoolPkg' has no non-destructor virtual functions ament_lint-0.12.0/ament_pclint/ament_pclint/config/c99.lnt000066400000000000000000000005501420377356500234620ustar00rootroot00000000000000/////////////////////////////////////////////////////////////////////// -v -t4 -u -b -width(0,4) ++"d__thread=" --u_GLIBCXX_USE_INT128 /////////////////////////////////////////////////////////////////////////////// -e708 // union initialization -e801 // goto statement used -emacro(*, INVALID_SOCKET) ../au-misra3.lnt ../au-misra3-amd1.lnt ../deprecate.lnt ament_lint-0.12.0/ament_pclint/ament_pclint/config/deprecate.lnt000066400000000000000000000010171420377356500250110ustar00rootroot00000000000000 -deprecate(type, size_t, "Use size64_t instead") -deprecate(type, bool, "Use bool8_t instead") -deprecate(function, memcpy, "Use memmove instead") -deprecate(function, strcpy, "Use strncpy instead") -deprecate(function, strlen, "Use srnlen instead") -deprecate(function, strcat, "Use strncat instead") -deprecate(function, strcmp, "Use strncmp instead") -deprecate(function, strdup, "Use Apex memory management") -deprecate(function, sprintf, "Use snprintf instead") -deprecate(function, vsprintf, "Use vsnprintf instead") ament_lint-0.12.0/ament_pclint/ament_pclint/config/env-xml.lnt000066400000000000000000000024431420377356500244470ustar00rootroot00000000000000/* Date Stamp */ -d"_lint_env_xml_lnt=env-xml.lnt modified 20-Nov-2003" /* To document usage use: -message( "Using " _lint_env_xml_lnt ) */ // --------------------------------------------------------------------- // This file is provided by Gimpel Software (www.gimpel.com) for use with // its products PC-lint and FlexeLint. // // Redistribution and use of this file, with or without modification, is // permitted provided that any such redistribution retains this notice. // --------------------------------------------------------------------- /* env-xml.lnt The following options cause the output of PC-lint/Flexelint to assume the format of an XML file. The tags chosen are the obvious ones; but they can be customized as needed. */ -v // turn off verbosity -width(0) // don't insert line breaks (unlimited output width). +xml() // turn on xml escapes; the whole is bracketed with the // pair ... -"format=%f %l %t %n %m" -"format_specific= " -hFs1 // The height of a message should be 1 (i.e. don't output the // line in error); always produce File information; and Space // between messages -pragma(message) // do not issue pragma messages ament_lint-0.12.0/ament_pclint/ament_pclint/config/gcc/000077500000000000000000000000001420377356500230735ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/ament_pclint/config/gcc/co-g++.h000066400000000000000000000414351420377356500242260ustar00rootroot00000000000000#ifndef GS_PCLP_CO_G_H #define GS_PCLP_CO_G_H #ifndef __cplusplus #define __SSP_STRONG__ 3 #define __DBL_MIN_EXP__ (-1021) #define __UINT_LEAST16_MAX__ 0xffff #define __ATOMIC_ACQUIRE 2 #define __FLT_MIN__ 1.17549435082228750797e-38F #define __GCC_IEC_559_COMPLEX 2 #define __UINT_LEAST8_TYPE__ unsigned char #define __SIZEOF_FLOAT80__ 16 #define __INTMAX_C(c) c ## L #define __CHAR_BIT__ 8 #define __UINT8_MAX__ 0xff #define __WINT_MAX__ 0xffffffffU #define __ORDER_LITTLE_ENDIAN__ 1234 #define __SIZE_MAX__ 0xffffffffffffffffUL #define __WCHAR_MAX__ 0x7fffffff #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L) #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __GCC_IEC_559 2 #define __FLT_EVAL_METHOD__ 0 #define __unix__ 1 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __x86_64 1 #define __UINT_FAST64_MAX__ 0xffffffffffffffffUL #define __SIG_ATOMIC_TYPE__ int #define __DBL_MIN_10_EXP__ (-307) #define __FINITE_MATH_ONLY__ 0 #define __GNUC_PATCHLEVEL__ 0 #define __UINT_FAST8_MAX__ 0xff #define __DEC64_MAX_EXP__ 385 #define __INT8_C(c) c #define __UINT_LEAST64_MAX__ 0xffffffffffffffffUL #define __SHRT_MAX__ 0x7fff #define __LDBL_MAX__ 1.18973149535723176502e+4932L #define __UINT_LEAST8_MAX__ 0xff #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __UINTMAX_TYPE__ long unsigned int #define __linux 1 #define __DEC32_EPSILON__ 1E-6DF #define __unix 1 #define __UINT32_MAX__ 0xffffffffU #define __LDBL_MAX_EXP__ 16384 #define __WINT_MIN__ 0U #define __linux__ 1 #define __SCHAR_MAX__ 0x7f #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1) #define __INT64_C(c) c ## L #define __DBL_DIG__ 15 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __SIZEOF_INT__ 4 #define __SIZEOF_POINTER__ 8 #define __USER_LABEL_PREFIX__ #define __STDC_HOSTED__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __FLT_EPSILON__ 1.19209289550781250000e-7F #define __LDBL_MIN__ 3.36210314311209350626e-4932L #define __STDC_UTF_16__ 1 #define __DEC32_MAX__ 9.999999E96DF #define __INT32_MAX__ 0x7fffffff #define __SIZEOF_LONG__ 8 #define __STDC_IEC_559__ 1 #define __STDC_ISO_10646__ 201505L #define __UINT16_C(c) c #define __DECIMAL_DIG__ 21 #define __gnu_linux__ 1 #define __LDBL_HAS_QUIET_NAN__ 1 #define __GNUC__ 5 #define __MMX__ 1 #define __FLT_HAS_DENORM__ 1 #define __SIZEOF_LONG_DOUBLE__ 16 #define __BIGGEST_ALIGNMENT__ 16 #define __DBL_MAX__ ((double)1.79769313486231570815e+308L) #define __INT_FAST32_MAX__ 0x7fffffffffffffffL #define __DBL_HAS_INFINITY__ 1 #define __DEC32_MIN_EXP__ (-94) #define __INT_FAST16_TYPE__ long int #define __LDBL_HAS_DENORM__ 1 #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL #define __INT_LEAST32_MAX__ 0x7fffffff #define __DEC32_MIN__ 1E-95DF #define __DBL_MAX_EXP__ 1024 #define __DEC128_EPSILON__ 1E-33DL #define __SSE2_MATH__ 1 #define __ATOMIC_HLE_RELEASE 131072 #define __PTRDIFF_MAX__ 0x7fffffffffffffffL #define __amd64 1 #define __STDC_NO_THREADS__ 1 #define __ATOMIC_HLE_ACQUIRE 65536 #define __LONG_LONG_MAX__ 0x7fffffffffffffffLL #define __SIZEOF_SIZE_T__ 8 #define __SIZEOF_WINT_T__ 4 #define __GCC_HAVE_DWARF2_CFI_ASM 1 #define __GXX_ABI_VERSION 1009 #define __FLT_MIN_EXP__ (-125) #define __INT_FAST64_TYPE__ long int #define __DBL_MIN__ ((double)2.22507385850720138309e-308L) #define __LP64__ 1 #define __DECIMAL_BID_FORMAT__ 1 #define __DEC128_MIN__ 1E-6143DL #define __REGISTER_PREFIX__ #define __UINT16_MAX__ 0xffff #define __DBL_HAS_DENORM__ 1 #define __UINT8_TYPE__ unsigned char #define __NO_INLINE__ 1 #define __FLT_MANT_DIG__ 24 #define __VERSION__ "5.4.0 20160609" #define __UINT64_C(c) c ## UL #define _STDC_PREDEF_H 1 #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __STDC_IEC_559_COMPLEX__ 1 #define __INT32_C(c) c #define __DEC64_EPSILON__ 1E-15DD #define __ORDER_PDP_ENDIAN__ 3412 #define __DEC128_MIN_EXP__ (-6142) #define __INT_FAST32_TYPE__ long int #define __UINT_LEAST16_TYPE__ short unsigned int #define unix 1 #define __INT16_MAX__ 0x7fff #define __SIZE_TYPE__ long unsigned int #define __UINT64_MAX__ 0xffffffffffffffffUL #define __INT8_TYPE__ signed char #define __ELF__ 1 #define __FLT_RADIX__ 2 #define __INT_LEAST16_TYPE__ short int #define __LDBL_EPSILON__ 1.08420217248550443401e-19L #define __UINTMAX_C(c) c ## UL #define __SSE_MATH__ 1 #define __k8 1 #define __SIG_ATOMIC_MAX__ 0x7fffffff #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __SIZEOF_PTRDIFF_T__ 8 #define __x86_64__ 1 #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF #define __INT_FAST16_MAX__ 0x7fffffffffffffffL #define __UINT_FAST32_MAX__ 0xffffffffffffffffUL #define __UINT_LEAST64_TYPE__ long unsigned int #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MAX_10_EXP__ 38 #define __LONG_MAX__ 0x7fffffffffffffffL #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL #define __FLT_HAS_INFINITY__ 1 #define __UINT_FAST16_TYPE__ long unsigned int #define __DEC64_MAX__ 9.999999999999999E384DD #define __CHAR16_TYPE__ short unsigned int #define __PRAGMA_REDEFINE_EXTNAME 1 #define __INT_LEAST16_MAX__ 0x7fff #define __DEC64_MANT_DIG__ 16 #define __INT64_MAX__ 0x7fffffffffffffffL #define __UINT_LEAST32_MAX__ 0xffffffffU #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __INT_LEAST64_TYPE__ long int #define __INT16_TYPE__ short int #define __INT_LEAST8_TYPE__ signed char #define __STDC_VERSION__ 201112L #define __DEC32_MAX_EXP__ 97 #define __INT_FAST8_MAX__ 0x7f #define __INTPTR_MAX__ 0x7fffffffffffffffL #define linux 1 #define __SSE2__ 1 #define __LDBL_MANT_DIG__ 64 #define __DBL_HAS_QUIET_NAN__ 1 #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) #define __code_model_small__ 1 #define __k8__ 1 #define __INTPTR_TYPE__ long int #define __UINT16_TYPE__ short unsigned int #define __WCHAR_TYPE__ int #define __SIZEOF_FLOAT__ 4 #define __UINTPTR_MAX__ 0xffffffffffffffffUL #define __DEC64_MIN_EXP__ (-382) #define __INT_FAST64_MAX__ 0x7fffffffffffffffL #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __FLT_DIG__ 6 #define __UINT_FAST64_TYPE__ long unsigned int #define __INT_MAX__ 0x7fffffff #define __amd64__ 1 #define __INT64_TYPE__ long int #define __FLT_MAX_EXP__ 128 #define __ORDER_BIG_ENDIAN__ 4321 #define __DBL_MANT_DIG__ 53 #define __SIZEOF_FLOAT128__ 16 #define __INT_LEAST64_MAX__ 0x7fffffffffffffffL #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __DEC64_MIN__ 1E-383DD #define __WINT_TYPE__ unsigned int #define __UINT_LEAST32_TYPE__ unsigned int #define __SIZEOF_SHORT__ 2 #define __SSE__ 1 #define __LDBL_MIN_EXP__ (-16381) #define __INT_LEAST8_MAX__ 0x7f #define __SIZEOF_INT128__ 16 #define __LDBL_MAX_10_EXP__ 4932 #define __ATOMIC_RELAXED 0 #define __DBL_EPSILON__ ((double)2.22044604925031308085e-16L) #define _LP64 1 #define __UINT8_C(c) c #define __INT_LEAST32_TYPE__ int #define __SIZEOF_WCHAR_T__ 4 #define __UINT64_TYPE__ long unsigned int #define __INT_FAST8_TYPE__ signed char #define __GNUC_STDC_INLINE__ 1 #define __DBL_DECIMAL_DIG__ 17 #define __STDC_UTF_32__ 1 #define __FXSR__ 1 #define __DEC_EVAL_METHOD__ 2 #define __UINT32_C(c) c ## U #define __INTMAX_MAX__ 0x7fffffffffffffffL #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F #define __INT8_MAX__ 0x7f #define __UINT_FAST32_TYPE__ long unsigned int #define __CHAR32_TYPE__ unsigned int #define __FLT_MAX__ 3.40282346638528859812e+38F #define __INT32_TYPE__ int #define __SIZEOF_DOUBLE__ 8 #define __FLT_MIN_10_EXP__ (-37) #define __INTMAX_TYPE__ long int #define __DEC128_MAX_EXP__ 6145 #define __ATOMIC_CONSUME 1 #define __GNUC_MINOR__ 4 #define __UINTMAX_MAX__ 0xffffffffffffffffUL #define __DEC32_MANT_DIG__ 7 #define __DBL_MAX_10_EXP__ 308 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L #define __INT16_C(c) c #define __STDC__ 1 #define __PTRDIFF_TYPE__ long int #define __ATOMIC_SEQ_CST 5 #define __UINT32_TYPE__ unsigned int #define __UINTPTR_TYPE__ long unsigned int #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD #define __DEC128_MANT_DIG__ 34 #define __LDBL_MIN_10_EXP__ (-4931) #define __SIZEOF_LONG_LONG__ 8 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __LDBL_DIG__ 18 #define __FLT_DECIMAL_DIG__ 9 #define __UINT_FAST16_MAX__ 0xffffffffffffffffUL #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __UINT_FAST8_TYPE__ unsigned char #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_RELEASE 3 #endif #ifdef __cplusplus #define __SSP_STRONG__ 3 #define __DBL_MIN_EXP__ (-1021) #define __UINT_LEAST16_MAX__ 0xffff #define __ATOMIC_ACQUIRE 2 #define __FLT_MIN__ 1.17549435082228750797e-38F #define __GCC_IEC_559_COMPLEX 2 #define __UINT_LEAST8_TYPE__ unsigned char #define __SIZEOF_FLOAT80__ 16 #define __INTMAX_C(c) c ## L #define __CHAR_BIT__ 8 #define __UINT8_MAX__ 0xff #define __WINT_MAX__ 0xffffffffU #define __ORDER_LITTLE_ENDIAN__ 1234 #define __SIZE_MAX__ 0xffffffffffffffffUL #define __WCHAR_MAX__ 0x7fffffff #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L) #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __GCC_IEC_559 2 #define __FLT_EVAL_METHOD__ 0 #define __unix__ 1 #define __cpp_binary_literals 201304 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __x86_64 1 #define __UINT_FAST64_MAX__ 0xffffffffffffffffUL #define __SIG_ATOMIC_TYPE__ int #define __DBL_MIN_10_EXP__ (-307) #define __FINITE_MATH_ONLY__ 0 #define __GNUC_PATCHLEVEL__ 0 #define __UINT_FAST8_MAX__ 0xff #define __DEC64_MAX_EXP__ 385 #define __INT8_C(c) c #define __UINT_LEAST64_MAX__ 0xffffffffffffffffUL #define __SHRT_MAX__ 0x7fff #define __LDBL_MAX__ 1.18973149535723176502e+4932L #define __UINT_LEAST8_MAX__ 0xff #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __UINTMAX_TYPE__ long unsigned int #define __linux 1 #define __DEC32_EPSILON__ 1E-6DF #define __unix 1 #define __UINT32_MAX__ 0xffffffffU #define __LDBL_MAX_EXP__ 16384 #define __WINT_MIN__ 0U #define __linux__ 1 #define __SCHAR_MAX__ 0x7f #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1) #define __INT64_C(c) c ## L #define __DBL_DIG__ 15 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __SIZEOF_INT__ 4 #define __SIZEOF_POINTER__ 8 #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __USER_LABEL_PREFIX__ #define __STDC_HOSTED__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __FLT_EPSILON__ 1.19209289550781250000e-7F #define __GXX_WEAK__ 1 #define __LDBL_MIN__ 3.36210314311209350626e-4932L #define __DEC32_MAX__ 9.999999E96DF #define __INT32_MAX__ 0x7fffffff #define __SIZEOF_LONG__ 8 #define __STDC_IEC_559__ 1 #define __STDC_ISO_10646__ 201505L #define __UINT16_C(c) c #define __DECIMAL_DIG__ 21 #define __gnu_linux__ 1 #define __LDBL_HAS_QUIET_NAN__ 1 #define __GNUC__ 5 #define __GXX_RTTI 1 #define __MMX__ 1 #define __FLT_HAS_DENORM__ 1 #define __SIZEOF_LONG_DOUBLE__ 16 #define __BIGGEST_ALIGNMENT__ 16 #define __DBL_MAX__ double(1.79769313486231570815e+308L) #define __INT_FAST32_MAX__ 0x7fffffffffffffffL #define __DBL_HAS_INFINITY__ 1 #define __INT64_MAX__ 0x7fffffffffffffffL #define __DEC32_MIN_EXP__ (-94) #define __INT_FAST16_TYPE__ long int #define __LDBL_HAS_DENORM__ 1 #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL #define __INT_LEAST32_MAX__ 0x7fffffff #define __DEC32_MIN__ 1E-95DF #define __DEPRECATED 1 #define __DBL_MAX_EXP__ 1024 #define __DEC128_EPSILON__ 1E-33DL #define __SSE2_MATH__ 1 #define __ATOMIC_HLE_RELEASE 131072 #define __PTRDIFF_MAX__ 0x7fffffffffffffffL #define __amd64 1 #define __STDC_NO_THREADS__ 1 #define __ATOMIC_HLE_ACQUIRE 65536 #define __GNUG__ 5 #define __LONG_LONG_MAX__ 0x7fffffffffffffffLL #define __SIZEOF_SIZE_T__ 8 #define __SIZEOF_WINT_T__ 4 #define __GCC_HAVE_DWARF2_CFI_ASM 1 #define __GXX_ABI_VERSION 1009 #define __FLT_MIN_EXP__ (-125) #define __INT_FAST64_TYPE__ long int #define __DBL_MIN__ double(2.22507385850720138309e-308L) #define __LP64__ 1 #define __DECIMAL_BID_FORMAT__ 1 #define __DEC128_MIN__ 1E-6143DL #define __REGISTER_PREFIX__ #define __UINT16_MAX__ 0xffff #define __DBL_HAS_DENORM__ 1 #define __UINT8_TYPE__ unsigned char #define __NO_INLINE__ 1 #define __FLT_MANT_DIG__ 24 #define __VERSION__ "5.4.0 20160609" #define __UINT64_C(c) c ## UL #define _STDC_PREDEF_H 1 #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __STDC_IEC_559_COMPLEX__ 1 #define __INT32_C(c) c #define __DEC64_EPSILON__ 1E-15DD #define __ORDER_PDP_ENDIAN__ 3412 #define __DEC128_MIN_EXP__ (-6142) #define __INT_FAST32_TYPE__ long int #define __UINT_LEAST16_TYPE__ short unsigned int #define unix 1 #define __INT16_MAX__ 0x7fff #define __cpp_rtti 199711 #define __SIZE_TYPE__ long unsigned int #define __UINT64_MAX__ 0xffffffffffffffffUL #define __INT8_TYPE__ signed char #define __ELF__ 1 #define __FLT_RADIX__ 2 #define __INT_LEAST16_TYPE__ short int #define __LDBL_EPSILON__ 1.08420217248550443401e-19L #define __UINTMAX_C(c) c ## UL #define __GLIBCXX_BITSIZE_INT_N_0 128 #define __k8 1 #define __SIG_ATOMIC_MAX__ 0x7fffffff #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __SIZEOF_PTRDIFF_T__ 8 #define __x86_64__ 1 #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF #define __INT_FAST16_MAX__ 0x7fffffffffffffffL #define __UINT_FAST32_MAX__ 0xffffffffffffffffUL #define __UINT_LEAST64_TYPE__ long unsigned int #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MAX_10_EXP__ 38 #define __LONG_MAX__ 0x7fffffffffffffffL #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL #define __FLT_HAS_INFINITY__ 1 #define __UINT_FAST16_TYPE__ long unsigned int #define __DEC64_MAX__ 9.999999999999999E384DD #define __CHAR16_TYPE__ short unsigned int #define __PRAGMA_REDEFINE_EXTNAME 1 #define __INT_LEAST16_MAX__ 0x7fff #define __DEC64_MANT_DIG__ 16 #define __UINT_LEAST32_MAX__ 0xffffffffU #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __INT_LEAST64_TYPE__ long int #define __INT16_TYPE__ short int #define __INT_LEAST8_TYPE__ signed char #define __DEC32_MAX_EXP__ 97 #define __INT_FAST8_MAX__ 0x7f #define __INTPTR_MAX__ 0x7fffffffffffffffL #define linux 1 #define __SSE2__ 1 #define __EXCEPTIONS 1 #define __LDBL_MANT_DIG__ 64 #define __DBL_HAS_QUIET_NAN__ 1 #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) #define __code_model_small__ 1 #define __k8__ 1 #define __INTPTR_TYPE__ long int #define __UINT16_TYPE__ short unsigned int #define __WCHAR_TYPE__ int #define __SIZEOF_FLOAT__ 4 #define __UINTPTR_MAX__ 0xffffffffffffffffUL #define __DEC64_MIN_EXP__ (-382) #define __INT_FAST64_MAX__ 0x7fffffffffffffffL #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __FLT_DIG__ 6 #define __UINT_FAST64_TYPE__ long unsigned int #define __INT_MAX__ 0x7fffffff #define __amd64__ 1 #define __INT64_TYPE__ long int #define __FLT_MAX_EXP__ 128 #define __ORDER_BIG_ENDIAN__ 4321 #define __DBL_MANT_DIG__ 53 #define __SIZEOF_FLOAT128__ 16 #define __INT_LEAST64_MAX__ 0x7fffffffffffffffL #define __DEC64_MIN__ 1E-383DD #define __WINT_TYPE__ unsigned int #define __UINT_LEAST32_TYPE__ unsigned int #define __SIZEOF_SHORT__ 2 #define __SSE__ 1 #define __LDBL_MIN_EXP__ (-16381) #define __INT_LEAST8_MAX__ 0x7f #define __SIZEOF_INT128__ 16 #define __LDBL_MAX_10_EXP__ 4932 #define __ATOMIC_RELAXED 0 #define __DBL_EPSILON__ double(2.22044604925031308085e-16L) #define _LP64 1 #define __UINT8_C(c) c #define __INT_LEAST32_TYPE__ int #define __SIZEOF_WCHAR_T__ 4 #define __UINT64_TYPE__ long unsigned int #define __INT_FAST8_TYPE__ signed char #define __DBL_DECIMAL_DIG__ 17 #define __FXSR__ 1 #define __DEC_EVAL_METHOD__ 2 #define __cpp_runtime_arrays 198712 #define __UINT32_C(c) c ## U #define __INTMAX_MAX__ 0x7fffffffffffffffL #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F #define __INT8_MAX__ 0x7f #define __UINT_FAST32_TYPE__ long unsigned int #define __CHAR32_TYPE__ unsigned int #define __FLT_MAX__ 3.40282346638528859812e+38F #define __INT32_TYPE__ int #define __SIZEOF_DOUBLE__ 8 #define __cpp_exceptions 199711 #define __INTMAX_TYPE__ long int #define __DEC128_MAX_EXP__ 6145 #define __ATOMIC_CONSUME 1 #define __GNUC_MINOR__ 4 #define __GLIBCXX_TYPE_INT_N_0 __int128 #define __UINTMAX_MAX__ 0xffffffffffffffffUL #define __DEC32_MANT_DIG__ 7 #define __DBL_MAX_10_EXP__ 308 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L #define __INT16_C(c) c #define __STDC__ 1 #define __PTRDIFF_TYPE__ long int #define __ATOMIC_SEQ_CST 5 #define __UINT32_TYPE__ unsigned int #define __UINTPTR_TYPE__ long unsigned int #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD #define __DEC128_MANT_DIG__ 34 #define __LDBL_MIN_10_EXP__ (-4931) #define __SSE_MATH__ 1 #define __SIZEOF_LONG_LONG__ 8 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __LDBL_DIG__ 18 #define __FLT_DECIMAL_DIG__ 9 #define __UINT_FAST16_MAX__ 0xffffffffffffffffUL #define __GNUC_GNU_INLINE__ 1 #define __FLT_MIN_10_EXP__ (-37) #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __UINT_FAST8_TYPE__ unsigned char #define _GNU_SOURCE 1 #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_RELEASE 3 #endif #endif /* GS_PCLP_CO_G_H */ ament_lint-0.12.0/ament_pclint/ament_pclint/config/gcc/co-g++.lnt000066400000000000000000000036441420377356500245740ustar00rootroot00000000000000/* Compiler configuration for gcc 5.4.0. Using the options: Generated on 2017-12-30 01:09:20 with pclp_config version 1.0.0. */ // Base Options // Extensions +fdi //Starts its #include search in the directory of the including file +fgi //Enable GNU inline semantics +fld //Enable support for gcc label designators +ppw(include_next) //Enable support for #include_next +ppw(ident) //Enable support for #ident +ppw(warning) //Enable support for #warning +ppw(import) //Enable support for #import +ppw(sccs) //Enable support for #sccs +ppw(unassert) //Enable support for #unassert +cpp(.cc) //Make .cc a C++ file extension in addition to the default of .cpp and .cxx +rw(__typeof__) +rw(_Decimal32) +rw(_Decimal64) +rw(_Decimal128) +rw(__alignof) +rw(__attribute) +rw(__builtin_choose_expr) +rw(__builtin_offsetof) +rw(__builtin_types_compatible_p) +rw(__builtin_va_arg) +rw(__extension__) +rw(__imag) +rw(__label__) +rw(__real) +rw(__thread) +rw(__PRETTY_FUNCTION__) +rw(typeof) -rw_asgn(__inline,inline) -rw_asgn(__inline__,inline) -rw_asgn(__signed__,signed) -rw_asgn(__signed,signed) -rw_asgn(__volatile__,volatile) -rw_asgn(__volatile,volatile) -rw_asgn(__alignof__,__alignof) -rw_asgn(__const,const) -rw_asgn(asm,_up_to_brackets) -rw_asgn(__asm,_up_to_brackets) -rw_asgn(__asm__,_up_to_brackets) // Suppressions -emacro(530, va_start) -emacro(530, va_end) -emacro(413, offsetof) // Transformed compiler options // Size Options -si4 -sl8 -sll8 -ss2 -sw4 -sp8 -sf4 -sd8 -sld16 +fzl ++fzl // Include Options --i"/usr/include/c++/5" --i"/usr/include/x86_64-linux-gnu/c++/5" --i"/usr/include/c++/5/backward" --i"/usr/lib/gcc/x86_64-linux-gnu/5/include" --i"/usr/local/include" --i"/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed" --i"/usr/include/x86_64-linux-gnu" --i"/usr/include" +libh(co-g++.h) -header(co-g++.h) //////////////////////////////////////////////////////////////////////////////// ../c++.lnt ../env-xml.lnt ament_lint-0.12.0/ament_pclint/ament_pclint/config/gcc/co-gcc.h000066400000000000000000000415271420377356500244100ustar00rootroot00000000000000#ifndef GS_PCLP_CO_GCC_H #define GS_PCLP_CO_GCC_H #ifndef __cplusplus #define __SSP_STRONG__ 3 #define __DBL_MIN_EXP__ (-1021) #define __UINT_LEAST16_MAX__ 0xffff #define __ATOMIC_ACQUIRE 2 #define __FLT_MIN__ 1.17549435082228750797e-38F #define __GCC_IEC_559_COMPLEX 2 #define __UINT_LEAST8_TYPE__ unsigned char #define __SIZEOF_FLOAT80__ 16 #define __INTMAX_C(c) c ## L #define __CHAR_BIT__ 8 #define __UINT8_MAX__ 0xff #define __WINT_MAX__ 0xffffffffU #define __ORDER_LITTLE_ENDIAN__ 1234 #define __SIZE_MAX__ 0xffffffffffffffffUL #define __WCHAR_MAX__ 0x7fffffff //lint -e621 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 //lint -e621 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 //lint -e621 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L) //lint -e621 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __GCC_IEC_559 2 #define __FLT_EVAL_METHOD__ 0 #define __unix__ 1 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __x86_64 1 #define __UINT_FAST64_MAX__ 0xffffffffffffffffUL #define __SIG_ATOMIC_TYPE__ int #define __DBL_MIN_10_EXP__ (-307) #define __FINITE_MATH_ONLY__ 0 #define __GNUC_PATCHLEVEL__ 0 #define __UINT_FAST8_MAX__ 0xff #define __DEC64_MAX_EXP__ 385 #define __INT8_C(c) c #define __UINT_LEAST64_MAX__ 0xffffffffffffffffUL #define __SHRT_MAX__ 0x7fff #define __LDBL_MAX__ 1.18973149535723176502e+4932L #define __UINT_LEAST8_MAX__ 0xff #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __UINTMAX_TYPE__ long unsigned int #define __linux 1 #define __DEC32_EPSILON__ 1E-6DF #define __unix 1 #define __UINT32_MAX__ 0xffffffffU #define __LDBL_MAX_EXP__ 16384 #define __WINT_MIN__ 0U #define __linux__ 1 #define __SCHAR_MAX__ 0x7f #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1) #define __INT64_C(c) c ## L #define __DBL_DIG__ 15 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __SIZEOF_INT__ 4 #define __SIZEOF_POINTER__ 8 #define __USER_LABEL_PREFIX__ #define __STDC_HOSTED__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __FLT_EPSILON__ 1.19209289550781250000e-7F #define __LDBL_MIN__ 3.36210314311209350626e-4932L #define __STDC_UTF_16__ 1 #define __DEC32_MAX__ 9.999999E96DF #define __INT32_MAX__ 0x7fffffff #define __SIZEOF_LONG__ 8 #define __STDC_IEC_559__ 1 #define __STDC_ISO_10646__ 201505L #define __UINT16_C(c) c #define __DECIMAL_DIG__ 21 #define __gnu_linux__ 1 #define __LDBL_HAS_QUIET_NAN__ 1 #define __GNUC__ 5 #define __MMX__ 1 #define __FLT_HAS_DENORM__ 1 #define __SIZEOF_LONG_DOUBLE__ 16 #define __BIGGEST_ALIGNMENT__ 16 #define __DBL_MAX__ ((double)1.79769313486231570815e+308L) #define __INT_FAST32_MAX__ 0x7fffffffffffffffL #define __DBL_HAS_INFINITY__ 1 #define __DEC32_MIN_EXP__ (-94) #define __INT_FAST16_TYPE__ long int #define __LDBL_HAS_DENORM__ 1 #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL #define __INT_LEAST32_MAX__ 0x7fffffff #define __DEC32_MIN__ 1E-95DF #define __DBL_MAX_EXP__ 1024 #define __DEC128_EPSILON__ 1E-33DL #define __SSE2_MATH__ 1 #define __ATOMIC_HLE_RELEASE 131072 #define __PTRDIFF_MAX__ 0x7fffffffffffffffL #define __amd64 1 #define __STDC_NO_THREADS__ 1 #define __ATOMIC_HLE_ACQUIRE 65536 #define __LONG_LONG_MAX__ 0x7fffffffffffffffLL #define __SIZEOF_SIZE_T__ 8 #define __SIZEOF_WINT_T__ 4 #define __GCC_HAVE_DWARF2_CFI_ASM 1 #define __GXX_ABI_VERSION 1009 #define __FLT_MIN_EXP__ (-125) #define __INT_FAST64_TYPE__ long int #define __DBL_MIN__ ((double)2.22507385850720138309e-308L) #define __LP64__ 1 #define __DECIMAL_BID_FORMAT__ 1 #define __DEC128_MIN__ 1E-6143DL #define __REGISTER_PREFIX__ #define __UINT16_MAX__ 0xffff #define __DBL_HAS_DENORM__ 1 #define __UINT8_TYPE__ unsigned char #define __NO_INLINE__ 1 #define __FLT_MANT_DIG__ 24 #define __VERSION__ "5.4.0 20160609" #define __UINT64_C(c) c ## UL #define _STDC_PREDEF_H 1 #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __STDC_IEC_559_COMPLEX__ 1 #define __INT32_C(c) c #define __DEC64_EPSILON__ 1E-15DD #define __ORDER_PDP_ENDIAN__ 3412 #define __DEC128_MIN_EXP__ (-6142) #define __INT_FAST32_TYPE__ long int #define __UINT_LEAST16_TYPE__ short unsigned int #define unix 1 #define __INT16_MAX__ 0x7fff #define __SIZE_TYPE__ long unsigned int #define __UINT64_MAX__ 0xffffffffffffffffUL #define __INT8_TYPE__ signed char #define __ELF__ 1 #define __FLT_RADIX__ 2 #define __INT_LEAST16_TYPE__ short int #define __LDBL_EPSILON__ 1.08420217248550443401e-19L #define __UINTMAX_C(c) c ## UL #define __SSE_MATH__ 1 #define __k8 1 #define __SIG_ATOMIC_MAX__ 0x7fffffff #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __SIZEOF_PTRDIFF_T__ 8 #define __x86_64__ 1 #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF #define __INT_FAST16_MAX__ 0x7fffffffffffffffL #define __UINT_FAST32_MAX__ 0xffffffffffffffffUL #define __UINT_LEAST64_TYPE__ long unsigned int #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MAX_10_EXP__ 38 #define __LONG_MAX__ 0x7fffffffffffffffL #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL #define __FLT_HAS_INFINITY__ 1 #define __UINT_FAST16_TYPE__ long unsigned int #define __DEC64_MAX__ 9.999999999999999E384DD #define __CHAR16_TYPE__ short unsigned int #define __PRAGMA_REDEFINE_EXTNAME 1 #define __INT_LEAST16_MAX__ 0x7fff #define __DEC64_MANT_DIG__ 16 #define __INT64_MAX__ 0x7fffffffffffffffL #define __UINT_LEAST32_MAX__ 0xffffffffU #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __INT_LEAST64_TYPE__ long int #define __INT16_TYPE__ short int #define __INT_LEAST8_TYPE__ signed char #define __STDC_VERSION__ 201112L #define __DEC32_MAX_EXP__ 97 #define __INT_FAST8_MAX__ 0x7f #define __INTPTR_MAX__ 0x7fffffffffffffffL #define linux 1 #define __SSE2__ 1 #define __LDBL_MANT_DIG__ 64 #define __DBL_HAS_QUIET_NAN__ 1 #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) #define __code_model_small__ 1 #define __k8__ 1 #define __INTPTR_TYPE__ long int #define __UINT16_TYPE__ short unsigned int #define __WCHAR_TYPE__ int #define __SIZEOF_FLOAT__ 4 #define __UINTPTR_MAX__ 0xffffffffffffffffUL #define __DEC64_MIN_EXP__ (-382) #define __INT_FAST64_MAX__ 0x7fffffffffffffffL #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __FLT_DIG__ 6 #define __UINT_FAST64_TYPE__ long unsigned int #define __INT_MAX__ 0x7fffffff #define __amd64__ 1 #define __INT64_TYPE__ long int #define __FLT_MAX_EXP__ 128 #define __ORDER_BIG_ENDIAN__ 4321 #define __DBL_MANT_DIG__ 53 #define __SIZEOF_FLOAT128__ 16 #define __INT_LEAST64_MAX__ 0x7fffffffffffffffL #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __DEC64_MIN__ 1E-383DD #define __WINT_TYPE__ unsigned int #define __UINT_LEAST32_TYPE__ unsigned int #define __SIZEOF_SHORT__ 2 #define __SSE__ 1 #define __LDBL_MIN_EXP__ (-16381) #define __INT_LEAST8_MAX__ 0x7f #define __SIZEOF_INT128__ 16 #define __LDBL_MAX_10_EXP__ 4932 #define __ATOMIC_RELAXED 0 #define __DBL_EPSILON__ ((double)2.22044604925031308085e-16L) #define _LP64 1 #define __UINT8_C(c) c #define __INT_LEAST32_TYPE__ int #define __SIZEOF_WCHAR_T__ 4 #define __UINT64_TYPE__ long unsigned int #define __INT_FAST8_TYPE__ signed char #define __GNUC_STDC_INLINE__ 1 #define __DBL_DECIMAL_DIG__ 17 #define __STDC_UTF_32__ 1 #define __FXSR__ 1 #define __DEC_EVAL_METHOD__ 2 #define __UINT32_C(c) c ## U #define __INTMAX_MAX__ 0x7fffffffffffffffL #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F #define __INT8_MAX__ 0x7f #define __UINT_FAST32_TYPE__ long unsigned int #define __CHAR32_TYPE__ unsigned int #define __FLT_MAX__ 3.40282346638528859812e+38F #define __INT32_TYPE__ int #define __SIZEOF_DOUBLE__ 8 #define __FLT_MIN_10_EXP__ (-37) #define __INTMAX_TYPE__ long int #define __DEC128_MAX_EXP__ 6145 #define __ATOMIC_CONSUME 1 #define __GNUC_MINOR__ 4 #define __UINTMAX_MAX__ 0xffffffffffffffffUL #define __DEC32_MANT_DIG__ 7 #define __DBL_MAX_10_EXP__ 308 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L #define __INT16_C(c) c #define __STDC__ 1 #define __PTRDIFF_TYPE__ long int #define __ATOMIC_SEQ_CST 5 #define __UINT32_TYPE__ unsigned int #define __UINTPTR_TYPE__ long unsigned int #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD #define __DEC128_MANT_DIG__ 34 #define __LDBL_MIN_10_EXP__ (-4931) #define __SIZEOF_LONG_LONG__ 8 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __LDBL_DIG__ 18 #define __FLT_DECIMAL_DIG__ 9 #define __UINT_FAST16_MAX__ 0xffffffffffffffffUL #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __UINT_FAST8_TYPE__ unsigned char #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_RELEASE 3 #endif #ifdef __cplusplus #define __SSP_STRONG__ 3 #define __DBL_MIN_EXP__ (-1021) #define __UINT_LEAST16_MAX__ 0xffff #define __ATOMIC_ACQUIRE 2 #define __FLT_MIN__ 1.17549435082228750797e-38F #define __GCC_IEC_559_COMPLEX 2 #define __UINT_LEAST8_TYPE__ unsigned char #define __SIZEOF_FLOAT80__ 16 #define __INTMAX_C(c) c ## L #define __CHAR_BIT__ 8 #define __UINT8_MAX__ 0xff #define __WINT_MAX__ 0xffffffffU #define __ORDER_LITTLE_ENDIAN__ 1234 #define __SIZE_MAX__ 0xffffffffffffffffUL #define __WCHAR_MAX__ 0x7fffffff #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L) #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __GCC_IEC_559 2 #define __FLT_EVAL_METHOD__ 0 #define __unix__ 1 #define __cpp_binary_literals 201304 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __x86_64 1 #define __UINT_FAST64_MAX__ 0xffffffffffffffffUL #define __SIG_ATOMIC_TYPE__ int #define __DBL_MIN_10_EXP__ (-307) #define __FINITE_MATH_ONLY__ 0 #define __GNUC_PATCHLEVEL__ 0 #define __UINT_FAST8_MAX__ 0xff #define __DEC64_MAX_EXP__ 385 #define __INT8_C(c) c #define __UINT_LEAST64_MAX__ 0xffffffffffffffffUL #define __SHRT_MAX__ 0x7fff #define __LDBL_MAX__ 1.18973149535723176502e+4932L #define __UINT_LEAST8_MAX__ 0xff #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __UINTMAX_TYPE__ long unsigned int #define __linux 1 #define __DEC32_EPSILON__ 1E-6DF #define __unix 1 #define __UINT32_MAX__ 0xffffffffU #define __LDBL_MAX_EXP__ 16384 #define __WINT_MIN__ 0U #define __linux__ 1 #define __SCHAR_MAX__ 0x7f #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1) #define __INT64_C(c) c ## L #define __DBL_DIG__ 15 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __SIZEOF_INT__ 4 #define __SIZEOF_POINTER__ 8 #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __USER_LABEL_PREFIX__ #define __STDC_HOSTED__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __FLT_EPSILON__ 1.19209289550781250000e-7F #define __GXX_WEAK__ 1 #define __LDBL_MIN__ 3.36210314311209350626e-4932L #define __DEC32_MAX__ 9.999999E96DF #define __INT32_MAX__ 0x7fffffff #define __SIZEOF_LONG__ 8 #define __STDC_IEC_559__ 1 #define __STDC_ISO_10646__ 201505L #define __UINT16_C(c) c #define __DECIMAL_DIG__ 21 #define __gnu_linux__ 1 #define __LDBL_HAS_QUIET_NAN__ 1 #define __GNUC__ 5 #define __GXX_RTTI 1 #define __MMX__ 1 #define __FLT_HAS_DENORM__ 1 #define __SIZEOF_LONG_DOUBLE__ 16 #define __BIGGEST_ALIGNMENT__ 16 #define __DBL_MAX__ double(1.79769313486231570815e+308L) #define __INT_FAST32_MAX__ 0x7fffffffffffffffL #define __DBL_HAS_INFINITY__ 1 #define __INT64_MAX__ 0x7fffffffffffffffL #define __DEC32_MIN_EXP__ (-94) #define __INT_FAST16_TYPE__ long int #define __LDBL_HAS_DENORM__ 1 #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL #define __INT_LEAST32_MAX__ 0x7fffffff #define __DEC32_MIN__ 1E-95DF #define __DEPRECATED 1 #define __DBL_MAX_EXP__ 1024 #define __DEC128_EPSILON__ 1E-33DL #define __SSE2_MATH__ 1 #define __ATOMIC_HLE_RELEASE 131072 #define __PTRDIFF_MAX__ 0x7fffffffffffffffL #define __amd64 1 #define __STDC_NO_THREADS__ 1 #define __ATOMIC_HLE_ACQUIRE 65536 #define __GNUG__ 5 #define __LONG_LONG_MAX__ 0x7fffffffffffffffLL #define __SIZEOF_SIZE_T__ 8 #define __SIZEOF_WINT_T__ 4 #define __GCC_HAVE_DWARF2_CFI_ASM 1 #define __GXX_ABI_VERSION 1009 #define __FLT_MIN_EXP__ (-125) #define __INT_FAST64_TYPE__ long int #define __DBL_MIN__ double(2.22507385850720138309e-308L) #define __LP64__ 1 #define __DECIMAL_BID_FORMAT__ 1 #define __DEC128_MIN__ 1E-6143DL #define __REGISTER_PREFIX__ #define __UINT16_MAX__ 0xffff #define __DBL_HAS_DENORM__ 1 #define __UINT8_TYPE__ unsigned char #define __NO_INLINE__ 1 #define __FLT_MANT_DIG__ 24 #define __VERSION__ "5.4.0 20160609" #define __UINT64_C(c) c ## UL #define _STDC_PREDEF_H 1 #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __STDC_IEC_559_COMPLEX__ 1 #define __INT32_C(c) c #define __DEC64_EPSILON__ 1E-15DD #define __ORDER_PDP_ENDIAN__ 3412 #define __DEC128_MIN_EXP__ (-6142) #define __INT_FAST32_TYPE__ long int #define __UINT_LEAST16_TYPE__ short unsigned int #define unix 1 #define __INT16_MAX__ 0x7fff #define __cpp_rtti 199711 #define __SIZE_TYPE__ long unsigned int #define __UINT64_MAX__ 0xffffffffffffffffUL #define __INT8_TYPE__ signed char #define __ELF__ 1 #define __FLT_RADIX__ 2 #define __INT_LEAST16_TYPE__ short int #define __LDBL_EPSILON__ 1.08420217248550443401e-19L #define __UINTMAX_C(c) c ## UL #define __GLIBCXX_BITSIZE_INT_N_0 128 #define __k8 1 #define __SIG_ATOMIC_MAX__ 0x7fffffff #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __SIZEOF_PTRDIFF_T__ 8 #define __x86_64__ 1 #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF #define __INT_FAST16_MAX__ 0x7fffffffffffffffL #define __UINT_FAST32_MAX__ 0xffffffffffffffffUL #define __UINT_LEAST64_TYPE__ long unsigned int #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MAX_10_EXP__ 38 #define __LONG_MAX__ 0x7fffffffffffffffL #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL #define __FLT_HAS_INFINITY__ 1 #define __UINT_FAST16_TYPE__ long unsigned int #define __DEC64_MAX__ 9.999999999999999E384DD #define __CHAR16_TYPE__ short unsigned int #define __PRAGMA_REDEFINE_EXTNAME 1 #define __INT_LEAST16_MAX__ 0x7fff #define __DEC64_MANT_DIG__ 16 #define __UINT_LEAST32_MAX__ 0xffffffffU #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __INT_LEAST64_TYPE__ long int #define __INT16_TYPE__ short int #define __INT_LEAST8_TYPE__ signed char #define __DEC32_MAX_EXP__ 97 #define __INT_FAST8_MAX__ 0x7f #define __INTPTR_MAX__ 0x7fffffffffffffffL #define linux 1 #define __SSE2__ 1 #define __EXCEPTIONS 1 #define __LDBL_MANT_DIG__ 64 #define __DBL_HAS_QUIET_NAN__ 1 #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) #define __code_model_small__ 1 #define __k8__ 1 #define __INTPTR_TYPE__ long int #define __UINT16_TYPE__ short unsigned int #define __WCHAR_TYPE__ int #define __SIZEOF_FLOAT__ 4 #define __UINTPTR_MAX__ 0xffffffffffffffffUL #define __DEC64_MIN_EXP__ (-382) #define __INT_FAST64_MAX__ 0x7fffffffffffffffL #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __FLT_DIG__ 6 #define __UINT_FAST64_TYPE__ long unsigned int #define __INT_MAX__ 0x7fffffff #define __amd64__ 1 #define __INT64_TYPE__ long int #define __FLT_MAX_EXP__ 128 #define __ORDER_BIG_ENDIAN__ 4321 #define __DBL_MANT_DIG__ 53 #define __SIZEOF_FLOAT128__ 16 #define __INT_LEAST64_MAX__ 0x7fffffffffffffffL #define __DEC64_MIN__ 1E-383DD #define __WINT_TYPE__ unsigned int #define __UINT_LEAST32_TYPE__ unsigned int #define __SIZEOF_SHORT__ 2 #define __SSE__ 1 #define __LDBL_MIN_EXP__ (-16381) #define __INT_LEAST8_MAX__ 0x7f #define __SIZEOF_INT128__ 16 #define __LDBL_MAX_10_EXP__ 4932 #define __ATOMIC_RELAXED 0 #define __DBL_EPSILON__ double(2.22044604925031308085e-16L) #define _LP64 1 #define __UINT8_C(c) c #define __INT_LEAST32_TYPE__ int #define __SIZEOF_WCHAR_T__ 4 #define __UINT64_TYPE__ long unsigned int #define __INT_FAST8_TYPE__ signed char #define __DBL_DECIMAL_DIG__ 17 #define __FXSR__ 1 #define __DEC_EVAL_METHOD__ 2 #define __cpp_runtime_arrays 198712 #define __UINT32_C(c) c ## U #define __INTMAX_MAX__ 0x7fffffffffffffffL #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F #define __INT8_MAX__ 0x7f #define __UINT_FAST32_TYPE__ long unsigned int #define __CHAR32_TYPE__ unsigned int #define __FLT_MAX__ 3.40282346638528859812e+38F #define __INT32_TYPE__ int #define __SIZEOF_DOUBLE__ 8 #define __cpp_exceptions 199711 #define __INTMAX_TYPE__ long int #define __DEC128_MAX_EXP__ 6145 #define __ATOMIC_CONSUME 1 #define __GNUC_MINOR__ 4 #define __GLIBCXX_TYPE_INT_N_0 __int128 #define __UINTMAX_MAX__ 0xffffffffffffffffUL #define __DEC32_MANT_DIG__ 7 #define __DBL_MAX_10_EXP__ 308 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L #define __INT16_C(c) c #define __STDC__ 1 #define __PTRDIFF_TYPE__ long int #define __ATOMIC_SEQ_CST 5 #define __UINT32_TYPE__ unsigned int #define __UINTPTR_TYPE__ long unsigned int #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD #define __DEC128_MANT_DIG__ 34 #define __LDBL_MIN_10_EXP__ (-4931) #define __SSE_MATH__ 1 #define __SIZEOF_LONG_LONG__ 8 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __LDBL_DIG__ 18 #define __FLT_DECIMAL_DIG__ 9 #define __UINT_FAST16_MAX__ 0xffffffffffffffffUL #define __GNUC_GNU_INLINE__ 1 #define __FLT_MIN_10_EXP__ (-37) #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __UINT_FAST8_TYPE__ unsigned char #define _GNU_SOURCE 1 #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_RELEASE 3 #endif #endif /* GS_PCLP_CO_GCC_H */ ament_lint-0.12.0/ament_pclint/ament_pclint/config/gcc/co-gcc.lnt000066400000000000000000000036441420377356500247540ustar00rootroot00000000000000/* Compiler configuration for gcc 5.4.0. Using the options: Generated on 2017-12-29 13:29:09 with pclp_config version 1.0.0. */ // Base Options // Extensions +fdi //Starts its #include search in the directory of the including file +fgi //Enable GNU inline semantics +fld //Enable support for gcc label designators +ppw(include_next) //Enable support for #include_next +ppw(ident) //Enable support for #ident +ppw(warning) //Enable support for #warning +ppw(import) //Enable support for #import +ppw(sccs) //Enable support for #sccs +ppw(unassert) //Enable support for #unassert +cpp(.cc) //Make .cc a C++ file extension in addition to the default of .cpp and .cxx +rw(__typeof__) +rw(_Decimal32) +rw(_Decimal64) +rw(_Decimal128) +rw(__alignof) +rw(__attribute) +rw(__builtin_choose_expr) +rw(__builtin_offsetof) +rw(__builtin_types_compatible_p) +rw(__builtin_va_arg) +rw(__extension__) +rw(__imag) +rw(__label__) +rw(__real) +rw(__thread) +rw(__PRETTY_FUNCTION__) +rw(typeof) -rw_asgn(__inline,inline) -rw_asgn(__inline__,inline) -rw_asgn(__signed__,signed) -rw_asgn(__signed,signed) -rw_asgn(__volatile__,volatile) -rw_asgn(__volatile,volatile) -rw_asgn(__alignof__,__alignof) -rw_asgn(__const,const) -rw_asgn(asm,_up_to_brackets) -rw_asgn(__asm,_up_to_brackets) -rw_asgn(__asm__,_up_to_brackets) // Suppressions -emacro(530, va_start) -emacro(530, va_end) -emacro(413, offsetof) // Transformed compiler options // Size Options -si4 -sl8 -sll8 -ss2 -sw4 -sp8 -sf4 -sd8 -sld16 +fzl ++fzl // Include Options --i"/usr/include/c++/5" --i"/usr/include/x86_64-linux-gnu/c++/5" --i"/usr/include/c++/5/backward" --i"/usr/lib/gcc/x86_64-linux-gnu/5/include" --i"/usr/local/include" --i"/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed" --i"/usr/include/x86_64-linux-gnu" --i"/usr/include" +libh(co-gcc.h) -header(co-gcc.h) //////////////////////////////////////////////////////////////////////////////// ../c99.lnt ../env-xml.lnt ament_lint-0.12.0/ament_pclint/ament_pclint/config/gcc/co-osx-g++.h000066400000000000000000000527501420377356500250370ustar00rootroot00000000000000#ifndef GS_PCLP_CO_OSX_G_H #define GS_PCLP_CO_OSX_G_H #ifndef __cplusplus #define OBJC_NEW_PROPERTIES 1 #define _LP64 1 #define __APPLE_CC__ 6000 #define __APPLE__ 1 #define __ATOMIC_ACQUIRE 2 #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_CONSUME 1 #define __ATOMIC_RELAXED 0 #define __ATOMIC_RELEASE 3 #define __ATOMIC_SEQ_CST 5 #define __BIGGEST_ALIGNMENT__ 16 #define __BLOCKS__ 1 #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __CHAR16_TYPE__ unsigned short #define __CHAR32_TYPE__ unsigned int #define __CHAR_BIT__ 8 #define __CONSTANT_CFSTRINGS__ 1 #define __DBL_DECIMAL_DIG__ 17 #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 #define __DBL_DIG__ 15 #define __DBL_EPSILON__ 2.2204460492503131e-16 #define __DBL_HAS_DENORM__ 1 #define __DBL_HAS_INFINITY__ 1 #define __DBL_HAS_QUIET_NAN__ 1 #define __DBL_MANT_DIG__ 53 #define __DBL_MAX_10_EXP__ 308 #define __DBL_MAX_EXP__ 1024 #define __DBL_MAX__ 1.7976931348623157e+308 #define __DBL_MIN_10_EXP__ (-307) #define __DBL_MIN_EXP__ (-1021) #define __DBL_MIN__ 2.2250738585072014e-308 #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ #define __DYNAMIC__ 1 #define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 101300 #define __FINITE_MATH_ONLY__ 0 #define __FLT_DECIMAL_DIG__ 9 #define __FLT_DENORM_MIN__ 1.40129846e-45F #define __FLT_DIG__ 6 #define __FLT_EPSILON__ 1.19209290e-7F #define __FLT_EVAL_METHOD__ 0 #define __FLT_HAS_DENORM__ 1 #define __FLT_HAS_INFINITY__ 1 #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MANT_DIG__ 24 #define __FLT_MAX_10_EXP__ 38 #define __FLT_MAX_EXP__ 128 #define __FLT_MAX__ 3.40282347e+38F #define __FLT_MIN_10_EXP__ (-37) #define __FLT_MIN_EXP__ (-125) #define __FLT_MIN__ 1.17549435e-38F #define __FLT_RADIX__ 2 #define __FXSR__ 1 #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GNUC_MINOR__ 2 #define __GNUC_PATCHLEVEL__ 1 #define __GNUC_STDC_INLINE__ 1 #define __GNUC__ 4 #define __GXX_ABI_VERSION 1002 #define __INT16_C_SUFFIX__ #define __INT16_FMTd__ "hd" #define __INT16_FMTi__ "hi" #define __INT16_MAX__ 32767 #define __INT16_TYPE__ short #define __INT32_C_SUFFIX__ #define __INT32_FMTd__ "d" #define __INT32_FMTi__ "i" #define __INT32_MAX__ 2147483647 #define __INT32_TYPE__ int #define __INT64_C_SUFFIX__ LL #define __INT64_FMTd__ "lld" #define __INT64_FMTi__ "lli" #define __INT64_MAX__ 9223372036854775807LL #define __INT64_TYPE__ long long int #define __INT8_C_SUFFIX__ #define __INT8_FMTd__ "hhd" #define __INT8_FMTi__ "hhi" #define __INT8_MAX__ 127 #define __INT8_TYPE__ signed char #define __INTMAX_C_SUFFIX__ L #define __INTMAX_FMTd__ "ld" #define __INTMAX_FMTi__ "li" #define __INTMAX_MAX__ 9223372036854775807L #define __INTMAX_TYPE__ long int #define __INTMAX_WIDTH__ 64 #define __INTPTR_FMTd__ "ld" #define __INTPTR_FMTi__ "li" #define __INTPTR_MAX__ 9223372036854775807L #define __INTPTR_TYPE__ long int #define __INTPTR_WIDTH__ 64 #define __INT_FAST16_FMTd__ "hd" #define __INT_FAST16_FMTi__ "hi" #define __INT_FAST16_MAX__ 32767 #define __INT_FAST16_TYPE__ short #define __INT_FAST32_FMTd__ "d" #define __INT_FAST32_FMTi__ "i" #define __INT_FAST32_MAX__ 2147483647 #define __INT_FAST32_TYPE__ int #define __INT_FAST64_FMTd__ "ld" #define __INT_FAST64_FMTi__ "li" #define __INT_FAST64_MAX__ 9223372036854775807L #define __INT_FAST64_TYPE__ long int #define __INT_FAST8_FMTd__ "hhd" #define __INT_FAST8_FMTi__ "hhi" #define __INT_FAST8_MAX__ 127 #define __INT_FAST8_TYPE__ signed char #define __INT_LEAST16_FMTd__ "hd" #define __INT_LEAST16_FMTi__ "hi" #define __INT_LEAST16_MAX__ 32767 #define __INT_LEAST16_TYPE__ short #define __INT_LEAST32_FMTd__ "d" #define __INT_LEAST32_FMTi__ "i" #define __INT_LEAST32_MAX__ 2147483647 #define __INT_LEAST32_TYPE__ int #define __INT_LEAST64_FMTd__ "ld" #define __INT_LEAST64_FMTi__ "li" #define __INT_LEAST64_MAX__ 9223372036854775807L #define __INT_LEAST64_TYPE__ long int #define __INT_LEAST8_FMTd__ "hhd" #define __INT_LEAST8_FMTi__ "hhi" #define __INT_LEAST8_MAX__ 127 #define __INT_LEAST8_TYPE__ signed char #define __INT_MAX__ 2147483647 #define __LDBL_DECIMAL_DIG__ 21 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L #define __LDBL_DIG__ 18 #define __LDBL_EPSILON__ 1.08420217248550443401e-19L #define __LDBL_HAS_DENORM__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __LDBL_HAS_QUIET_NAN__ 1 #define __LDBL_MANT_DIG__ 64 #define __LDBL_MAX_10_EXP__ 4932 #define __LDBL_MAX_EXP__ 16384 #define __LDBL_MAX__ 1.18973149535723176502e+4932L #define __LDBL_MIN_10_EXP__ (-4931) #define __LDBL_MIN_EXP__ (-16381) #define __LDBL_MIN__ 3.36210314311209350626e-4932L #define __LITTLE_ENDIAN__ 1 #define __LONG_LONG_MAX__ 9223372036854775807LL #define __LONG_MAX__ 9223372036854775807L #define __LP64__ 1 #define __MACH__ 1 #define __MMX__ 1 #define __NO_INLINE__ 1 #define __NO_MATH_INLINES 1 #define __OBJC_BOOL_IS_BOOL 0 #define __ORDER_BIG_ENDIAN__ 4321 #define __ORDER_LITTLE_ENDIAN__ 1234 #define __ORDER_PDP_ENDIAN__ 3412 #define __PIC__ 2 #define __POINTER_WIDTH__ 64 #define __PRAGMA_REDEFINE_EXTNAME 1 #define __PTRDIFF_FMTd__ "ld" #define __PTRDIFF_FMTi__ "li" #define __PTRDIFF_MAX__ 9223372036854775807L #define __PTRDIFF_TYPE__ long int #define __PTRDIFF_WIDTH__ 64 #define __REGISTER_PREFIX__ #define __SCHAR_MAX__ 127 #define __SHRT_MAX__ 32767 #define __SIG_ATOMIC_MAX__ 2147483647 #define __SIG_ATOMIC_WIDTH__ 32 #define __SIZEOF_DOUBLE__ 8 #define __SIZEOF_FLOAT__ 4 #define __SIZEOF_INT128__ 16 #define __SIZEOF_INT__ 4 #define __SIZEOF_LONG_DOUBLE__ 16 #define __SIZEOF_LONG_LONG__ 8 #define __SIZEOF_LONG__ 8 #define __SIZEOF_POINTER__ 8 #define __SIZEOF_PTRDIFF_T__ 8 #define __SIZEOF_SHORT__ 2 #define __SIZEOF_SIZE_T__ 8 #define __SIZEOF_WCHAR_T__ 4 #define __SIZEOF_WINT_T__ 4 #define __SIZE_FMTX__ "lX" #define __SIZE_FMTo__ "lo" #define __SIZE_FMTu__ "lu" #define __SIZE_FMTx__ "lx" #define __SIZE_MAX__ 18446744073709551615UL #define __SIZE_TYPE__ long unsigned int #define __SIZE_WIDTH__ 64 #define __SSE2_MATH__ 1 #define __SSE2__ 1 #define __SSE3__ 1 #define __SSE4_1__ 1 #define __SSE_MATH__ 1 #define __SSE__ 1 #define __SSP__ 1 #define __SSSE3__ 1 #define __STDC_HOSTED__ 1 #define __STDC_NO_THREADS__ 1 #define __STDC_UTF_16__ 1 #define __STDC_UTF_32__ 1 #define __STDC_VERSION__ 201112L #define __STDC__ 1 #define __UINT16_C_SUFFIX__ #define __UINT16_FMTX__ "hX" #define __UINT16_FMTo__ "ho" #define __UINT16_FMTu__ "hu" #define __UINT16_FMTx__ "hx" #define __UINT16_MAX__ 65535 #define __UINT16_TYPE__ unsigned short #define __UINT32_C_SUFFIX__ U #define __UINT32_FMTX__ "X" #define __UINT32_FMTo__ "o" #define __UINT32_FMTu__ "u" #define __UINT32_FMTx__ "x" #define __UINT32_MAX__ 4294967295U #define __UINT32_TYPE__ unsigned int #define __UINT64_C_SUFFIX__ ULL #define __UINT64_FMTX__ "llX" #define __UINT64_FMTo__ "llo" #define __UINT64_FMTu__ "llu" #define __UINT64_FMTx__ "llx" #define __UINT64_MAX__ 18446744073709551615ULL #define __UINT64_TYPE__ long long unsigned int #define __UINT8_C_SUFFIX__ #define __UINT8_FMTX__ "hhX" #define __UINT8_FMTo__ "hho" #define __UINT8_FMTu__ "hhu" #define __UINT8_FMTx__ "hhx" #define __UINT8_MAX__ 255 #define __UINT8_TYPE__ unsigned char #define __UINTMAX_C_SUFFIX__ UL #define __UINTMAX_FMTX__ "lX" #define __UINTMAX_FMTo__ "lo" #define __UINTMAX_FMTu__ "lu" #define __UINTMAX_FMTx__ "lx" #define __UINTMAX_MAX__ 18446744073709551615UL #define __UINTMAX_TYPE__ long unsigned int #define __UINTMAX_WIDTH__ 64 #define __UINTPTR_FMTX__ "lX" #define __UINTPTR_FMTo__ "lo" #define __UINTPTR_FMTu__ "lu" #define __UINTPTR_FMTx__ "lx" #define __UINTPTR_MAX__ 18446744073709551615UL #define __UINTPTR_TYPE__ long unsigned int #define __UINTPTR_WIDTH__ 64 #define __UINT_FAST16_FMTX__ "hX" #define __UINT_FAST16_FMTo__ "ho" #define __UINT_FAST16_FMTu__ "hu" #define __UINT_FAST16_FMTx__ "hx" #define __UINT_FAST16_MAX__ 65535 #define __UINT_FAST16_TYPE__ unsigned short #define __UINT_FAST32_FMTX__ "X" #define __UINT_FAST32_FMTo__ "o" #define __UINT_FAST32_FMTu__ "u" #define __UINT_FAST32_FMTx__ "x" #define __UINT_FAST32_MAX__ 4294967295U #define __UINT_FAST32_TYPE__ unsigned int #define __UINT_FAST64_FMTX__ "lX" #define __UINT_FAST64_FMTo__ "lo" #define __UINT_FAST64_FMTu__ "lu" #define __UINT_FAST64_FMTx__ "lx" #define __UINT_FAST64_MAX__ 18446744073709551615UL #define __UINT_FAST64_TYPE__ long unsigned int #define __UINT_FAST8_FMTX__ "hhX" #define __UINT_FAST8_FMTo__ "hho" #define __UINT_FAST8_FMTu__ "hhu" #define __UINT_FAST8_FMTx__ "hhx" #define __UINT_FAST8_MAX__ 255 #define __UINT_FAST8_TYPE__ unsigned char #define __UINT_LEAST16_FMTX__ "hX" #define __UINT_LEAST16_FMTo__ "ho" #define __UINT_LEAST16_FMTu__ "hu" #define __UINT_LEAST16_FMTx__ "hx" #define __UINT_LEAST16_MAX__ 65535 #define __UINT_LEAST16_TYPE__ unsigned short #define __UINT_LEAST32_FMTX__ "X" #define __UINT_LEAST32_FMTo__ "o" #define __UINT_LEAST32_FMTu__ "u" #define __UINT_LEAST32_FMTx__ "x" #define __UINT_LEAST32_MAX__ 4294967295U #define __UINT_LEAST32_TYPE__ unsigned int #define __UINT_LEAST64_FMTX__ "lX" #define __UINT_LEAST64_FMTo__ "lo" #define __UINT_LEAST64_FMTu__ "lu" #define __UINT_LEAST64_FMTx__ "lx" #define __UINT_LEAST64_MAX__ 18446744073709551615UL #define __UINT_LEAST64_TYPE__ long unsigned int #define __UINT_LEAST8_FMTX__ "hhX" #define __UINT_LEAST8_FMTo__ "hho" #define __UINT_LEAST8_FMTu__ "hhu" #define __UINT_LEAST8_FMTx__ "hhx" #define __UINT_LEAST8_MAX__ 255 #define __UINT_LEAST8_TYPE__ unsigned char #define __USER_LABEL_PREFIX__ _ #define __VERSION__ "4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)" #define __WCHAR_MAX__ 2147483647 #define __WCHAR_TYPE__ int #define __WCHAR_WIDTH__ 32 #define __WINT_TYPE__ int #define __WINT_WIDTH__ 32 #define __amd64 1 #define __amd64__ 1 #define __apple_build_version__ 9000039 #define __block __attribute__((__blocks__(byref))) #define __clang__ 1 #define __clang_major__ 9 #define __clang_minor__ 0 #define __clang_patchlevel__ 0 #define __clang_version__ "9.0.0 (clang-900.0.39.2)" #define __core2 1 #define __core2__ 1 #define __llvm__ 1 #define __nonnull _Nonnull #define __null_unspecified _Null_unspecified #define __nullable _Nullable #define __pic__ 2 #define __strong #define __tune_core2__ 1 #define __unsafe_unretained #define __weak __attribute__((objc_gc(weak))) #define __x86_64 1 #define __x86_64__ 1 #endif #ifdef __cplusplus #define OBJC_NEW_PROPERTIES 1 #define _LP64 1 #define __APPLE_CC__ 6000 #define __APPLE__ 1 #define __ATOMIC_ACQUIRE 2 #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_CONSUME 1 #define __ATOMIC_RELAXED 0 #define __ATOMIC_RELEASE 3 #define __ATOMIC_SEQ_CST 5 #define __BIGGEST_ALIGNMENT__ 16 #define __BLOCKS__ 1 #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __CHAR16_TYPE__ unsigned short #define __CHAR32_TYPE__ unsigned int #define __CHAR_BIT__ 8 #define __CONSTANT_CFSTRINGS__ 1 #define __DBL_DECIMAL_DIG__ 17 #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 #define __DBL_DIG__ 15 #define __DBL_EPSILON__ 2.2204460492503131e-16 #define __DBL_HAS_DENORM__ 1 #define __DBL_HAS_INFINITY__ 1 #define __DBL_HAS_QUIET_NAN__ 1 #define __DBL_MANT_DIG__ 53 #define __DBL_MAX_10_EXP__ 308 #define __DBL_MAX_EXP__ 1024 #define __DBL_MAX__ 1.7976931348623157e+308 #define __DBL_MIN_10_EXP__ (-307) #define __DBL_MIN_EXP__ (-1021) #define __DBL_MIN__ 2.2250738585072014e-308 #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ #define __DEPRECATED 1 #define __DYNAMIC__ 1 #define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 101300 #define __EXCEPTIONS 1 #define __FINITE_MATH_ONLY__ 0 #define __FLT_DECIMAL_DIG__ 9 #define __FLT_DENORM_MIN__ 1.40129846e-45F #define __FLT_DIG__ 6 #define __FLT_EPSILON__ 1.19209290e-7F #define __FLT_EVAL_METHOD__ 0 #define __FLT_HAS_DENORM__ 1 #define __FLT_HAS_INFINITY__ 1 #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MANT_DIG__ 24 #define __FLT_MAX_10_EXP__ 38 #define __FLT_MAX_EXP__ 128 #define __FLT_MAX__ 3.40282347e+38F #define __FLT_MIN_10_EXP__ (-37) #define __FLT_MIN_EXP__ (-125) #define __FLT_MIN__ 1.17549435e-38F #define __FLT_RADIX__ 2 #define __FXSR__ 1 #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GLIBCXX_BITSIZE_INT_N_0 128 #define __GLIBCXX_TYPE_INT_N_0 __int128 #define __GNUC_GNU_INLINE__ 1 #define __GNUC_MINOR__ 2 #define __GNUC_PATCHLEVEL__ 1 #define __GNUC__ 4 #define __GNUG__ 4 #define __GXX_ABI_VERSION 1002 #define __GXX_RTTI 1 #define __GXX_WEAK__ 1 #define __INT16_C_SUFFIX__ #define __INT16_FMTd__ "hd" #define __INT16_FMTi__ "hi" #define __INT16_MAX__ 32767 #define __INT16_TYPE__ short #define __INT32_C_SUFFIX__ #define __INT32_FMTd__ "d" #define __INT32_FMTi__ "i" #define __INT32_MAX__ 2147483647 #define __INT32_TYPE__ int #define __INT64_C_SUFFIX__ LL #define __INT64_FMTd__ "lld" #define __INT64_FMTi__ "lli" #define __INT64_MAX__ 9223372036854775807LL #define __INT64_TYPE__ long long int #define __INT8_C_SUFFIX__ #define __INT8_FMTd__ "hhd" #define __INT8_FMTi__ "hhi" #define __INT8_MAX__ 127 #define __INT8_TYPE__ signed char #define __INTMAX_C_SUFFIX__ L #define __INTMAX_FMTd__ "ld" #define __INTMAX_FMTi__ "li" #define __INTMAX_MAX__ 9223372036854775807L #define __INTMAX_TYPE__ long int #define __INTMAX_WIDTH__ 64 #define __INTPTR_FMTd__ "ld" #define __INTPTR_FMTi__ "li" #define __INTPTR_MAX__ 9223372036854775807L #define __INTPTR_TYPE__ long int #define __INTPTR_WIDTH__ 64 #define __INT_FAST16_FMTd__ "hd" #define __INT_FAST16_FMTi__ "hi" #define __INT_FAST16_MAX__ 32767 #define __INT_FAST16_TYPE__ short #define __INT_FAST32_FMTd__ "d" #define __INT_FAST32_FMTi__ "i" #define __INT_FAST32_MAX__ 2147483647 #define __INT_FAST32_TYPE__ int #define __INT_FAST64_FMTd__ "ld" #define __INT_FAST64_FMTi__ "li" #define __INT_FAST64_MAX__ 9223372036854775807L #define __INT_FAST64_TYPE__ long int #define __INT_FAST8_FMTd__ "hhd" #define __INT_FAST8_FMTi__ "hhi" #define __INT_FAST8_MAX__ 127 #define __INT_FAST8_TYPE__ signed char #define __INT_LEAST16_FMTd__ "hd" #define __INT_LEAST16_FMTi__ "hi" #define __INT_LEAST16_MAX__ 32767 #define __INT_LEAST16_TYPE__ short #define __INT_LEAST32_FMTd__ "d" #define __INT_LEAST32_FMTi__ "i" #define __INT_LEAST32_MAX__ 2147483647 #define __INT_LEAST32_TYPE__ int #define __INT_LEAST64_FMTd__ "ld" #define __INT_LEAST64_FMTi__ "li" #define __INT_LEAST64_MAX__ 9223372036854775807L #define __INT_LEAST64_TYPE__ long int #define __INT_LEAST8_FMTd__ "hhd" #define __INT_LEAST8_FMTi__ "hhi" #define __INT_LEAST8_MAX__ 127 #define __INT_LEAST8_TYPE__ signed char #define __INT_MAX__ 2147483647 #define __LDBL_DECIMAL_DIG__ 21 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L #define __LDBL_DIG__ 18 #define __LDBL_EPSILON__ 1.08420217248550443401e-19L #define __LDBL_HAS_DENORM__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __LDBL_HAS_QUIET_NAN__ 1 #define __LDBL_MANT_DIG__ 64 #define __LDBL_MAX_10_EXP__ 4932 #define __LDBL_MAX_EXP__ 16384 #define __LDBL_MAX__ 1.18973149535723176502e+4932L #define __LDBL_MIN_10_EXP__ (-4931) #define __LDBL_MIN_EXP__ (-16381) #define __LDBL_MIN__ 3.36210314311209350626e-4932L #define __LITTLE_ENDIAN__ 1 #define __LONG_LONG_MAX__ 9223372036854775807LL #define __LONG_MAX__ 9223372036854775807L #define __LP64__ 1 #define __MACH__ 1 #define __MMX__ 1 #define __NO_INLINE__ 1 #define __NO_MATH_INLINES 1 #define __OBJC_BOOL_IS_BOOL 0 #define __ORDER_BIG_ENDIAN__ 4321 #define __ORDER_LITTLE_ENDIAN__ 1234 #define __ORDER_PDP_ENDIAN__ 3412 #define __PIC__ 2 #define __POINTER_WIDTH__ 64 #define __PRAGMA_REDEFINE_EXTNAME 1 #define __PTRDIFF_FMTd__ "ld" #define __PTRDIFF_FMTi__ "li" #define __PTRDIFF_MAX__ 9223372036854775807L #define __PTRDIFF_TYPE__ long int #define __PTRDIFF_WIDTH__ 64 #define __REGISTER_PREFIX__ #define __SCHAR_MAX__ 127 #define __SHRT_MAX__ 32767 #define __SIG_ATOMIC_MAX__ 2147483647 #define __SIG_ATOMIC_WIDTH__ 32 #define __SIZEOF_DOUBLE__ 8 #define __SIZEOF_FLOAT__ 4 #define __SIZEOF_INT128__ 16 #define __SIZEOF_INT__ 4 #define __SIZEOF_LONG_DOUBLE__ 16 #define __SIZEOF_LONG_LONG__ 8 #define __SIZEOF_LONG__ 8 #define __SIZEOF_POINTER__ 8 #define __SIZEOF_PTRDIFF_T__ 8 #define __SIZEOF_SHORT__ 2 #define __SIZEOF_SIZE_T__ 8 #define __SIZEOF_WCHAR_T__ 4 #define __SIZEOF_WINT_T__ 4 #define __SIZE_FMTX__ "lX" #define __SIZE_FMTo__ "lo" #define __SIZE_FMTu__ "lu" #define __SIZE_FMTx__ "lx" #define __SIZE_MAX__ 18446744073709551615UL #define __SIZE_TYPE__ long unsigned int #define __SIZE_WIDTH__ 64 #define __SSE2_MATH__ 1 #define __SSE2__ 1 #define __SSE3__ 1 #define __SSE4_1__ 1 #define __SSE_MATH__ 1 #define __SSE__ 1 #define __SSP__ 1 #define __SSSE3__ 1 #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL #define __STDC_HOSTED__ 1 #define __STDC_NO_THREADS__ 1 #define __STDC_UTF_16__ 1 #define __STDC_UTF_32__ 1 #define __STDC__ 1 #define __UINT16_C_SUFFIX__ #define __UINT16_FMTX__ "hX" #define __UINT16_FMTo__ "ho" #define __UINT16_FMTu__ "hu" #define __UINT16_FMTx__ "hx" #define __UINT16_MAX__ 65535 #define __UINT16_TYPE__ unsigned short #define __UINT32_C_SUFFIX__ U #define __UINT32_FMTX__ "X" #define __UINT32_FMTo__ "o" #define __UINT32_FMTu__ "u" #define __UINT32_FMTx__ "x" #define __UINT32_MAX__ 4294967295U #define __UINT32_TYPE__ unsigned int #define __UINT64_C_SUFFIX__ ULL #define __UINT64_FMTX__ "llX" #define __UINT64_FMTo__ "llo" #define __UINT64_FMTu__ "llu" #define __UINT64_FMTx__ "llx" #define __UINT64_MAX__ 18446744073709551615ULL #define __UINT64_TYPE__ long long unsigned int #define __UINT8_C_SUFFIX__ #define __UINT8_FMTX__ "hhX" #define __UINT8_FMTo__ "hho" #define __UINT8_FMTu__ "hhu" #define __UINT8_FMTx__ "hhx" #define __UINT8_MAX__ 255 #define __UINT8_TYPE__ unsigned char #define __UINTMAX_C_SUFFIX__ UL #define __UINTMAX_FMTX__ "lX" #define __UINTMAX_FMTo__ "lo" #define __UINTMAX_FMTu__ "lu" #define __UINTMAX_FMTx__ "lx" #define __UINTMAX_MAX__ 18446744073709551615UL #define __UINTMAX_TYPE__ long unsigned int #define __UINTMAX_WIDTH__ 64 #define __UINTPTR_FMTX__ "lX" #define __UINTPTR_FMTo__ "lo" #define __UINTPTR_FMTu__ "lu" #define __UINTPTR_FMTx__ "lx" #define __UINTPTR_MAX__ 18446744073709551615UL #define __UINTPTR_TYPE__ long unsigned int #define __UINTPTR_WIDTH__ 64 #define __UINT_FAST16_FMTX__ "hX" #define __UINT_FAST16_FMTo__ "ho" #define __UINT_FAST16_FMTu__ "hu" #define __UINT_FAST16_FMTx__ "hx" #define __UINT_FAST16_MAX__ 65535 #define __UINT_FAST16_TYPE__ unsigned short #define __UINT_FAST32_FMTX__ "X" #define __UINT_FAST32_FMTo__ "o" #define __UINT_FAST32_FMTu__ "u" #define __UINT_FAST32_FMTx__ "x" #define __UINT_FAST32_MAX__ 4294967295U #define __UINT_FAST32_TYPE__ unsigned int #define __UINT_FAST64_FMTX__ "lX" #define __UINT_FAST64_FMTo__ "lo" #define __UINT_FAST64_FMTu__ "lu" #define __UINT_FAST64_FMTx__ "lx" #define __UINT_FAST64_MAX__ 18446744073709551615UL #define __UINT_FAST64_TYPE__ long unsigned int #define __UINT_FAST8_FMTX__ "hhX" #define __UINT_FAST8_FMTo__ "hho" #define __UINT_FAST8_FMTu__ "hhu" #define __UINT_FAST8_FMTx__ "hhx" #define __UINT_FAST8_MAX__ 255 #define __UINT_FAST8_TYPE__ unsigned char #define __UINT_LEAST16_FMTX__ "hX" #define __UINT_LEAST16_FMTo__ "ho" #define __UINT_LEAST16_FMTu__ "hu" #define __UINT_LEAST16_FMTx__ "hx" #define __UINT_LEAST16_MAX__ 65535 #define __UINT_LEAST16_TYPE__ unsigned short #define __UINT_LEAST32_FMTX__ "X" #define __UINT_LEAST32_FMTo__ "o" #define __UINT_LEAST32_FMTu__ "u" #define __UINT_LEAST32_FMTx__ "x" #define __UINT_LEAST32_MAX__ 4294967295U #define __UINT_LEAST32_TYPE__ unsigned int #define __UINT_LEAST64_FMTX__ "lX" #define __UINT_LEAST64_FMTo__ "lo" #define __UINT_LEAST64_FMTu__ "lu" #define __UINT_LEAST64_FMTx__ "lx" #define __UINT_LEAST64_MAX__ 18446744073709551615UL #define __UINT_LEAST64_TYPE__ long unsigned int #define __UINT_LEAST8_FMTX__ "hhX" #define __UINT_LEAST8_FMTo__ "hho" #define __UINT_LEAST8_FMTu__ "hhu" #define __UINT_LEAST8_FMTx__ "hhx" #define __UINT_LEAST8_MAX__ 255 #define __UINT_LEAST8_TYPE__ unsigned char #define __USER_LABEL_PREFIX__ _ #define __VERSION__ "4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)" #define __WCHAR_MAX__ 2147483647 #define __WCHAR_TYPE__ int #define __WCHAR_WIDTH__ 32 #define __WINT_TYPE__ int #define __WINT_WIDTH__ 32 #define __amd64 1 #define __amd64__ 1 #define __apple_build_version__ 9000039 #define __block __attribute__((__blocks__(byref))) #define __clang__ 1 #define __clang_major__ 9 #define __clang_minor__ 0 #define __clang_patchlevel__ 0 #define __clang_version__ "9.0.0 (clang-900.0.39.2)" #define __core2 1 #define __core2__ 1 #define __cpp_exceptions 199711 #define __cpp_rtti 199711 #define __llvm__ 1 #define __nonnull _Nonnull #define __null_unspecified _Null_unspecified #define __nullable _Nullable #define __pic__ 2 #define __private_extern__ extern #define __strong #define __tune_core2__ 1 #define __unsafe_unretained #define __weak __attribute__((objc_gc(weak))) #define __x86_64 1 #define __x86_64__ 1 #endif #endif /* GS_PCLP_CO_OSX_G_H */ ament_lint-0.12.0/ament_pclint/ament_pclint/config/gcc/co-osx-g++.lnt000066400000000000000000000043721420377356500254020ustar00rootroot00000000000000/* Compiler configuration for gcc 9.0.0. Using the options: Generated on 2017-12-30 00:15:11 with pclp_config version 1.0.0. */ // Base Options // Extensions +fdi //Starts its #include search in the directory of the including file +fgi //Enable GNU inline semantics +fld //Enable support for gcc label designators +ppw(include_next) //Enable support for #include_next +ppw(ident) //Enable support for #ident +ppw(warning) //Enable support for #warning +ppw(import) //Enable support for #import +ppw(sccs) //Enable support for #sccs +ppw(unassert) //Enable support for #unassert +cpp(.cc) //Make .cc a C++ file extension in addition to the default of .cpp and .cxx +rw(__typeof__) +rw(_Decimal32) +rw(_Decimal64) +rw(_Decimal128) +rw(__alignof) +rw(__attribute) +rw(__builtin_choose_expr) +rw(__builtin_offsetof) +rw(__builtin_types_compatible_p) +rw(__builtin_va_arg) +rw(__extension__) +rw(__imag) +rw(__label__) +rw(__real) +rw(__thread) +rw(__PRETTY_FUNCTION__) +rw(typeof) -rw_asgn(__inline,inline) -rw_asgn(__inline__,inline) -rw_asgn(__signed__,signed) -rw_asgn(__signed,signed) -rw_asgn(__volatile__,volatile) -rw_asgn(__volatile,volatile) -rw_asgn(__alignof__,__alignof) -rw_asgn(__const,const) -rw_asgn(asm,_up_to_brackets) -rw_asgn(__asm,_up_to_brackets) -rw_asgn(__asm__,_up_to_brackets) // Suppressions -emacro(530, va_start) -emacro(530, va_end) -emacro(413, offsetof) // Transformed compiler options // Size Options -si4 -sl8 -sll8 -ss2 -sw4 -sp8 -sf4 -sd8 -sld16 +fzl ++fzl // Include Options --i"/usr/local/include" --i"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1" --i"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include" --i"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include" --i"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include" --i"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks (framework directory)" +libh(co-osx-g++.h) -header(co-osx-g++.h) //////////////////////////////////////////////////////////////////////////////// ../c++.lnt ../env-xml.lnt ament_lint-0.12.0/ament_pclint/ament_pclint/config/gcc/co-osx-gcc.h000066400000000000000000000527561420377356500252250ustar00rootroot00000000000000#ifndef GS_PCLP_CO_OSX_GCC_H #define GS_PCLP_CO_OSX_GCC_H #ifndef __cplusplus #define OBJC_NEW_PROPERTIES 1 #define _LP64 1 #define __APPLE_CC__ 6000 #define __APPLE__ 1 #define __ATOMIC_ACQUIRE 2 #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_CONSUME 1 #define __ATOMIC_RELAXED 0 #define __ATOMIC_RELEASE 3 #define __ATOMIC_SEQ_CST 5 #define __BIGGEST_ALIGNMENT__ 16 #define __BLOCKS__ 1 #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __CHAR16_TYPE__ unsigned short #define __CHAR32_TYPE__ unsigned int #define __CHAR_BIT__ 8 #define __CONSTANT_CFSTRINGS__ 1 #define __DBL_DECIMAL_DIG__ 17 #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 #define __DBL_DIG__ 15 #define __DBL_EPSILON__ 2.2204460492503131e-16 #define __DBL_HAS_DENORM__ 1 #define __DBL_HAS_INFINITY__ 1 #define __DBL_HAS_QUIET_NAN__ 1 #define __DBL_MANT_DIG__ 53 #define __DBL_MAX_10_EXP__ 308 #define __DBL_MAX_EXP__ 1024 #define __DBL_MAX__ 1.7976931348623157e+308 #define __DBL_MIN_10_EXP__ (-307) #define __DBL_MIN_EXP__ (-1021) #define __DBL_MIN__ 2.2250738585072014e-308 #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ #define __DYNAMIC__ 1 #define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 101300 #define __FINITE_MATH_ONLY__ 0 #define __FLT_DECIMAL_DIG__ 9 #define __FLT_DENORM_MIN__ 1.40129846e-45F #define __FLT_DIG__ 6 #define __FLT_EPSILON__ 1.19209290e-7F #define __FLT_EVAL_METHOD__ 0 #define __FLT_HAS_DENORM__ 1 #define __FLT_HAS_INFINITY__ 1 #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MANT_DIG__ 24 #define __FLT_MAX_10_EXP__ 38 #define __FLT_MAX_EXP__ 128 #define __FLT_MAX__ 3.40282347e+38F #define __FLT_MIN_10_EXP__ (-37) #define __FLT_MIN_EXP__ (-125) #define __FLT_MIN__ 1.17549435e-38F #define __FLT_RADIX__ 2 #define __FXSR__ 1 #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GNUC_MINOR__ 2 #define __GNUC_PATCHLEVEL__ 1 #define __GNUC_STDC_INLINE__ 1 #define __GNUC__ 4 #define __GXX_ABI_VERSION 1002 #define __INT16_C_SUFFIX__ #define __INT16_FMTd__ "hd" #define __INT16_FMTi__ "hi" #define __INT16_MAX__ 32767 #define __INT16_TYPE__ short #define __INT32_C_SUFFIX__ #define __INT32_FMTd__ "d" #define __INT32_FMTi__ "i" #define __INT32_MAX__ 2147483647 #define __INT32_TYPE__ int #define __INT64_C_SUFFIX__ LL #define __INT64_FMTd__ "lld" #define __INT64_FMTi__ "lli" #define __INT64_MAX__ 9223372036854775807LL #define __INT64_TYPE__ long long int #define __INT8_C_SUFFIX__ #define __INT8_FMTd__ "hhd" #define __INT8_FMTi__ "hhi" #define __INT8_MAX__ 127 #define __INT8_TYPE__ signed char #define __INTMAX_C_SUFFIX__ L #define __INTMAX_FMTd__ "ld" #define __INTMAX_FMTi__ "li" #define __INTMAX_MAX__ 9223372036854775807L #define __INTMAX_TYPE__ long int #define __INTMAX_WIDTH__ 64 #define __INTPTR_FMTd__ "ld" #define __INTPTR_FMTi__ "li" #define __INTPTR_MAX__ 9223372036854775807L #define __INTPTR_TYPE__ long int #define __INTPTR_WIDTH__ 64 #define __INT_FAST16_FMTd__ "hd" #define __INT_FAST16_FMTi__ "hi" #define __INT_FAST16_MAX__ 32767 #define __INT_FAST16_TYPE__ short #define __INT_FAST32_FMTd__ "d" #define __INT_FAST32_FMTi__ "i" #define __INT_FAST32_MAX__ 2147483647 #define __INT_FAST32_TYPE__ int #define __INT_FAST64_FMTd__ "ld" #define __INT_FAST64_FMTi__ "li" #define __INT_FAST64_MAX__ 9223372036854775807L #define __INT_FAST64_TYPE__ long int #define __INT_FAST8_FMTd__ "hhd" #define __INT_FAST8_FMTi__ "hhi" #define __INT_FAST8_MAX__ 127 #define __INT_FAST8_TYPE__ signed char #define __INT_LEAST16_FMTd__ "hd" #define __INT_LEAST16_FMTi__ "hi" #define __INT_LEAST16_MAX__ 32767 #define __INT_LEAST16_TYPE__ short #define __INT_LEAST32_FMTd__ "d" #define __INT_LEAST32_FMTi__ "i" #define __INT_LEAST32_MAX__ 2147483647 #define __INT_LEAST32_TYPE__ int #define __INT_LEAST64_FMTd__ "ld" #define __INT_LEAST64_FMTi__ "li" #define __INT_LEAST64_MAX__ 9223372036854775807L #define __INT_LEAST64_TYPE__ long int #define __INT_LEAST8_FMTd__ "hhd" #define __INT_LEAST8_FMTi__ "hhi" #define __INT_LEAST8_MAX__ 127 #define __INT_LEAST8_TYPE__ signed char #define __INT_MAX__ 2147483647 #define __LDBL_DECIMAL_DIG__ 21 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L #define __LDBL_DIG__ 18 #define __LDBL_EPSILON__ 1.08420217248550443401e-19L #define __LDBL_HAS_DENORM__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __LDBL_HAS_QUIET_NAN__ 1 #define __LDBL_MANT_DIG__ 64 #define __LDBL_MAX_10_EXP__ 4932 #define __LDBL_MAX_EXP__ 16384 #define __LDBL_MAX__ 1.18973149535723176502e+4932L #define __LDBL_MIN_10_EXP__ (-4931) #define __LDBL_MIN_EXP__ (-16381) #define __LDBL_MIN__ 3.36210314311209350626e-4932L #define __LITTLE_ENDIAN__ 1 #define __LONG_LONG_MAX__ 9223372036854775807LL #define __LONG_MAX__ 9223372036854775807L #define __LP64__ 1 #define __MACH__ 1 #define __MMX__ 1 #define __NO_INLINE__ 1 #define __NO_MATH_INLINES 1 #define __OBJC_BOOL_IS_BOOL 0 #define __ORDER_BIG_ENDIAN__ 4321 #define __ORDER_LITTLE_ENDIAN__ 1234 #define __ORDER_PDP_ENDIAN__ 3412 #define __PIC__ 2 #define __POINTER_WIDTH__ 64 #define __PRAGMA_REDEFINE_EXTNAME 1 #define __PTRDIFF_FMTd__ "ld" #define __PTRDIFF_FMTi__ "li" #define __PTRDIFF_MAX__ 9223372036854775807L #define __PTRDIFF_TYPE__ long int #define __PTRDIFF_WIDTH__ 64 #define __REGISTER_PREFIX__ #define __SCHAR_MAX__ 127 #define __SHRT_MAX__ 32767 #define __SIG_ATOMIC_MAX__ 2147483647 #define __SIG_ATOMIC_WIDTH__ 32 #define __SIZEOF_DOUBLE__ 8 #define __SIZEOF_FLOAT__ 4 #define __SIZEOF_INT128__ 16 #define __SIZEOF_INT__ 4 #define __SIZEOF_LONG_DOUBLE__ 16 #define __SIZEOF_LONG_LONG__ 8 #define __SIZEOF_LONG__ 8 #define __SIZEOF_POINTER__ 8 #define __SIZEOF_PTRDIFF_T__ 8 #define __SIZEOF_SHORT__ 2 #define __SIZEOF_SIZE_T__ 8 #define __SIZEOF_WCHAR_T__ 4 #define __SIZEOF_WINT_T__ 4 #define __SIZE_FMTX__ "lX" #define __SIZE_FMTo__ "lo" #define __SIZE_FMTu__ "lu" #define __SIZE_FMTx__ "lx" #define __SIZE_MAX__ 18446744073709551615UL #define __SIZE_TYPE__ long unsigned int #define __SIZE_WIDTH__ 64 #define __SSE2_MATH__ 1 #define __SSE2__ 1 #define __SSE3__ 1 #define __SSE4_1__ 1 #define __SSE_MATH__ 1 #define __SSE__ 1 #define __SSP__ 1 #define __SSSE3__ 1 #define __STDC_HOSTED__ 1 #define __STDC_NO_THREADS__ 1 #define __STDC_UTF_16__ 1 #define __STDC_UTF_32__ 1 #define __STDC_VERSION__ 201112L #define __STDC__ 1 #define __UINT16_C_SUFFIX__ #define __UINT16_FMTX__ "hX" #define __UINT16_FMTo__ "ho" #define __UINT16_FMTu__ "hu" #define __UINT16_FMTx__ "hx" #define __UINT16_MAX__ 65535 #define __UINT16_TYPE__ unsigned short #define __UINT32_C_SUFFIX__ U #define __UINT32_FMTX__ "X" #define __UINT32_FMTo__ "o" #define __UINT32_FMTu__ "u" #define __UINT32_FMTx__ "x" #define __UINT32_MAX__ 4294967295U #define __UINT32_TYPE__ unsigned int #define __UINT64_C_SUFFIX__ ULL #define __UINT64_FMTX__ "llX" #define __UINT64_FMTo__ "llo" #define __UINT64_FMTu__ "llu" #define __UINT64_FMTx__ "llx" #define __UINT64_MAX__ 18446744073709551615ULL #define __UINT64_TYPE__ long long unsigned int #define __UINT8_C_SUFFIX__ #define __UINT8_FMTX__ "hhX" #define __UINT8_FMTo__ "hho" #define __UINT8_FMTu__ "hhu" #define __UINT8_FMTx__ "hhx" #define __UINT8_MAX__ 255 #define __UINT8_TYPE__ unsigned char #define __UINTMAX_C_SUFFIX__ UL #define __UINTMAX_FMTX__ "lX" #define __UINTMAX_FMTo__ "lo" #define __UINTMAX_FMTu__ "lu" #define __UINTMAX_FMTx__ "lx" #define __UINTMAX_MAX__ 18446744073709551615UL #define __UINTMAX_TYPE__ long unsigned int #define __UINTMAX_WIDTH__ 64 #define __UINTPTR_FMTX__ "lX" #define __UINTPTR_FMTo__ "lo" #define __UINTPTR_FMTu__ "lu" #define __UINTPTR_FMTx__ "lx" #define __UINTPTR_MAX__ 18446744073709551615UL #define __UINTPTR_TYPE__ long unsigned int #define __UINTPTR_WIDTH__ 64 #define __UINT_FAST16_FMTX__ "hX" #define __UINT_FAST16_FMTo__ "ho" #define __UINT_FAST16_FMTu__ "hu" #define __UINT_FAST16_FMTx__ "hx" #define __UINT_FAST16_MAX__ 65535 #define __UINT_FAST16_TYPE__ unsigned short #define __UINT_FAST32_FMTX__ "X" #define __UINT_FAST32_FMTo__ "o" #define __UINT_FAST32_FMTu__ "u" #define __UINT_FAST32_FMTx__ "x" #define __UINT_FAST32_MAX__ 4294967295U #define __UINT_FAST32_TYPE__ unsigned int #define __UINT_FAST64_FMTX__ "lX" #define __UINT_FAST64_FMTo__ "lo" #define __UINT_FAST64_FMTu__ "lu" #define __UINT_FAST64_FMTx__ "lx" #define __UINT_FAST64_MAX__ 18446744073709551615UL #define __UINT_FAST64_TYPE__ long unsigned int #define __UINT_FAST8_FMTX__ "hhX" #define __UINT_FAST8_FMTo__ "hho" #define __UINT_FAST8_FMTu__ "hhu" #define __UINT_FAST8_FMTx__ "hhx" #define __UINT_FAST8_MAX__ 255 #define __UINT_FAST8_TYPE__ unsigned char #define __UINT_LEAST16_FMTX__ "hX" #define __UINT_LEAST16_FMTo__ "ho" #define __UINT_LEAST16_FMTu__ "hu" #define __UINT_LEAST16_FMTx__ "hx" #define __UINT_LEAST16_MAX__ 65535 #define __UINT_LEAST16_TYPE__ unsigned short #define __UINT_LEAST32_FMTX__ "X" #define __UINT_LEAST32_FMTo__ "o" #define __UINT_LEAST32_FMTu__ "u" #define __UINT_LEAST32_FMTx__ "x" #define __UINT_LEAST32_MAX__ 4294967295U #define __UINT_LEAST32_TYPE__ unsigned int #define __UINT_LEAST64_FMTX__ "lX" #define __UINT_LEAST64_FMTo__ "lo" #define __UINT_LEAST64_FMTu__ "lu" #define __UINT_LEAST64_FMTx__ "lx" #define __UINT_LEAST64_MAX__ 18446744073709551615UL #define __UINT_LEAST64_TYPE__ long unsigned int #define __UINT_LEAST8_FMTX__ "hhX" #define __UINT_LEAST8_FMTo__ "hho" #define __UINT_LEAST8_FMTu__ "hhu" #define __UINT_LEAST8_FMTx__ "hhx" #define __UINT_LEAST8_MAX__ 255 #define __UINT_LEAST8_TYPE__ unsigned char #define __USER_LABEL_PREFIX__ _ #define __VERSION__ "4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)" #define __WCHAR_MAX__ 2147483647 #define __WCHAR_TYPE__ int #define __WCHAR_WIDTH__ 32 #define __WINT_TYPE__ int #define __WINT_WIDTH__ 32 #define __amd64 1 #define __amd64__ 1 #define __apple_build_version__ 9000039 #define __block __attribute__((__blocks__(byref))) #define __clang__ 1 #define __clang_major__ 9 #define __clang_minor__ 0 #define __clang_patchlevel__ 0 #define __clang_version__ "9.0.0 (clang-900.0.39.2)" #define __core2 1 #define __core2__ 1 #define __llvm__ 1 #define __nonnull _Nonnull #define __null_unspecified _Null_unspecified #define __nullable _Nullable #define __pic__ 2 #define __strong #define __tune_core2__ 1 #define __unsafe_unretained #define __weak __attribute__((objc_gc(weak))) #define __x86_64 1 #define __x86_64__ 1 #endif #ifdef __cplusplus #define OBJC_NEW_PROPERTIES 1 #define _LP64 1 #define __APPLE_CC__ 6000 #define __APPLE__ 1 #define __ATOMIC_ACQUIRE 2 #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_CONSUME 1 #define __ATOMIC_RELAXED 0 #define __ATOMIC_RELEASE 3 #define __ATOMIC_SEQ_CST 5 #define __BIGGEST_ALIGNMENT__ 16 #define __BLOCKS__ 1 #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __CHAR16_TYPE__ unsigned short #define __CHAR32_TYPE__ unsigned int #define __CHAR_BIT__ 8 #define __CONSTANT_CFSTRINGS__ 1 #define __DBL_DECIMAL_DIG__ 17 #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 #define __DBL_DIG__ 15 #define __DBL_EPSILON__ 2.2204460492503131e-16 #define __DBL_HAS_DENORM__ 1 #define __DBL_HAS_INFINITY__ 1 #define __DBL_HAS_QUIET_NAN__ 1 #define __DBL_MANT_DIG__ 53 #define __DBL_MAX_10_EXP__ 308 #define __DBL_MAX_EXP__ 1024 #define __DBL_MAX__ 1.7976931348623157e+308 #define __DBL_MIN_10_EXP__ (-307) #define __DBL_MIN_EXP__ (-1021) #define __DBL_MIN__ 2.2250738585072014e-308 #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ #define __DEPRECATED 1 #define __DYNAMIC__ 1 #define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 101300 #define __EXCEPTIONS 1 #define __FINITE_MATH_ONLY__ 0 #define __FLT_DECIMAL_DIG__ 9 #define __FLT_DENORM_MIN__ 1.40129846e-45F #define __FLT_DIG__ 6 #define __FLT_EPSILON__ 1.19209290e-7F #define __FLT_EVAL_METHOD__ 0 #define __FLT_HAS_DENORM__ 1 #define __FLT_HAS_INFINITY__ 1 #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MANT_DIG__ 24 #define __FLT_MAX_10_EXP__ 38 #define __FLT_MAX_EXP__ 128 #define __FLT_MAX__ 3.40282347e+38F #define __FLT_MIN_10_EXP__ (-37) #define __FLT_MIN_EXP__ (-125) #define __FLT_MIN__ 1.17549435e-38F #define __FLT_RADIX__ 2 #define __FXSR__ 1 #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GLIBCXX_BITSIZE_INT_N_0 128 #define __GLIBCXX_TYPE_INT_N_0 __int128 #define __GNUC_GNU_INLINE__ 1 #define __GNUC_MINOR__ 2 #define __GNUC_PATCHLEVEL__ 1 #define __GNUC__ 4 #define __GNUG__ 4 #define __GXX_ABI_VERSION 1002 #define __GXX_RTTI 1 #define __GXX_WEAK__ 1 #define __INT16_C_SUFFIX__ #define __INT16_FMTd__ "hd" #define __INT16_FMTi__ "hi" #define __INT16_MAX__ 32767 #define __INT16_TYPE__ short #define __INT32_C_SUFFIX__ #define __INT32_FMTd__ "d" #define __INT32_FMTi__ "i" #define __INT32_MAX__ 2147483647 #define __INT32_TYPE__ int #define __INT64_C_SUFFIX__ LL #define __INT64_FMTd__ "lld" #define __INT64_FMTi__ "lli" #define __INT64_MAX__ 9223372036854775807LL #define __INT64_TYPE__ long long int #define __INT8_C_SUFFIX__ #define __INT8_FMTd__ "hhd" #define __INT8_FMTi__ "hhi" #define __INT8_MAX__ 127 #define __INT8_TYPE__ signed char #define __INTMAX_C_SUFFIX__ L #define __INTMAX_FMTd__ "ld" #define __INTMAX_FMTi__ "li" #define __INTMAX_MAX__ 9223372036854775807L #define __INTMAX_TYPE__ long int #define __INTMAX_WIDTH__ 64 #define __INTPTR_FMTd__ "ld" #define __INTPTR_FMTi__ "li" #define __INTPTR_MAX__ 9223372036854775807L #define __INTPTR_TYPE__ long int #define __INTPTR_WIDTH__ 64 #define __INT_FAST16_FMTd__ "hd" #define __INT_FAST16_FMTi__ "hi" #define __INT_FAST16_MAX__ 32767 #define __INT_FAST16_TYPE__ short #define __INT_FAST32_FMTd__ "d" #define __INT_FAST32_FMTi__ "i" #define __INT_FAST32_MAX__ 2147483647 #define __INT_FAST32_TYPE__ int #define __INT_FAST64_FMTd__ "ld" #define __INT_FAST64_FMTi__ "li" #define __INT_FAST64_MAX__ 9223372036854775807L #define __INT_FAST64_TYPE__ long int #define __INT_FAST8_FMTd__ "hhd" #define __INT_FAST8_FMTi__ "hhi" #define __INT_FAST8_MAX__ 127 #define __INT_FAST8_TYPE__ signed char #define __INT_LEAST16_FMTd__ "hd" #define __INT_LEAST16_FMTi__ "hi" #define __INT_LEAST16_MAX__ 32767 #define __INT_LEAST16_TYPE__ short #define __INT_LEAST32_FMTd__ "d" #define __INT_LEAST32_FMTi__ "i" #define __INT_LEAST32_MAX__ 2147483647 #define __INT_LEAST32_TYPE__ int #define __INT_LEAST64_FMTd__ "ld" #define __INT_LEAST64_FMTi__ "li" #define __INT_LEAST64_MAX__ 9223372036854775807L #define __INT_LEAST64_TYPE__ long int #define __INT_LEAST8_FMTd__ "hhd" #define __INT_LEAST8_FMTi__ "hhi" #define __INT_LEAST8_MAX__ 127 #define __INT_LEAST8_TYPE__ signed char #define __INT_MAX__ 2147483647 #define __LDBL_DECIMAL_DIG__ 21 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L #define __LDBL_DIG__ 18 #define __LDBL_EPSILON__ 1.08420217248550443401e-19L #define __LDBL_HAS_DENORM__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __LDBL_HAS_QUIET_NAN__ 1 #define __LDBL_MANT_DIG__ 64 #define __LDBL_MAX_10_EXP__ 4932 #define __LDBL_MAX_EXP__ 16384 #define __LDBL_MAX__ 1.18973149535723176502e+4932L #define __LDBL_MIN_10_EXP__ (-4931) #define __LDBL_MIN_EXP__ (-16381) #define __LDBL_MIN__ 3.36210314311209350626e-4932L #define __LITTLE_ENDIAN__ 1 #define __LONG_LONG_MAX__ 9223372036854775807LL #define __LONG_MAX__ 9223372036854775807L #define __LP64__ 1 #define __MACH__ 1 #define __MMX__ 1 #define __NO_INLINE__ 1 #define __NO_MATH_INLINES 1 #define __OBJC_BOOL_IS_BOOL 0 #define __ORDER_BIG_ENDIAN__ 4321 #define __ORDER_LITTLE_ENDIAN__ 1234 #define __ORDER_PDP_ENDIAN__ 3412 #define __PIC__ 2 #define __POINTER_WIDTH__ 64 #define __PRAGMA_REDEFINE_EXTNAME 1 #define __PTRDIFF_FMTd__ "ld" #define __PTRDIFF_FMTi__ "li" #define __PTRDIFF_MAX__ 9223372036854775807L #define __PTRDIFF_TYPE__ long int #define __PTRDIFF_WIDTH__ 64 #define __REGISTER_PREFIX__ #define __SCHAR_MAX__ 127 #define __SHRT_MAX__ 32767 #define __SIG_ATOMIC_MAX__ 2147483647 #define __SIG_ATOMIC_WIDTH__ 32 #define __SIZEOF_DOUBLE__ 8 #define __SIZEOF_FLOAT__ 4 #define __SIZEOF_INT128__ 16 #define __SIZEOF_INT__ 4 #define __SIZEOF_LONG_DOUBLE__ 16 #define __SIZEOF_LONG_LONG__ 8 #define __SIZEOF_LONG__ 8 #define __SIZEOF_POINTER__ 8 #define __SIZEOF_PTRDIFF_T__ 8 #define __SIZEOF_SHORT__ 2 #define __SIZEOF_SIZE_T__ 8 #define __SIZEOF_WCHAR_T__ 4 #define __SIZEOF_WINT_T__ 4 #define __SIZE_FMTX__ "lX" #define __SIZE_FMTo__ "lo" #define __SIZE_FMTu__ "lu" #define __SIZE_FMTx__ "lx" #define __SIZE_MAX__ 18446744073709551615UL #define __SIZE_TYPE__ long unsigned int #define __SIZE_WIDTH__ 64 #define __SSE2_MATH__ 1 #define __SSE2__ 1 #define __SSE3__ 1 #define __SSE4_1__ 1 #define __SSE_MATH__ 1 #define __SSE__ 1 #define __SSP__ 1 #define __SSSE3__ 1 #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL #define __STDC_HOSTED__ 1 #define __STDC_NO_THREADS__ 1 #define __STDC_UTF_16__ 1 #define __STDC_UTF_32__ 1 #define __STDC__ 1 #define __UINT16_C_SUFFIX__ #define __UINT16_FMTX__ "hX" #define __UINT16_FMTo__ "ho" #define __UINT16_FMTu__ "hu" #define __UINT16_FMTx__ "hx" #define __UINT16_MAX__ 65535 #define __UINT16_TYPE__ unsigned short #define __UINT32_C_SUFFIX__ U #define __UINT32_FMTX__ "X" #define __UINT32_FMTo__ "o" #define __UINT32_FMTu__ "u" #define __UINT32_FMTx__ "x" #define __UINT32_MAX__ 4294967295U #define __UINT32_TYPE__ unsigned int #define __UINT64_C_SUFFIX__ ULL #define __UINT64_FMTX__ "llX" #define __UINT64_FMTo__ "llo" #define __UINT64_FMTu__ "llu" #define __UINT64_FMTx__ "llx" #define __UINT64_MAX__ 18446744073709551615ULL #define __UINT64_TYPE__ long long unsigned int #define __UINT8_C_SUFFIX__ #define __UINT8_FMTX__ "hhX" #define __UINT8_FMTo__ "hho" #define __UINT8_FMTu__ "hhu" #define __UINT8_FMTx__ "hhx" #define __UINT8_MAX__ 255 #define __UINT8_TYPE__ unsigned char #define __UINTMAX_C_SUFFIX__ UL #define __UINTMAX_FMTX__ "lX" #define __UINTMAX_FMTo__ "lo" #define __UINTMAX_FMTu__ "lu" #define __UINTMAX_FMTx__ "lx" #define __UINTMAX_MAX__ 18446744073709551615UL #define __UINTMAX_TYPE__ long unsigned int #define __UINTMAX_WIDTH__ 64 #define __UINTPTR_FMTX__ "lX" #define __UINTPTR_FMTo__ "lo" #define __UINTPTR_FMTu__ "lu" #define __UINTPTR_FMTx__ "lx" #define __UINTPTR_MAX__ 18446744073709551615UL #define __UINTPTR_TYPE__ long unsigned int #define __UINTPTR_WIDTH__ 64 #define __UINT_FAST16_FMTX__ "hX" #define __UINT_FAST16_FMTo__ "ho" #define __UINT_FAST16_FMTu__ "hu" #define __UINT_FAST16_FMTx__ "hx" #define __UINT_FAST16_MAX__ 65535 #define __UINT_FAST16_TYPE__ unsigned short #define __UINT_FAST32_FMTX__ "X" #define __UINT_FAST32_FMTo__ "o" #define __UINT_FAST32_FMTu__ "u" #define __UINT_FAST32_FMTx__ "x" #define __UINT_FAST32_MAX__ 4294967295U #define __UINT_FAST32_TYPE__ unsigned int #define __UINT_FAST64_FMTX__ "lX" #define __UINT_FAST64_FMTo__ "lo" #define __UINT_FAST64_FMTu__ "lu" #define __UINT_FAST64_FMTx__ "lx" #define __UINT_FAST64_MAX__ 18446744073709551615UL #define __UINT_FAST64_TYPE__ long unsigned int #define __UINT_FAST8_FMTX__ "hhX" #define __UINT_FAST8_FMTo__ "hho" #define __UINT_FAST8_FMTu__ "hhu" #define __UINT_FAST8_FMTx__ "hhx" #define __UINT_FAST8_MAX__ 255 #define __UINT_FAST8_TYPE__ unsigned char #define __UINT_LEAST16_FMTX__ "hX" #define __UINT_LEAST16_FMTo__ "ho" #define __UINT_LEAST16_FMTu__ "hu" #define __UINT_LEAST16_FMTx__ "hx" #define __UINT_LEAST16_MAX__ 65535 #define __UINT_LEAST16_TYPE__ unsigned short #define __UINT_LEAST32_FMTX__ "X" #define __UINT_LEAST32_FMTo__ "o" #define __UINT_LEAST32_FMTu__ "u" #define __UINT_LEAST32_FMTx__ "x" #define __UINT_LEAST32_MAX__ 4294967295U #define __UINT_LEAST32_TYPE__ unsigned int #define __UINT_LEAST64_FMTX__ "lX" #define __UINT_LEAST64_FMTo__ "lo" #define __UINT_LEAST64_FMTu__ "lu" #define __UINT_LEAST64_FMTx__ "lx" #define __UINT_LEAST64_MAX__ 18446744073709551615UL #define __UINT_LEAST64_TYPE__ long unsigned int #define __UINT_LEAST8_FMTX__ "hhX" #define __UINT_LEAST8_FMTo__ "hho" #define __UINT_LEAST8_FMTu__ "hhu" #define __UINT_LEAST8_FMTx__ "hhx" #define __UINT_LEAST8_MAX__ 255 #define __UINT_LEAST8_TYPE__ unsigned char #define __USER_LABEL_PREFIX__ _ #define __VERSION__ "4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)" #define __WCHAR_MAX__ 2147483647 #define __WCHAR_TYPE__ int #define __WCHAR_WIDTH__ 32 #define __WINT_TYPE__ int #define __WINT_WIDTH__ 32 #define __amd64 1 #define __amd64__ 1 #define __apple_build_version__ 9000039 #define __block __attribute__((__blocks__(byref))) #define __clang__ 1 #define __clang_major__ 9 #define __clang_minor__ 0 #define __clang_patchlevel__ 0 #define __clang_version__ "9.0.0 (clang-900.0.39.2)" #define __core2 1 #define __core2__ 1 #define __cpp_exceptions 199711 #define __cpp_rtti 199711 #define __llvm__ 1 #define __nonnull _Nonnull #define __null_unspecified _Null_unspecified #define __nullable _Nullable #define __pic__ 2 #define __private_extern__ extern #define __strong #define __tune_core2__ 1 #define __unsafe_unretained #define __weak __attribute__((objc_gc(weak))) #define __x86_64 1 #define __x86_64__ 1 #endif #endif /* GS_PCLP_CO_OSX_GCC_H */ ament_lint-0.12.0/ament_pclint/ament_pclint/config/gcc/co-osx-gcc.lnt000066400000000000000000000044031420377356500255550ustar00rootroot00000000000000/* Compiler configuration for gcc 9.0.0. Using the options: Generated on 2017-12-29 23:49:58 with pclp_config version 1.0.0. */ // Base Options // Extensions +fdi //Starts its #include search in the directory of the including file +fgi //Enable GNU inline semantics +fld //Enable support for gcc label designators +ppw(include_next) //Enable support for #include_next +ppw(ident) //Enable support for #ident +ppw(warning) //Enable support for #warning +ppw(import) //Enable support for #import +ppw(sccs) //Enable support for #sccs +ppw(unassert) //Enable support for #unassert +cpp(.cc) //Make .cc a C++ file extension in addition to the default of .cpp and .cxx +rw(__typeof__) +rw(_Decimal32) +rw(_Decimal64) +rw(_Decimal128) +rw(__alignof) +rw(__attribute) +rw(__builtin_choose_expr) +rw(__builtin_offsetof) +rw(__builtin_types_compatible_p) +rw(__builtin_va_arg) +rw(__extension__) +rw(__imag) +rw(__label__) +rw(__real) +rw(__thread) +rw(__PRETTY_FUNCTION__) +rw(typeof) -rw_asgn(__inline,inline) -rw_asgn(__inline__,inline) -rw_asgn(__signed__,signed) -rw_asgn(__signed,signed) -rw_asgn(__volatile__,volatile) -rw_asgn(__volatile,volatile) -rw_asgn(__alignof__,__alignof) -rw_asgn(__const,const) -rw_asgn(asm,_up_to_brackets) -rw_asgn(__asm,_up_to_brackets) -rw_asgn(__asm__,_up_to_brackets) // Suppressions -emacro(530, va_start) -emacro(530, va_end) -emacro(413, offsetof) // Transformed compiler options // Size Options -si4 -sl8 -sll8 -ss2 -sw4 -sp8 -sf4 -sd8 -sld16 +fzl ++fzl // Include Options --i"/usr/local/include" --i"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1" --i"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include" --i"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include" --i"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include" --i"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks (framework directory)" +libh(co-osx-gcc.h) -header(co-osx-gcc.h) //////////////////////////////////////////////////////////////////////////////// ../c99.lnt ../env-xml.lnt -dlint=1 ament_lint-0.12.0/ament_pclint/ament_pclint/config/msvc/000077500000000000000000000000001420377356500233075ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/ament_pclint/config/msvc/co-cl++.lnt000066400000000000000000000070411420377356500251530ustar00rootroot00000000000000/* Compiler configuration for vs2017_64 19.11.25547. Using the options: Generated on 2018-09-21 10:28:26 with pclp_config version 1.0.0. */ // Base Options // Extensions -std=c++14 // Enable C++14 support -$ // Enable $ as an identifier character +fan // Enable support for anonymous unions +fdi // Search including directory +fsi // Search include stack for headers +frc // Enable MSVC behavior with regards to handling of commas in macro expansions involving __VA_ARGS__ +fbl // Search dependent base classes for unqualified lookup in a class template +fei // Enumerations are always int +fur // Allow unions to contain reference members +frd // Allow redefinition of default parameters for member functions of a class template +fum // A user-declared move operation will only delete the corresponding copy operation +ffv // Implicit conversion from function pointers to void pointers +flp // Support the C++98 definition of null pointer constant +fnf // Fall back on operator new when operator new[] cannot be found +fes // Search enclosing scopes for friend tag declarations +ffw // A friend declaration may act as a forward declaration +fma // Microsoft Asm blocks +fdt // Enable delayed template parsing +fms // Other Microsoft extensions -fon // Disable alternative C++ tokens for logical operators +fwc // internal wchar_t +fwu // wchar_t is unsigned +ppw(using) // Enable support for the #using directive +ppw(import) // Enable support for the #import directive +rw(___identifier) +rw(__alignof) +rw(__asm) +rw(__builtin_alignof) +rw(__cdecl) +rw(__declspec) +rw(__fastcall) +rw(__finally) +rw(__forceinline) +rw(__gc) +rw(__if_exists) +rw(__if_not_exists) +rw(__inline) +rw(__int16) +rw(__int32) +rw(__int64) +rw(__int8) +rw(__interface) +rw(__is_destructible) +rw(__is_interface_class) +rw(__is_nothrow_destructible) +rw(__is_sealed) +rw(__leave) +rw(__multiple_inheritance) +rw(__nogc) +rw(__pin) +rw(__ptr64) +rw(__ptr32) +rw(__single_inheritance) +rw(__sptr) +rw(__stdcall) +rw(__super) +rw(__thiscall) +rw(__try) +rw(__try_cast) +rw(__uptr) +rw(__unaligned) +rw(__uuidof) +rw(__value) +rw(__vectorcall) +rw(__virtual_inheritance) +rw(__w64) +rw(__wchar_t) +rw(_asm) +rw(_alignof) +rw(_cdecl) +rw(_declspec) +rw(_fastcall) +rw(_inline) +rw(_int16) +rw(_int32) +rw(_int64) +rw(_int8) +rw(_stdcall) +rw(_thiscall) +rw(_uuidof) +rw(char16_t) +rw(char32_t) +fzl // long sizeof ++fzl // long long sizeof +d"_EMIT_VECTORCALL(...)=" ++doffsetof(s,m)=__builtin_offsetof(s,m) // Suppressions -emacro(505 792 1773,va_start) -esym(4242,std::_Const_cast) -estring(9022,_identifier) -estring(9051 9052,_inline,_declspec,_stdcall) -emacro(413, offsetof) -e4374 // Visual Studio allows certain calling convention differences in overridden functions // Transformed compiler options // Size Options -si4 -sl4 -sll8 -ss2 -sw2 -sp8 -sf4 -sd8 -sld8 // Include Options --i"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\ATLMFC\include" --i"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include" --i"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" --i"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" --i"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" --i"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" --i"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" +libh(co-cl.h) -header(co-cl.h) //////////////////////////////////////////////////////////////////////////////// ../c++.lnt ../env-xml.lnt ament_lint-0.12.0/ament_pclint/ament_pclint/config/msvc/co-cl.h000066400000000000000000000012321420377356500244530ustar00rootroot00000000000000#ifndef GS_PCLP_CO_CL_H #define GS_PCLP_CO_CL_H #define _INTEGRAL_MAX_BITS 64 #define _WIN32 1 #define _WIN64 1 #define _M_X64 1 #define _M_AMD64 100 #define _MSC_FULL_VER 190000000 #define _MSC_VER 1900 #define _WINSOCK_DEPRECATED_NO_WARNINGS 1 #define _MSC_EXTENSIONS 1 #define _NATIVE_WCHAR_T_DEFINED 1 #define _WCHAR_T_DEFINED 1 #define __FUNCTION__ "func" #define __FUNCDNAME__ "funcname" #define __FUNCSIG__ "funcsig" #define L__FUNCTION__ L"func" #ifndef __cplusplus void __assert(_Bool); /*lint !e793 !e955 !e970 !e1904 !e9141 */ #endif #ifdef __cplusplus void __assert(bool); /*lint !e793 !e955 !e970 !e1904 !e9141 */ #endif #endif /* GS_PCLP_CO_CL_H */ ament_lint-0.12.0/ament_pclint/ament_pclint/config/msvc/co-cl.lnt000066400000000000000000000071451420377356500250320ustar00rootroot00000000000000/* Compiler configuration for vs2017_64 19.11.25547. Using the options: Generated on 2018-09-21 10:28:27 with pclp_config version 1.0.0. */ // Base Options // Extensions -std=c++14 // Enable C++14 support -$ // Enable $ as an identifier character +fan // Enable support for anonymous unions +fdi // Search including directory +fsi // Search include stack for headers +frc // Enable MSVC behavior with regards to handling of commas in macro expansions involving __VA_ARGS__ +fbl // Search dependent base classes for unqualified lookup in a class template +fei // Enumerations are always int +fur // Allow unions to contain reference members +frd // Allow redefinition of default parameters for member functions of a class template +fum // A user-declared move operation will only delete the corresponding copy operation +ffv // Implicit conversion from function pointers to void pointers +flp // Support the C++98 definition of null pointer constant +fnf // Fall back on operator new when operator new[] cannot be found +fes // Search enclosing scopes for friend tag declarations +ffw // A friend declaration may act as a forward declaration +fma // Microsoft Asm blocks +fdt // Enable delayed template parsing +fms // Other Microsoft extensions -fon // Disable alternative C++ tokens for logical operators +fwc // internal wchar_t +fwu // wchar_t is unsigned +ppw(using) // Enable support for the #using directive +ppw(import) // Enable support for the #import directive +rw(___identifier) +rw(__alignof) +rw(__asm) +rw(__builtin_alignof) +rw(__cdecl) +rw(__declspec) +rw(__fastcall) +rw(__finally) +rw(__forceinline) +rw(__gc) +rw(__if_exists) +rw(__if_not_exists) +rw(__inline) +rw(__int16) +rw(__int32) +rw(__int64) +rw(__int8) +rw(__interface) +rw(__is_destructible) +rw(__is_interface_class) +rw(__is_nothrow_destructible) +rw(__is_sealed) +rw(__leave) +rw(__multiple_inheritance) +rw(__nogc) +rw(__pin) +rw(__ptr64) +rw(__ptr32) +rw(__single_inheritance) +rw(__sptr) +rw(__stdcall) +rw(__super) +rw(__thiscall) +rw(__try) +rw(__try_cast) +rw(__uptr) +rw(__unaligned) +rw(__uuidof) +rw(__value) +rw(__vectorcall) +rw(__virtual_inheritance) +rw(__w64) +rw(__wchar_t) +rw(_asm) +rw(_alignof) +rw(_cdecl) +rw(_declspec) +rw(_fastcall) +rw(_inline) +rw(_int16) +rw(_int32) +rw(_int64) +rw(_int8) +rw(_stdcall) +rw(_thiscall) +rw(_uuidof) +rw(char16_t) +rw(char32_t) +fzl // long sizeof ++fzl // long long sizeof +d"_EMIT_VECTORCALL(...)=" ++doffsetof(s,m)=__builtin_offsetof(s,m) // Suppressions -emacro(505 792 1773,va_start) -esym(4242,std::_Const_cast) -estring(9022,_identifier) -estring(9051 9052,_inline,_declspec,_stdcall) -emacro(413, offsetof) -e4374 // Visual Studio allows certain calling convention differences in overridden functions // Transformed compiler options // Size Options -si4 -sl4 -sll8 -ss2 -sw2 -sp8 -sf4 -sd8 -sld8 // Include Options --i"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\ATLMFC\include" --i"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include" --i"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" --i"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" --i"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" --i"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" --i"C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" +libh(co-cl.h) -header(co-cl.h) //////////////////////////////////////////////////////////////////////////////// ../c99.lnt ../env-xml.lnt -dPCLINT_PLUS=1 -emacro(*, FIONBIO) -emacro(*, INVALID_HANDLE_VALUE) ament_lint-0.12.0/ament_pclint/ament_pclint/main.py000077500000000000000000000310151420377356500223730ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014-2015 Open Source Robotics Foundation, Inc. # Copyright 2017-2018 Apex.AI, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import concurrent.futures import multiprocessing import os from shutil import which import subprocess import sys import time from xml.etree import ElementTree from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr def main(argv=sys.argv[1:]): extensions = ['c', 'cc', 'cpp', 'cxx', 'c++'] parser = argparse.ArgumentParser( description='Perform static code analysis using pclint.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='Files and/or directories to be checked. Directories are searched recursively for ' 'files ending in one of %s.' % ', '.join(["'.%s'" % e for e in extensions])) parser.add_argument( '--language', choices=['c', 'cpp'], help='Force pclint to analyze files as specified language. ' '(default: Automatically detected)') parser.add_argument( '--pclint-config-file', help='Specify a custom pclint configuration file. ' '(default: config/gcc/{co-gcc|co-g++}.lnt on Linux, ' 'config/gcc/{co-osx-gcc|co-osx-g++}.lnt on OSX, ' 'config/msvc/{co-cl|co-cl++}.lnt on Windows.)') parser.add_argument( '--include-directories', nargs='*', help='Paths to directories that are included in the files that should be analyzed.\n' 'Paths in AMENT_PREFIX_PATH will be included by default.\n' 'Use --exclude-ament-prefix-path to exclude them.') parser.add_argument( '--exclude-ament-prefix-path', action='store_true', help='Include folders in AMENT_PREFIX_PATH will be included by default, use this option' 'to exclude them.') parser.add_argument( '--compiler-definitions', nargs='*', default='', help='Compiler definitions that are necessary for PCLint.') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') parser.add_argument( '--debug', action='store_true', help='Print the full pclint command that is being called' ) args = parser.parse_args(argv) if args.xunit_file: start_time = time.time() files = get_files(args.paths, extensions) if not files: print('No files found', file=sys.stderr) return 1 exec_name = 'pclp64' # Name of Windows executable, other OSes have a suffix if sys.platform == 'linux': exec_name += '_linux' elif sys.platform == 'darwin': exec_name += '_osx' pclint_bin = find_executable(exec_name) if not pclint_bin: print("Could not find pclint executable '{}'".format(exec_name), file=sys.stderr) return 1 if args.pclint_config_file: pclint_config_dir = os.path.dirname(args.pclint_config_file) elif os.name == 'nt': pclint_config_dir = \ os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config', 'msvc') else: pclint_config_dir = \ os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config', 'gcc') # Prepare pclint command base_cmd = [pclint_bin, '-i"%s"' % pclint_config_dir, '-i"%s"' % os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config'), 'env-xml.lnt'] # Add include directories from arguments for directory in (args.include_directories or []): base_cmd.extend(['-i"%s"' % directory]) # Add include folders in AMENT_PREFIX_PATH if not args.exclude_ament_prefix_path and os.environ['AMENT_PREFIX_PATH']: if os.name == 'nt': paths = os.environ['AMENT_PREFIX_PATH'].split(';') else: paths = os.environ['AMENT_PREFIX_PATH'].split(':') for path in paths: include_folder = os.path.join(path, 'include') if os.path.exists(include_folder): base_cmd.extend(['-i"{}"'.format(include_folder)]) # Add compiler definitions from arguments for definition in (args.compiler_definitions or []): base_cmd.extend(['-d"%s"' % definition]) # try to determine the number of CPU cores jobs = 1 try: jobs = multiprocessing.cpu_count() except NotImplementedError: # the number of cores cannot be determined, don't parallelize pass result = [''] * len(files) idx = 0 threads = [] retvals = [0] * len(files) with concurrent.futures.ThreadPoolExecutor(max_workers=jobs) as executor: for f in files: retvals[idx] = 0 cmd = base_cmd[:] if args.pclint_config_file: pclint_config_file = os.path.basename(args.pclint_config_file) else: pclint_config_file = get_lnt_file(f, args.language) cmd.extend([pclint_config_file]) # Add file at the end cmd.append(f) # For debug: prints full command to be copied and pasted. if args.debug: print(str(cmd).replace("'", '').replace(',', '').replace('[', '').replace(']', '')) # We start one thread per file threads.append(executor.submit(execute_analysis, cmd, result, retvals, idx)) idx += 1 concurrent.futures.wait(threads) aggregate_xml = _format_pclint_xml_out(result) try: root = ElementTree.fromstring(aggregate_xml) except ElementTree.ParseError as e: print('Invalid XML in pclint output: %s' % str(e), file=sys.stderr) return 1 # output errors report = {} for doc in root.findall('doc'): for error in doc.findall('error'): report[error.find('file').text] = [] for error in doc.findall('error'): filename = error.find('file').text data = { 'line': int(error.find('line').text), 'id': error.find('code').text, 'severity': error.find('type').text, 'msg': error.find('desc').text, } report[filename].append(data) data = dict(data) data['filename'] = filename print('[%(filename)s:%(line)d]: (%(severity)s: %(id)s) %(msg)s' % data, file=sys.stderr) # output summary error_count = sum(len(r) for r in report.values()) if not error_count: print('No problems found') rc = 0 else: print('%d errors' % error_count, file=sys.stderr) if args.debug: for r in result: print(r) rc = 1 # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return rc def execute_analysis(cmd, result, retvals, idx): try: p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) xml = p.communicate()[0].decode('utf-8') # Read xml from stdout except subprocess.CalledProcessError as e: print("The invocation of 'pclint' failed with error code %d: %s" % (e.returncode, e), file=sys.stderr) return False result[idx] = xml retvals[idx] = p.returncode def find_executable(file_name, additional_paths=None): path = None if additional_paths: path = os.getenv('PATH', os.defpath) path += os.path.pathsep + os.path.pathsep.join(additional_paths) return which(file_name, path=path) def _format_pclint_xml_out(xml_arr): aggregate_xml = \ '\n\ \n' # noqa: E122 for xml in xml_arr: aggregate_xml += xml aggregate_xml += '' return aggregate_xml def get_lnt_file(filename, args_language): if os.name == 'nt': cc_config = 'co-cl.lnt' cpp_config = 'co-cl++.lnt' elif sys.platform == 'darwin': cc_config = 'co-osx-gcc.lnt' cpp_config = 'co-osx-g++.lnt' else: cc_config = 'co-gcc.lnt' cpp_config = 'co-g++.lnt' if (filename.endswith('.cpp') or filename.endswith('.c++') or filename.endswith('.cxx')): pclint_config_file = cpp_config else: pclint_config_file = cc_config # Allow user to force cpp files to be analyzed as c files. # and c files to be analyzed as cpp files. if args_language == 'c': pclint_config_file = cc_config elif args_language == 'cpp': pclint_config_file = cpp_config return pclint_config_file def get_files(paths, extensions): files = [] for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_'] and d not in ['test']] dirnames.sort() # select files by extension for filename in sorted(filenames): _, ext = os.path.splitext(filename) if ext in ('.%s' % e for e in extensions): files.append(os.path.join(dirpath, filename)) if os.path.isfile(path): files.append(path) return [str(os.path.normpath(f)) for f in files] def get_xunit_content(report, testname, elapsed): test_count = sum(max(len(r), 1) for r in report.values()) error_count = sum(len(r) for r in report.values()) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for filename in sorted(report.keys()): errors = report[filename] if errors: # report each pclint error as a failing testcase for error in errors: data = { 'quoted_name': quoteattr( '%s: %s (%s:%d)' % ( error['severity'], error['id'], filename, error['line'])), 'testname': testname, 'quoted_message': quoteattr(error['msg']), } xml += """ """ % data else: # if there are no pclint errors report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % r for r in sorted(report.keys())])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_pclint/doc/000077500000000000000000000000001420377356500171625ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/doc/index.rst000066400000000000000000000010321420377356500210170ustar00rootroot00000000000000ament_pclint ============== Performs a static code analysis of C / C++ source files using `PCLint `_. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_pclint [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_pclint `_. ament_lint-0.12.0/ament_pclint/package.xml000066400000000000000000000017221420377356500205340ustar00rootroot00000000000000 ament_pclint 0.12.0 The ability to perform static code analysis on C/C++ code using pclint and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Juan Pablo Samper ament_copyright ament_flake8 ament_pep257 python3-pytest ament_python ament_lint-0.12.0/ament_pclint/pytest.ini000066400000000000000000000000351420377356500204440ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_pclint/resource/000077500000000000000000000000001420377356500202445ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/resource/ament_pclint000066400000000000000000000000001420377356500226320ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/setup.py000066400000000000000000000037241420377356500201350ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_pclint' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], package_data={'': [ 'config/gcc/co-g++.h', 'config/gcc/co-g++.lnt', 'config/gcc/co-gcc.h', 'config/gcc/co-gcc.lnt', 'config/gcc/co-osx-g++.h', 'config/gcc/co-osx-g++.lnt', 'config/gcc/co-osx-gcc.h', 'config/gcc/co-osx-gcc.lnt', 'config/msvc/cl-include-path.lnt', 'config/msvc/co-cl.lnt', 'config/msvc/co-cl++.lnt', 'config/msvc/co-cl.h', 'config/au-misra3.lnt', 'config/au-misra3-amd1.lnt', 'config/au-misra-cpp.lnt', 'config/c99.lnt', 'config/c++.lnt', 'config/deprecate.lnt', 'config/env-xml.lnt' ]}, zip_safe=False, author='Juan Pablo Samper', author_email='jp.samper@apex.ai', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='', keywords=['ament'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apex AI', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Static code analysis on C/C++ code using PCLint.', long_description="""\ The ability to perform static code analysis on C/C++ code using PCLint and generate xUnit test result files.""", license='Apache License, Version 2.0', tests_require=['pytest'], test_suite='test', entry_points={ 'console_scripts': [ 'ament_pclint = ament_pclint.main:main', ], }, ) ament_lint-0.12.0/ament_pclint/test/000077500000000000000000000000001420377356500173745ustar00rootroot00000000000000ament_lint-0.12.0/ament_pclint/test/test_copyright.py000066400000000000000000000020321420377356500230120ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_copyright.main import main import pytest @pytest.mark.copyright @pytest.mark.linter def test_copyright(): path_prefix = 'ament_pclint/config/' excluded = [ 'gcc/co-g++.h', 'gcc/co-gcc.h', 'gcc/co-osx-g++.h', 'gcc/co-osx-gcc.h', 'msvc/co-cl.h', 'msvc/co-cl++.h'] rc = main(argv=['--exclude'] + [path_prefix + fname for fname in excluded]) assert rc == 0, 'Found errors' ament_lint-0.12.0/ament_pclint/test/test_flake8.py000066400000000000000000000015651420377356500221660ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.linter @pytest.mark.flake8 def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_pclint/test/test_pep257.py000066400000000000000000000014221420377356500220260ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pep257.main import main import pytest @pytest.mark.linter @pytest.mark.pep257 def test_pep257(): rc = main(argv=[]) assert rc == 0, 'Found docblock style errors' ament_lint-0.12.0/ament_pep257/000077500000000000000000000000001420377356500161465ustar00rootroot00000000000000ament_lint-0.12.0/ament_pep257/CHANGELOG.rst000066400000000000000000000157621420377356500202020ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_pep257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- * Remove use of distutils.version.LooseVersion. (`#346 `_) * Contributors: Chris Lalancette 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * remove use of "extend" action in argparse (`#262 `_) * Expand ignores to pep257 definition. (`#241 `_) * Expand ignores to pep257 definition. (ament `#240 `_) * add '--allow-undocumented' flag to enforce pep257 * restore existing default error codes to check * fix no-ignores logic * expose options from pydocstyle * allow user to explicitly set convention to "ament" * fix typo in populating argv for pydocstyle * reformat ament convention list * Add help info for ament convention * Add pytest.ini so local tests don't display warning. (`#259 `_) * remove match args to allow pydocstyle defaults (`#243 `_) * Contributors: Chris Lalancette, Ted Kern 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * Generate xunit files valid for the junit10.xsd (`#220 `_) * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dirk Thomas, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Ability to exclude folders with ament_pep257 (`#176 `_) * Contributors: Dirk Thomas, Dmitriy Vornychev 0.7.4 (2019-07-31) ------------------ * declare pytest markers (`#164 `_) * declare pytest markers * add markers to ament_xmllint tests * Contributors: Dirk Thomas 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ * Fix lint warnings from invalid escape sequences (`#111 `_) Use raw strings for regex patterns to avoid warnings. * Contributors: Jacob Perron 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ * level setup.py versions to 0.5.1 * Contributors: Mikael Arguedas 0.5.0 (2018-06-18 10:09) ------------------------ * add pytest markers to linter tests * set zip_safe to avoid warning during installation (`#96 `_) * Contributors: Dirk Thomas 0.4.0 (2017-12-08) ------------------ * remove test_suite, add pytest as test_requires * Add new D106, D107 linter errors to ignored list (`#86 `_) * Add new D107 linter error to ignored list * Ignore D106 also * 0.0.3 * Merge pull request `#84 `_ from ament/flake8_plugins update style to satisfy new flake8 plugins * update style to satisfy new flake8 plugins * 0.0.2 * Merge pull request `#78 `_ from ament/use_flake8 use flake8 instead of pep8 and pyflakes * fix style warnings * use flake8 instead of pep8 and pyflakes * Fix pydocstyle 2.0.0 (`#71 `_) * works with 2.0.0 * works with 1.1.1 and 2.0.0 * remove __future_\_ imports * Merge pull request `#61 `_ from ament/multistring_format (dev) enforcing multiline docstring format * ignore D404 * (dev) enforcing multiline docstring format by ignoring D212 we implicitely enforce D213 as the multistring comment format * Merge pull request `#58 `_ from Karsten1987/master (fix) correct pydocstyle import for version 1.1.0 * (fix) correct pydocstyle import for version 1.1.0 * update schema url * add schema to manifest files * fix pydocstyle paths (`#57 `_) * Merge pull request `#49 `_ from ament/xenial use upstream pydocstyle * use new pydocstyle * Merge pull request `#47 `_ from ament/wjwwood-patch-1 ignore pep257 error D203 by default * ignore pep257 error D203 by default * Merge pull request `#42 `_ from ament/remove_second_extension remove result type extension from testsuite name * remove result type extension from testsuite name * Merge pull request `#28 `_ from ament/pep257 add packages to check pep257 compliance * add ament_pep257 package * Contributors: Dirk Thomas, Karsten Knese, William Woodall, dhood ament_lint-0.12.0/ament_pep257/ament_pep257/000077500000000000000000000000001420377356500203545ustar00rootroot00000000000000ament_lint-0.12.0/ament_pep257/ament_pep257/__init__.py000066400000000000000000000000001420377356500224530ustar00rootroot00000000000000ament_lint-0.12.0/ament_pep257/ament_pep257/main.py000077500000000000000000000217001420377356500216550ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import logging import os import sys import time from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr import pydocstyle from pydocstyle import check try: # as of version 1.1.0 from pydocstyle.config import ConfigurationParser from pydocstyle.violations import Error from pydocstyle.utils import log except ImportError: # try version 1.0.0 from pydocstyle import ConfigurationParser from pydocstyle import Error from pydocstyle import log log.setLevel(logging.INFO) _conventions = set(pydocstyle.conventions.keys()) _conventions.add('ament') _ament_ignore = [ 'D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D106', 'D107', 'D203', 'D212', 'D404', ] def main(argv=sys.argv[1:]): parser = argparse.ArgumentParser( description='Check docstrings against the style conventions in PEP 257.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) err_code_group = parser.add_mutually_exclusive_group() err_code_group.add_argument( '--ignore', nargs='+', default=[], help='Choose the list of error codes for pydocstyle NOT to check for.') err_code_group.add_argument( '--select', nargs='+', default=[], help='Choose the basic list of error codes for pydocstyle to check for.' ) err_code_group.add_argument( '--convention', choices=_conventions, default='ament', help=( f'Choose a preset list of error codes. Valid options are {_conventions}.' f'The "ament" convention is defined as --ignore {_ament_ignore}.' ), ) parser.add_argument( '--add-ignore', nargs='+', default=[], help='Ignore an extra error code, removing it from the list set by --(select/ignore)') parser.add_argument( '--add-select', nargs='+', default=[], help='Check an extra error code, adding it to the list set by --(select/ignore).' ) parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories, files ending ' "in '.py' will be considered.") parser.add_argument( '--exclude', metavar='filename', nargs='*', default=[], dest='excludes', help='The filenames to exclude.') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if args.xunit_file: start_time = time.time() args.ignore = ','.join(args.ignore) args.select = ','.join(args.select) args.add_select = ','.join(args.add_select) args.add_ignore = ','.join(args.add_ignore) if not (args.ignore or args.select) and args.convention == 'ament': args.ignore = ','.join(_ament_ignore) excludes = [os.path.abspath(e) for e in args.excludes] report = generate_pep257_report(args.paths, excludes, args.ignore, args.select, args.convention, args.add_ignore, args.add_select) error_count = sum(len(r[1]) for r in report) # print summary if not error_count: print('No problems found') rc = 0 else: print('%d errors' % error_count) rc = 1 # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return rc def _filename_in_excludes(filename, excludes): absname = os.path.abspath(filename) return any(os.path.commonpath([absname, e]) == e for e in excludes) def generate_pep257_report(paths, excludes, ignore, select, convention, add_ignore, add_select): conf = ConfigurationParser() sys_argv = sys.argv sys.argv = [ 'main', '--match', r'.*\.py', '--match-dir', r'[^\._].*', ] if ignore: sys.argv += ['--ignore', ignore] elif select: sys.argv += ['--select', select] else: sys.argv += ['--convention', convention] if add_ignore: sys.argv += ['--add-ignore', add_ignore] if add_select: sys.argv += ['--add-select', add_select] sys.argv += paths conf.parse() sys.argv = sys_argv files_to_check = conf.get_files_to_check() report = [] files_dict = {} for filename, checked_codes, ignore_decorators in files_to_check: if _filename_in_excludes(filename, excludes): continue files_dict[filename] = { 'select': checked_codes, 'ignore_decorators': ignore_decorators, } for filename in sorted(files_dict.keys()): print('checking', filename) errors = [] pep257_errors = check( [filename], **files_dict[filename]) for pep257_error in pep257_errors: if isinstance(pep257_error, Error): errors.append({ 'category': pep257_error.code, 'linenumber': pep257_error.line, 'message': pep257_error.message, }) print( '%s:%d %s: %s' % (pep257_error.filename, pep257_error.line, pep257_error.definition, pep257_error.message)) elif isinstance(pep257_error, SyntaxError): errors.append({ 'category': str(type(pep257_error)), 'linenumber': '-', 'message': 'invalid syntax in file', }) print('%s: invalid syntax' % filename) else: errors.append({ 'category': 'unknown', 'linenumber': '-', 'message': str(pep257_error), }) print('%s: %s' % (filename, pep257_error)) report.append((filename, errors)) return report def get_xunit_content(report, testname, elapsed): test_count = sum(max(len(r[1]), 1) for r in report) error_count = sum(len(r[1]) for r in report) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for (filename, errors) in report: if errors: # report each error as a failing testcase for error in errors: data = { 'quoted_location': quoteattr( '%s (%s:%d)' % ( error['category'], filename, error['linenumber'])), 'testname': testname, 'quoted_message': quoteattr(error['message']), } xml += """ """ % data else: # if there are no lint_cmake errors report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % r[0] for r in report])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_pep257/ament_pep257/pytest_marker.py000066400000000000000000000013401420377356500236150ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def pytest_configure(config): config.addinivalue_line( 'markers', 'pep257: marks tests checking for PEP 257 compliance') ament_lint-0.12.0/ament_pep257/doc/000077500000000000000000000000001420377356500167135ustar00rootroot00000000000000ament_lint-0.12.0/ament_pep257/doc/index.rst000066400000000000000000000011241420377356500205520ustar00rootroot00000000000000ament_pep257 ============ Checks the docstring style of Python source files using `pep257 `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_pep257 [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_pep257 `_. ament_lint-0.12.0/ament_pep257/package.xml000066400000000000000000000016771420377356500202760ustar00rootroot00000000000000 ament_pep257 0.12.0 The ability to check code against the style conventions in PEP 8 and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 MIT Audrow Nash Claire Wang Dirk Thomas ament_lint pydocstyle ament_flake8 python3-pytest ament_python ament_lint-0.12.0/ament_pep257/pytest.ini000066400000000000000000000000351420377356500201750ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_pep257/resource/000077500000000000000000000000001420377356500177755ustar00rootroot00000000000000ament_lint-0.12.0/ament_pep257/resource/ament_pep257000066400000000000000000000000001420377356500221140ustar00rootroot00000000000000ament_lint-0.12.0/ament_pep257/setup.py000066400000000000000000000027721420377356500176700ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_pep257' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], package_data={'': [ 'configuration/ament_pep257.ini', ]}, zip_safe=True, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check Python code style using pep257.', long_description="""\ The ability to check code against the docstring conventions in PEP 257 and generate xUnit test result files.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_pep257 = ament_pep257.main:main', ], 'pytest11': [ 'ament_pep257 = ament_pep257.pytest_marker', ], }, ) ament_lint-0.12.0/ament_pep257/test/000077500000000000000000000000001420377356500171255ustar00rootroot00000000000000ament_lint-0.12.0/ament_pep257/test/test_flake8.py000066400000000000000000000015641420377356500217160ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_pycodestyle/000077500000000000000000000000001420377356500174705ustar00rootroot00000000000000ament_lint-0.12.0/ament_pycodestyle/CHANGELOG.rst000066400000000000000000000062431420377356500215160ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_pycodestyle ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Generate xunit files valid for the junit10.xsd (`#220 `_) * Rename pep8 packages to pycodestyle (part 2 of 2) The python package 'pep8' has been renamed to 'pycodestyle'. This change follows suit by renaming ament_pep8 and ament_cmake_pep8 to ament_pycodestyle and ament_cmake_pycodestyle respectively. * Rename pep8 packages to pycodestyle (part 1 of 2) The python package 'pep8' has been renamed to 'pycodestyle'. This change follows suit by renaming ament_pep8 and ament_cmake_pep8 to ament_pycodestyle and ament_cmake_pycodestyle respectively. * Contributors: Chris Lalancette, Jose Luis Rivero, Scott K Logan 0.8.1 (2019-10-23) ------------------ 0.8.0 (2019-09-17) ------------------ 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_pycodestyle/ament_pycodestyle/000077500000000000000000000000001420377356500232205ustar00rootroot00000000000000ament_lint-0.12.0/ament_pycodestyle/ament_pycodestyle/__init__.py000066400000000000000000000000001420377356500253170ustar00rootroot00000000000000ament_lint-0.12.0/ament_pycodestyle/ament_pycodestyle/configuration/000077500000000000000000000000001420377356500260675ustar00rootroot00000000000000ament_lint-0.12.0/ament_pycodestyle/ament_pycodestyle/configuration/ament_pycodestyle.ini000066400000000000000000000000571420377356500323220ustar00rootroot00000000000000[pycodestyle] ignore = '' max-line-length = 99 ament_lint-0.12.0/ament_pycodestyle/ament_pycodestyle/main.py000077500000000000000000000144431420377356500245270ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014-2015, 2020 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import os import sys from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr import pycodestyle def main(argv=sys.argv[1:]): config_file = os.path.join( os.path.dirname(__file__), 'configuration', 'ament_pycodestyle.ini') parser = argparse.ArgumentParser( description='Check code against the style conventions in PEP 8.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '--config', metavar='path', default=config_file, dest='config_file', help='The config file') parser.add_argument( '--linelength', metavar='N', type=int, help='The maximum line length (default: specified in the config file)') parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files ending ' "in '.py' will be considered.") parser.add_argument( '--exclude', metavar='filename', nargs='*', dest='excludes', help='The filenames to exclude.') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if not os.path.exists(args.config_file): print("Could not config file '%s'" % args.config_file, file=sys.stderr) return 1 report = generate_pycodestyle_report( args.config_file, args.paths, args.excludes, max_line_length=args.linelength) # print statistics about errors if report.total_errors: print('') report.print_statistics() # print summary print('') if not report.total_errors: print('No problems found') rc = 0 else: errors = report.get_count('E') warnings = report.get_count('W') print('%d errors, %d warnings' % (errors, warnings)) rc = 1 # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return rc def generate_pycodestyle_report(config_file, paths, excludes, max_line_length=None): kwargs = { 'repeat': True, 'show_source': True, 'verbose': True, 'reporter': CustomReport, 'config_file': config_file, } if max_line_length is not None: kwargs['max_line_length'] = max_line_length pycodestyle_guide = CustomStyleGuide(**kwargs) if excludes: pycodestyle_guide.options.exclude += excludes return pycodestyle_guide.check_files(paths) def get_xunit_content(report, testname): data = { 'testname': testname, 'test_count': max(report.total_errors, 1), 'error_count': report.total_errors, 'time': '%.3f' % round(report.elapsed, 3), } xml = """ """ % data if report.errors: # report each pycodestyle error/warning as a failing testcase for error in report.errors: data = { 'quoted_name': quoteattr( error['error_code'] + ' (%(path)s:%(row)d:%(column)d)' % error), 'testname': testname, 'quoted_message': quoteattr( '%(error_message)s:\n%(source_line)s' % error), } xml += """ """ % data else: # if there are no pycodestyle errors/warnings report a single successful test data = { 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % f for f in report.files])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml class CustomStyleGuide(pycodestyle.StyleGuide): def input_file(self, filename, **kwargs): self.options.reporter.files.append(filename) return super(CustomStyleGuide, self).input_file(filename, **kwargs) class CustomReport(pycodestyle.StandardReport): errors = [] files = [] def error(self, line_number, offset, text, check): code = super(CustomReport, self).error( line_number, offset, text, check) line = self.lines[line_number - 1] \ if line_number <= len(self.lines) else '' self.errors.append({ 'path': self.filename, 'row': self.line_offset + line_number, 'column': offset + 1, 'error_code': code, 'error_message': text, 'source_line': line.splitlines()[0] if line else '', }) return code if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_pycodestyle/doc/000077500000000000000000000000001420377356500202355ustar00rootroot00000000000000ament_lint-0.12.0/ament_pycodestyle/doc/index.rst000066400000000000000000000011551420377356500221000ustar00rootroot00000000000000ament_pycodestyle ================= Checks the code style of Python source files using `pycodestyle `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_pycodestyle [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_pycodestile `_. ament_lint-0.12.0/ament_pycodestyle/package.xml000066400000000000000000000014651420377356500216130ustar00rootroot00000000000000 ament_pycodestyle 0.12.0 The ability to check code against the style conventions in PEP 8 and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas python3-pycodestyle ament_python ament_lint-0.12.0/ament_pycodestyle/pytest.ini000066400000000000000000000000351420377356500215170ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_pycodestyle/resource/000077500000000000000000000000001420377356500213175ustar00rootroot00000000000000ament_lint-0.12.0/ament_pycodestyle/resource/ament_pycodestyle000066400000000000000000000000001420377356500247600ustar00rootroot00000000000000ament_lint-0.12.0/ament_pycodestyle/setup.py000066400000000000000000000026641420377356500212120ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_pycodestyle' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], package_data={'': [ 'configuration/ament_pycodestyle.ini', ]}, zip_safe=False, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check Python code style using pycodestyle.', long_description="""\ The ability to check code against the style conventions in PEP 8 and generate xUnit test result files.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_pycodestyle = ament_pycodestyle.main:main', ], }, ) ament_lint-0.12.0/ament_pyflakes/000077500000000000000000000000001420377356500167425ustar00rootroot00000000000000ament_lint-0.12.0/ament_pyflakes/CHANGELOG.rst000066400000000000000000000156071420377356500207740ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_pyflakes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * Generate xunit files valid for the junit10.xsd (`#220 `_) * Rename pep8 packages to pycodestyle (part 2 of 2) The python package 'pep8' has been renamed to 'pycodestyle'. This change follows suit by renaming ament_pep8 and ament_cmake_pep8 to ament_pycodestyle and ament_cmake_pycodestyle respectively. * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dirk Thomas, Jose Luis Rivero, Scott K Logan 0.8.1 (2019-10-23) ------------------ * fix pytest warning about unknown markers (`#194 `_) * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Contributors: Dirk Thomas 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ * level setup.py versions to 0.5.1 * Contributors: Mikael Arguedas 0.5.0 (2018-06-18 10:09) ------------------------ * add pytest markers to linter tests * set zip_safe to avoid warning during installation (`#96 `_) * Contributors: Dirk Thomas 0.4.0 (2017-12-08) ------------------ * remove test_suite, add pytest as test_requires * 0.0.3 * Merge pull request `#84 `_ from ament/flake8_plugins update style to satisfy new flake8 plugins * update style to satisfy new flake8 plugins * implicitly inherit from object (only in files not copied from somewhe… (`#83 `_) * implicitly inherit from object (only in files not copied from somewhere else) * don't modify file copied from elsewhere * Merge pull request `#81 `_ from ament/ignore_build_spaces ignore folders with an AMENT_IGNORE file, e.g. build spaces * ignore folders with an AMENT_IGNORE file, e.g. build spaces * 0.0.2 * remove __future_\_ imports * update schema url * add schema to manifest files * Merge pull request `#49 `_ from ament/xenial use upstream pydocstyle * use new pydocstyle * Merge pull request `#51 `_ from ament/lint_generated_code extend linter API to allow overriding the max line length * handle error messages where the line itself contains additional percent characters * Merge pull request `#42 `_ from ament/remove_second_extension remove result type extension from testsuite name * remove result type extension from testsuite name * apply normpath to prevent './' prefix (fix `#24 `_) * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * make use of python linter packages * support excluding filenames from copyright, pep8, pyflakes check * move cmake part of ament_pyflakes to ament_cmake_pyflakes * move cmake part of ament_pep8 to ament_cmake_pep8 * fix code style * disable debug output * add trailing newline to generated test result files * add missing copyright / license information * Merge pull request `#14 `_ from ament/test_runner_windows change test runner to work on windows * change test runner to work on windows * Merge pull request `#9 `_ from ament/docs add docs for linters * add docs for linters * modify generated unit test files for a better hierarchy in Jenkins * fix copy-n-pasted license names * make testname argument optional for all linters * use other linters for the linter packages where possible * run ament_copyright and ament_pyflakes with Python 3 * Merge pull request `#2 `_ from ament/ament_lint_auto allow linting based on test dependencies only * add ament_lint_auto and ament_lint_common, update all linter packages to implement extension point of ament_lint_auto * use project(.. NONE) * update to latest refactoring of ament_cmake * add dependency on ament_cmake_environment * add ament_pyflakes * Contributors: Dirk Thomas, Mikael Arguedas ament_lint-0.12.0/ament_pyflakes/ament_pyflakes/000077500000000000000000000000001420377356500217445ustar00rootroot00000000000000ament_lint-0.12.0/ament_pyflakes/ament_pyflakes/__init__.py000066400000000000000000000000001420377356500240430ustar00rootroot00000000000000ament_lint-0.12.0/ament_pyflakes/ament_pyflakes/main.py000077500000000000000000000164431420377356500232550ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import os import sys import time from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr from pyflakes.api import checkPath from pyflakes.messages import Message from pyflakes.reporter import Reporter def main(argv=sys.argv[1:]): parser = argparse.ArgumentParser( description='Check code using pyflakes.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files ending ' "in '.py' will be considered.") parser.add_argument( '--exclude', metavar='filename', nargs='*', dest='excludes', help='The filenames to exclude.') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if args.xunit_file: start_time = time.time() filenames = get_files(args.paths) if args.excludes: filenames = [f for f in filenames if os.path.basename(f) not in args.excludes] if not filenames: print('No files found', file=sys.stderr) return 1 report = [] # invoke pyflakes for each file for filename in filenames: reporter = CustomReporter() print(filename) checkPath(filename, reporter=reporter) for error in reporter.errors: try: print(error, file=sys.stderr) except TypeError: # this can happen if the line contains percent characters print(error.__dict__, file=sys.stderr) report.append((filename, reporter.errors)) print('') # output summary error_count = sum(len(r[1]) for r in report) if not error_count: print('No problems found') rc = 0 else: print('%d errors' % error_count, file=sys.stderr) rc = 1 # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return rc def get_files(paths): files = [] for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] dirnames.sort() # select files by extension for filename in sorted(filenames): if filename.endswith('.py'): files.append(os.path.join(dirpath, filename)) if os.path.isfile(path): files.append(path) return [os.path.normpath(f) for f in files] def get_xunit_content(report, testname, elapsed): test_count = sum(max(len(r[1]), 1) for r in report) error_count = sum(len(r[1]) for r in report) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for (filename, errors) in report: if errors: # report each pyflakes error as a failing testcase for error in errors: try: msg = error.message % error.message_args except TypeError: # this can happen if the line contains percent characters msg = error.message + ' ' + str(error.message_args) data = { 'quoted_name': quoteattr( '%s (%s:%d)' % ( type(error).__name__, filename, error.lineno)), 'testname': testname, 'quoted_message': quoteattr(msg), } xml += """ """ % data else: # if there are no pyflakes errors report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % r[0] for r in report])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml class CustomReporter(Reporter): def __init__(self): super(CustomReporter, self).__init__(sys.stdout, sys.stderr) self.errors = [] def unexpectedError(self, filename, msg): # noqa: N802 self.errors.append(UnexpectedError(filename, msg)) def syntaxError(self, filename, msg, lineno, offset, text): # noqa: N802 self.errors.append(SyntaxError(filename, msg, lineno, offset, text)) def flake(self, message): self.errors.append(message) class Location: def __init__(self, lineno, col_offset=None): self.lineno = lineno if col_offset is not None: self.col_offset = col_offset class SyntaxError(Message): message = 'syntax error %r' def __init__(self, filename, msg, lineno, offset, text): loc = Location(lineno, col_offset=offset) super(SyntaxError, self).__init__(filename, loc) self.message_args = (msg, text,) class UnexpectedError(Message): message = 'unexpected error %r' def __init__(self, filename, msg): loc = Location(0) super(UnexpectedError, self).__init__(filename, loc) self.message_args = (msg,) if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_pyflakes/doc/000077500000000000000000000000001420377356500175075ustar00rootroot00000000000000ament_lint-0.12.0/ament_pyflakes/doc/index.rst000066400000000000000000000011311420377356500213440ustar00rootroot00000000000000ament_pyflakes ============== Checks the code style of Python source files using `Pyflakes `_. Files with the following extensions are being considered: ``.py``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_pyflakes [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_pyflakes `_. ament_lint-0.12.0/ament_pyflakes/package.xml000066400000000000000000000015541420377356500210640ustar00rootroot00000000000000 ament_pyflakes 0.12.0 The ability to check code using pyflakes and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas pyflakes3 ament_pycodestyle python3-pytest ament_python ament_lint-0.12.0/ament_pyflakes/pytest.ini000066400000000000000000000002031420377356500207660ustar00rootroot00000000000000[pytest] markers = linter: marks tests as linter checks pep8: marks tests checking for pep8 compliance junit_family=xunit2 ament_lint-0.12.0/ament_pyflakes/resource/000077500000000000000000000000001420377356500205715ustar00rootroot00000000000000ament_lint-0.12.0/ament_pyflakes/resource/ament_pyflakes000066400000000000000000000000001420377356500235040ustar00rootroot00000000000000ament_lint-0.12.0/ament_pyflakes/setup.py000066400000000000000000000025001420377356500204510ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_pyflakes' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], zip_safe=True, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check Python code style using pyflakes.', long_description="""\ The ability to check code using pyflakes and generate xUnit test result files.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_pyflakes = ament_pyflakes.main:main', ], }, ) ament_lint-0.12.0/ament_pyflakes/test/000077500000000000000000000000001420377356500177215ustar00rootroot00000000000000ament_lint-0.12.0/ament_pyflakes/test/test_pep8.py000066400000000000000000000014371420377356500222130ustar00rootroot00000000000000# Copyright 2015, 2020 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pycodestyle.main import main import pytest @pytest.mark.linter @pytest.mark.pep8 def test_pep8(): rc = main(argv=[]) assert rc == 0, 'Found code style errors / warnings' ament_lint-0.12.0/ament_uncrustify/000077500000000000000000000000001420377356500173375ustar00rootroot00000000000000ament_lint-0.12.0/ament_uncrustify/CHANGELOG.rst000066400000000000000000000273241420377356500213700ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_uncrustify ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * [ament_uncrustify] Fix file exclusion behavior (`#334 `_) * [ament_uncrustify] Fix file exclusion behavior This PR fixes the file exclusion behavior reported in `#326 `_. Specifically, the exclusion list is matched against files/directories as the search path is traversed. Tries to maintain consistency with `#327 `_. * [ament_uncrustify] Add file exclusion tests * [ament_uncrustify] Remove erroneous pytest marker * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * [ament_uncrustify] Add ament_lint tests (`#338 `_) * Add `ament_lint` tests on `ament_uncrustify` * Address linter warnings in `ament_uncrustify` * Contributors: Abrar Rahman Protyasha, Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Allow 'C++' as language, but convert it to 'CPP' (`#302 `_) * Allow correct languages on uncrustify (`#272 `_) * Allow correct languages on uncrustify. * Update dictionary. * Contributors: Audrow Nash, Miguel Company 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * fix TypeError in ament_uncrustify (`#228 `_) * Generate xunit files valid for the junit10.xsd (`#220 `_) * pass explicit language to uncrustify (`#214 `_) * pass explicitl language to uncrustify * remove dst before renaming file to work on Windows * use dict comprehension * conditionally pass -l in both commands * remove unncessary line * fix comprehension * fix dict after fiddling with comprehension * add CMake option for force specific language for uncrustify * feedback about help message * remove status attribute from result XML (`#212 `_) * enable nl_func_call_start_multi_line in uncrustify (`#210 `_) * Contributors: Chris Lalancette, Dirk Thomas, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Contributors: Dirk Thomas 0.7.4 (2019-07-31) ------------------ 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * use explicit encoding when reading files (`#138 `_) * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ * [ament_uncrustify] Update uncrustiy configuration Added new options with defaults. * Contributors: Jacob Perron 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ * update configuration to 0.67 (`#103 `_) * update configuration to 0.67 * force sp_fparen_brace_initializer as it overrides sp_fparen_brace * Contributors: Mikael Arguedas 0.5.2 (2018-06-27) ------------------ * use uncrustify_vendor as a dependency (`#102 `_) * Contributors: Mikael Arguedas 0.5.1 (2018-06-18 13:47) ------------------------ * level setup.py versions to 0.5.1 * Contributors: Mikael Arguedas 0.5.0 (2018-06-18 10:09) ------------------------ * set zip_safe to avoid warning during installation (`#96 `_) * Merge pull request `#95 `_ from ament/uncrustify_0.66.1 update uncrustify config to version 0.66.1 * work around overmatching of nl_fcall_brace, since we don't use it just ignore it (which is the default anyway) * update uncrustify config to version 0.66.1 * Contributors: Dirk Thomas 0.4.0 (2017-12-08) ------------------ * remove test_suite, add pytest as test_requires * Merge pull request `#85 `_ from ament/uncrustify_master update uncrustify config * shuffle order of option groups as in new uncrustify version * update uncrustify config * 0.0.3 * Merge pull request `#84 `_ from ament/flake8_plugins update style to satisfy new flake8 plugins * update style to satisfy new flake8 plugins * Merge pull request `#81 `_ from ament/ignore_build_spaces ignore folders with an AMENT_IGNORE file, e.g. build spaces * ignore folders with an AMENT_IGNORE file, e.g. build spaces * 0.0.2 * remove __future_\_ imports * update schema url * add schema to manifest files * fix undefined variable in case of exceptions * Merge pull request `#52 `_ from ament/lint_generated_code fix handling of --root * fix custom line length for uncrustify on Windows * Merge pull request `#51 `_ from ament/lint_generated_code extend linter API to allow overriding the max line length * add CMake argument to override max line length for linters as well as the root for cpplint * Merge pull request `#44 `_ from ament/uncrustify_0.62 update config to uncrustify 0.62 * update config to uncrustify 0.62 * Merge pull request `#43 `_ from ament/ignore_space_after_semicolon ignore space after a semi colon * ignore space after a semi colon * Merge pull request `#42 `_ from ament/remove_second_extension remove result type extension from testsuite name * remove result type extension from testsuite name * Merge pull request `#25 `_ from ament/test_repeated_publisher_subscriber disable multi-line comment formatting since the result is just not good * disable multi-line comment formatting since the result is just not good * update style rule for preprocessor stringify operator * apply normpath to prevent './' prefix (fix `#24 `_) * Merge pull request `#23 `_ from ament/uncrustify_exclude_option add --exclude option to ament_uncrustify * add --exclude option to ament_uncrustify * treat enum like structs for newlines before {, allow newline in empty block * fix overwriting later used list, abort on non-deterministic values * update uncrustify config * fix location of uncrustify files on Windows * improve debugging of uncrustify errors * Merge pull request `#19 `_ from ament/split_linter_packages_in_python_and_cmake split linter packages in python and cmake * move cmake part of ament_uncrustify to ament_cmake_uncrustify * move cmake part of ament_pyflakes to ament_cmake_pyflakes * move cmake part of ament_pep8 to ament_cmake_pep8 * move cmake part of ament_lint_cmake to ament_cmake_lint_cmake * pass relative paths to uncrustify on Windows * fix finding uncrustify on windows * disable debug output * update uncrustify config (related to `#18 `_) * update uncrustify config (related to `#18 `_) * update uncrustify config (related to `#18 `_) * update uncrustify config to version 0.61 (related to `#18 `_) * update uncrustify config (related to `#18 `_) * update uncrustify config (related to `#18 `_) * Merge pull request `#18 `_ from ament/uncrustify_config update uncrustify config * update uncrustify config * fix uncrustify unit test results * update uncrustify config: treat structs like classes instead of ifs * add trailing newline to generated test result files * add missing copyright / license information * Merge pull request `#14 `_ from ament/test_runner_windows change test runner to work on windows * change test runner to work on windows * set code_width in uncrustify to 100 characters * update uncrustify configuration to enforce newlines before curly braces for namespaces, templates, classes and functions * add configuration file for ament_pep8, set max-line-length to 99, don't use default ignores * Merge pull request `#9 `_ from ament/docs add docs for linters * add docs for linters * modify generated unit test files for a better hierarchy in Jenkins * fix copy-n-pasted license names * make testname argument optional for all linters * use other linters for the linter packages where possible * code style only * Merge pull request `#2 `_ from ament/ament_lint_auto allow linting based on test dependencies only * add ament_lint_auto and ament_lint_common, update all linter packages to implement extension point of ament_lint_auto * use project(.. NONE) * update to latest refactoring of ament_cmake * add dependency on ament_cmake_environment * Merge pull request `#1 `_ from ament/uncrustify_google update uncrustify config to reflect google code style * add ament_clang_format * update uncrustify config to reflect google code style * add --reformat option to ament_uncrustify, run uncrustify multiple times if necessary * add ament_uncrustify * Contributors: Dirk Thomas, William Woodall ament_lint-0.12.0/ament_uncrustify/ament_uncrustify/000077500000000000000000000000001420377356500227365ustar00rootroot00000000000000ament_lint-0.12.0/ament_uncrustify/ament_uncrustify/__init__.py000066400000000000000000000000001420377356500250350ustar00rootroot00000000000000ament_lint-0.12.0/ament_uncrustify/ament_uncrustify/configuration/000077500000000000000000000000001420377356500256055ustar00rootroot00000000000000ament_lint-0.12.0/ament_uncrustify/ament_uncrustify/configuration/ament_code_style.cfg000066400000000000000000003077021420377356500316150ustar00rootroot00000000000000# Uncrustify-0.68 # # General options # # The type of line endings. Default=Auto. newlines = auto # auto/lf/crlf/cr # The original size of tabs in the input. Default=8. input_tab_size = 8 # unsigned number # The size of tabs in the output (only used if align_with_tabs=true). Default=8. output_tab_size = 8 # unsigned number # The ASCII value of the string escape char, usually 92 (\) or 94 (^). (Pawn). string_escape_char = 92 # unsigned number # Alternate string escape char for Pawn. Only works right before the quote char. string_escape_char2 = 0 # unsigned number # Replace tab characters found in string literals with the escape sequence \t instead. string_replace_tab_chars = false # false/true # Allow interpreting '>=' and '>>=' as part of a template in 'void f(list>=val);'. # If True, 'assert(x<0 && y>=3)' will be broken. Default=False # Improvements to template detection may make this option obsolete. tok_split_gte = false # false/true # Override the default ' *INDENT-OFF*' in comments for disabling processing of part of the file. disable_processing_cmt = " *INDENT-OFF*" # string # Override the default ' *INDENT-ON*' in comments for enabling processing of part of the file. enable_processing_cmt = " *INDENT-ON*" # string # Enable parsing of digraphs. Default=False. enable_digraphs = false # false/true # Control what to do with the UTF-8 BOM (recommend 'remove'). utf8_bom = ignore # ignore/add/remove/force # If the file contains bytes with values between 128 and 255, but is not UTF-8, then output as UTF-8. utf8_byte = false # false/true # Force the output encoding to UTF-8. utf8_force = false # false/true # # Spacing options # # Add or remove space around arithmetic operator '+', '-', '/', '*', etc # also '>>>' '<<' '>>' '%' '|'. sp_arith = force # ignore/add/remove/force # Add or remove space around arithmetic operator '+' and '-'. Overrides sp_arith sp_arith_additive = force # ignore/add/remove/force # Add or remove space around assignment operator '=', '+=', etc. sp_assign = force # ignore/add/remove/force # Add or remove space around '=' in C++11 lambda capture specifications. Overrides sp_assign. sp_cpp_lambda_assign = ignore # ignore/add/remove/force # Add or remove space after the capture specification in C++11 lambda. sp_cpp_lambda_paren = ignore # ignore/add/remove/force # Add or remove space around assignment operator '=' in a prototype. sp_assign_default = ignore # ignore/add/remove/force # Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign. sp_before_assign = ignore # ignore/add/remove/force # Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign. sp_after_assign = ignore # ignore/add/remove/force # Add or remove space in 'NS_ENUM ('. sp_enum_paren = ignore # ignore/add/remove/force # Add or remove space around assignment '=' in enum. sp_enum_assign = ignore # ignore/add/remove/force # Add or remove space before assignment '=' in enum. Overrides sp_enum_assign. sp_enum_before_assign = ignore # ignore/add/remove/force # Add or remove space after assignment '=' in enum. Overrides sp_enum_assign. sp_enum_after_assign = ignore # ignore/add/remove/force # Add or remove space around assignment ':' in enum. sp_enum_colon = ignore # ignore/add/remove/force # Add or remove space around preprocessor '##' concatenation operator. Default=Add. sp_pp_concat = force # ignore/add/remove/force # Add or remove space after preprocessor '#' stringify operator. Also affects the '#@' charizing operator. sp_pp_stringify = remove # ignore/add/remove/force # Add or remove space before preprocessor '#' stringify operator as in '#define x(y) L#y'. sp_before_pp_stringify = ignore # ignore/add/remove/force # Add or remove space around boolean operators '&&' and '||'. sp_bool = force # ignore/add/remove/force # Add or remove space around compare operator '<', '>', '==', etc. sp_compare = force # ignore/add/remove/force # Add or remove space inside '(' and ')'. sp_inside_paren = ignore # ignore/add/remove/force # Add or remove space between nested parens: '((' vs ') )'. sp_paren_paren = ignore # ignore/add/remove/force # Add or remove space between back-to-back parens: ')(' vs ') ('. sp_cparen_oparen = ignore # ignore/add/remove/force # Whether to balance spaces inside nested parens. sp_balance_nested_parens = false # false/true # Add or remove space between ')' and '{'. sp_paren_brace = force # ignore/add/remove/force # Add or remove space between nested braces, i.e. '{{' vs '{ {'. sp_brace_brace = ignore # ignore/add/remove/force # Add or remove space before pointer star '*'. sp_before_ptr_star = force # ignore/add/remove/force # Add or remove space before pointer star '*' that isn't followed by a variable name # If set to 'ignore', sp_before_ptr_star is used instead. sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force # Add or remove space between pointer stars '*'. sp_between_ptr_star = remove # ignore/add/remove/force # Add or remove space after pointer star '*', if followed by a word. sp_after_ptr_star = force # ignore/add/remove/force # Add or remove space after pointer caret '^', if followed by a word. sp_after_ptr_block_caret = ignore # ignore/add/remove/force # Add or remove space after pointer star '*', if followed by a qualifier. sp_after_ptr_star_qualifier = ignore # ignore/add/remove/force # Add or remove space after a pointer star '*', if followed by a func proto/def. sp_after_ptr_star_func = force # ignore/add/remove/force # Add or remove space after a pointer star '*', if followed by an open paren (function types). sp_ptr_star_paren = ignore # ignore/add/remove/force # Add or remove space before a pointer star '*', if followed by a func proto/def. sp_before_ptr_star_func = force # ignore/add/remove/force # Add or remove space before a reference sign '&'. sp_before_byref = force # ignore/add/remove/force # Add or remove space before a reference sign '&' that isn't followed by a variable name. # If set to 'ignore', sp_before_byref is used instead. sp_before_unnamed_byref = ignore # ignore/add/remove/force # Add or remove space after reference sign '&', if followed by a word. sp_after_byref = force # ignore/add/remove/force # Add or remove space after a reference sign '&', if followed by a func proto/def. sp_after_byref_func = force # ignore/add/remove/force # Add or remove space before a reference sign '&', if followed by a func proto/def. sp_before_byref_func = force # ignore/add/remove/force # Add or remove space between type and word. Default=Force. sp_after_type = force # ignore/add/remove/force # Add or remove space between 'decltype(...)' and word. sp_after_decltype = ignore # ignore/add/remove/force # Add or remove space before the paren in the D constructs 'template Foo(' and 'class Foo('. sp_before_template_paren = ignore # ignore/add/remove/force # Add or remove space in 'template <' vs 'template<'. # If set to ignore, sp_before_angle is used. sp_template_angle = ignore # ignore/add/remove/force # Add or remove space before '<>'. sp_before_angle = remove # ignore/add/remove/force # Add or remove space inside '<' and '>'. sp_inside_angle = remove # ignore/add/remove/force # Add or remove space between '<>' and ':'. sp_angle_colon = ignore # ignore/add/remove/force # Add or remove space after '<>'. sp_after_angle = remove # ignore/add/remove/force # Add or remove space between '<>' and '(' as found in 'new List(foo);'. sp_angle_paren = remove # ignore/add/remove/force # Add or remove space between '<>' and '()' as found in 'new List();'. sp_angle_paren_empty = remove # ignore/add/remove/force # Add or remove space between '<>' and a word as in 'List m;' or 'template static ...'. sp_angle_word = force # ignore/add/remove/force # Add or remove space between '>' and '>' in '>>' (template stuff). Default=Add. sp_angle_shift = remove # ignore/add/remove/force # Permit removal of the space between '>>' in 'foo >' (C++11 only). Default=False. # sp_angle_shift cannot remove the space without this option. sp_permit_cpp11_shift = true # false/true # Add or remove space before '(' of 'if', 'for', 'switch', 'while', etc. sp_before_sparen = force # ignore/add/remove/force # Add or remove space inside if-condition '(' and ')'. sp_inside_sparen = remove # ignore/add/remove/force # Add or remove space before if-condition ')'. Overrides sp_inside_sparen. sp_inside_sparen_close = ignore # ignore/add/remove/force # Add or remove space after if-condition '('. Overrides sp_inside_sparen. sp_inside_sparen_open = ignore # ignore/add/remove/force # Add or remove space after ')' of 'if', 'for', 'switch', and 'while', etc. sp_after_sparen = ignore # ignore/add/remove/force # Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while', etc. sp_sparen_brace = force # ignore/add/remove/force # Add or remove space between 'invariant' and '(' in the D language. sp_invariant_paren = ignore # ignore/add/remove/force # Add or remove space after the ')' in 'invariant (C) c' in the D language. sp_after_invariant_paren = ignore # ignore/add/remove/force # Add or remove space before empty statement ';' on 'if', 'for' and 'while'. sp_special_semi = ignore # ignore/add/remove/force # Add or remove space before ';'. Default=Remove. sp_before_semi = remove # ignore/add/remove/force # Add or remove space before ';' in non-empty 'for' statements. sp_before_semi_for = ignore # ignore/add/remove/force # Add or remove space before a semicolon of an empty part of a for statement. sp_before_semi_for_empty = ignore # ignore/add/remove/force # Add or remove space after ';', except when followed by a comment. Default=Add. sp_after_semi = ignore # ignore/add/remove/force # Add or remove space after ';' in non-empty 'for' statements. Default=Force. sp_after_semi_for = force # ignore/add/remove/force # Add or remove space after the final semicolon of an empty part of a for statement: for ( ; ; ). sp_after_semi_for_empty = force # ignore/add/remove/force # Add or remove space before '[' (except '[]'). sp_before_square = remove # ignore/add/remove/force # Add or remove space before structured bindings. Only for C++17. sp_cpp_before_struct_binding = ignore # ignore/add/remove/force # Add or remove space before '[]'. sp_before_squares = remove # ignore/add/remove/force # Add or remove space inside a non-empty '[' and ']'. sp_inside_square = remove # ignore/add/remove/force # Add or remove space inside a non-empty OC boxed array '@[' and ']'. # If set to ignore, sp_inside_square is used. sp_inside_square_oc_array = ignore # ignore/add/remove/force # Add or remove space after ',', 'a,b' vs 'a, b'. sp_after_comma = force # ignore/add/remove/force # Add or remove space before ','. Default=Remove. sp_before_comma = remove # ignore/add/remove/force # Add or remove space between ',' and ']' in multidimensional array type 'int[,,]'. Only for C#. sp_after_mdatype_commas = ignore # ignore/add/remove/force # Add or remove space between '[' and ',' in multidimensional array type 'int[,,]'. Only for C#. sp_before_mdatype_commas = ignore # ignore/add/remove/force # Add or remove space between ',' in multidimensional array type 'int[,,]'. Only for C#. sp_between_mdatype_commas = ignore # ignore/add/remove/force # Add or remove space between an open paren and comma: '(,' vs '( ,'. Default=Force. sp_paren_comma = force # ignore/add/remove/force # Add or remove space before the variadic '...' when preceded by a non-punctuator. sp_before_ellipsis = ignore # ignore/add/remove/force # Add or remove space between a type and '...'. sp_type_ellipsis = ignore # ignore/add/remove/force # Add or remove space between ')' and '...'. sp_paren_ellipsis = ignore # ignore/add/remove/force # Add or remove space after class ':'. sp_after_class_colon = force # ignore/add/remove/force # Add or remove space before class ':'. sp_before_class_colon = force # ignore/add/remove/force # Add or remove space after class constructor ':'. sp_after_constr_colon = ignore # ignore/add/remove/force # Add or remove space before class constructor ':'. sp_before_constr_colon = ignore # ignore/add/remove/force # Add or remove space before case ':'. Default=Remove. sp_before_case_colon = remove # ignore/add/remove/force # Add or remove space between 'operator' and operator sign. sp_after_operator = remove # ignore/add/remove/force # Add or remove space between the operator symbol and the open paren, as in 'operator ++('. sp_after_operator_sym = remove # ignore/add/remove/force # Overrides sp_after_operator_sym when the operator has no arguments, as in 'operator *()'. sp_after_operator_sym_empty = remove # ignore/add/remove/force # Add or remove space after C/D cast, i.e. 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a'. sp_after_cast = ignore # ignore/add/remove/force # Add or remove spaces inside cast parens. sp_inside_paren_cast = remove # ignore/add/remove/force # Add or remove space between the type and open paren in a C++ cast, i.e. 'int(exp)' vs 'int (exp)'. sp_cpp_cast_paren = remove # ignore/add/remove/force # Add or remove space between 'sizeof' and '('. sp_sizeof_paren = remove # ignore/add/remove/force # Add or remove space between 'sizeof' and '...'. sp_sizeof_ellipsis = ignore # ignore/add/remove/force # Add or remove space between 'sizeof...' and '('. sp_sizeof_ellipsis_paren = ignore # ignore/add/remove/force # Add or remove space between 'decltype' and '('. sp_decltype_paren = ignore # ignore/add/remove/force # Add or remove space after the tag keyword (Pawn). sp_after_tag = ignore # ignore/add/remove/force # Add or remove space inside enum '{' and '}'. sp_inside_braces_enum = ignore # ignore/add/remove/force # Add or remove space inside struct/union '{' and '}'. sp_inside_braces_struct = ignore # ignore/add/remove/force # Add or remove space inside OC boxed dictionary @'{' and '}' sp_inside_braces_oc_dict = ignore # ignore/add/remove/force # Add or remove space after open brace in an unnamed temporary direct-list-initialization. sp_after_type_brace_init_lst_open = ignore # ignore/add/remove/force # Add or remove space before close brace in an unnamed temporary direct-list-initialization. sp_before_type_brace_init_lst_close = ignore # ignore/add/remove/force # Add or remove space inside an unnamed temporary direct-list-initialization. sp_inside_type_brace_init_lst = ignore # ignore/add/remove/force # Add or remove space inside '{' and '}'. sp_inside_braces = remove # ignore/add/remove/force # Add or remove space inside '{}'. sp_inside_braces_empty = remove # ignore/add/remove/force # Add or remove space between return type and function name # A minimum of 1 is forced except for pointer return types. sp_type_func = ignore # ignore/add/remove/force # Add or remove space between type and open brace of an unnamed temporary direct-list-initialization. sp_type_brace_init_lst = ignore # ignore/add/remove/force # Add or remove space between function name and '(' on function declaration. sp_func_proto_paren = remove # ignore/add/remove/force # Add or remove space between function name and '()' on function declaration without parameters. sp_func_proto_paren_empty = remove # ignore/add/remove/force # Add or remove space between function name and '(' on function definition. sp_func_def_paren = remove # ignore/add/remove/force # Add or remove space between function name and '()' on function definition without parameters. sp_func_def_paren_empty = remove # ignore/add/remove/force # Add or remove space inside empty function '()'. sp_inside_fparens = remove # ignore/add/remove/force # Add or remove space inside function '(' and ')'. sp_inside_fparen = remove # ignore/add/remove/force # Add or remove space inside the first parens in the function type: 'void (*x)(...)'. sp_inside_tparen = ignore # ignore/add/remove/force # Add or remove between the parens in the function type: 'void (*x)(...)'. sp_after_tparen_close = ignore # ignore/add/remove/force # Add or remove space between ']' and '(' when part of a function call. sp_square_fparen = remove # ignore/add/remove/force # Add or remove space between ')' and '{' of function. sp_fparen_brace = force # ignore/add/remove/force # Add or remove space between ')' and '{' of function call in object initialization. Overrides sp_fparen_brace. sp_fparen_brace_initializer = force # ignore/add/remove/force # Java: Add or remove space between ')' and '{{' of double brace initializer. sp_fparen_dbrace = ignore # ignore/add/remove/force # Add or remove space between function name and '(' on function calls. sp_func_call_paren = remove # ignore/add/remove/force # Add or remove space between function name and '()' on function calls without parameters. # If set to 'ignore' (the default), sp_func_call_paren is used. sp_func_call_paren_empty = ignore # ignore/add/remove/force # Add or remove space between the user function name and '(' on function calls # You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. sp_func_call_user_paren = ignore # ignore/add/remove/force # Add or remove space inside user function '(' and ')' # You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. sp_func_call_user_inside_fparen = ignore # ignore/add/remove/force # Add or remove space between nested parens with user functions: '((' vs ') )'You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. sp_func_call_user_paren_paren = ignore # ignore/add/remove/force # Add or remove space between a constructor/destructor and the open paren. sp_func_class_paren = remove # ignore/add/remove/force # Add or remove space between a constructor without parameters or destructor and '()'. sp_func_class_paren_empty = remove # ignore/add/remove/force # Add or remove space between 'return' and '('. sp_return_paren = ignore # ignore/add/remove/force # Add or remove space between 'return' and '{'. sp_return_brace = ignore # ignore/add/remove/force # Add or remove space between '__attribute__' and '('. sp_attribute_paren = ignore # ignore/add/remove/force # Add or remove space between 'defined' and '(' in '#if defined (FOO)'. sp_defined_paren = ignore # ignore/add/remove/force # Add or remove space between 'throw' and '(' in 'throw (something)'. sp_throw_paren = ignore # ignore/add/remove/force # Add or remove space between 'throw' and anything other than '(' as in '@throw [...];'. sp_after_throw = ignore # ignore/add/remove/force # Add or remove space between 'catch' and '(' in 'catch (something) { }' # If set to ignore, sp_before_sparen is used. sp_catch_paren = ignore # ignore/add/remove/force # Add or remove space between '@catch' and '(' in '@catch (something) { }' # If set to ignore, sp_catch_paren is used. sp_oc_catch_paren = ignore # ignore/add/remove/force # Add or remove space between 'version' and '(' in 'version (something) { }' (D language) # If set to ignore, sp_before_sparen is used. sp_version_paren = ignore # ignore/add/remove/force # Add or remove space between 'scope' and '(' in 'scope (something) { }' (D language) # If set to ignore, sp_before_sparen is used. sp_scope_paren = ignore # ignore/add/remove/force # Add or remove space between 'super' and '(' in 'super (something)'. Default=Remove. sp_super_paren = remove # ignore/add/remove/force # Add or remove space between 'this' and '(' in 'this (something)'. Default=Remove. sp_this_paren = remove # ignore/add/remove/force # Add or remove space between macro and value. sp_macro = ignore # ignore/add/remove/force # Add or remove space between macro function ')' and value. sp_macro_func = ignore # ignore/add/remove/force # Add or remove space between 'else' and '{' if on the same line. sp_else_brace = force # ignore/add/remove/force # Add or remove space between '}' and 'else' if on the same line. sp_brace_else = force # ignore/add/remove/force # Add or remove space between '}' and the name of a typedef on the same line. sp_brace_typedef = force # ignore/add/remove/force # Add or remove space between 'catch' and '{' if on the same line. sp_catch_brace = force # ignore/add/remove/force # Add or remove space between '@catch' and '{' if on the same line. # If set to ignore, sp_catch_brace is used. sp_oc_catch_brace = ignore # ignore/add/remove/force # Add or remove space between '}' and 'catch' if on the same line. sp_brace_catch = force # ignore/add/remove/force # Add or remove space between '}' and '@catch' if on the same line. # If set to ignore, sp_brace_catch is used. sp_oc_brace_catch = ignore # ignore/add/remove/force # Add or remove space between 'finally' and '{' if on the same line. sp_finally_brace = force # ignore/add/remove/force # Add or remove space between '}' and 'finally' if on the same line. sp_brace_finally = force # ignore/add/remove/force # Add or remove space between 'try' and '{' if on the same line. sp_try_brace = force # ignore/add/remove/force # Add or remove space between get/set and '{' if on the same line. sp_getset_brace = ignore # ignore/add/remove/force # Add or remove space between a variable and '{' for C++ uniform initialization. Default=Add. sp_word_brace = add # ignore/add/remove/force # Add or remove space between a variable and '{' for a namespace. Default=Add. sp_word_brace_ns = add # ignore/add/remove/force # Add or remove space before the '::' operator. sp_before_dc = remove # ignore/add/remove/force # Add or remove space after the '::' operator. sp_after_dc = remove # ignore/add/remove/force # Add or remove around the D named array initializer ':' operator. sp_d_array_colon = ignore # ignore/add/remove/force # Add or remove space after the '!' (not) operator. Default=Remove. sp_not = remove # ignore/add/remove/force # Add or remove space after the '~' (invert) operator. Default=Remove. sp_inv = remove # ignore/add/remove/force # Add or remove space after the '&' (address-of) operator. Default=Remove # This does not affect the spacing after a '&' that is part of a type. sp_addr = remove # ignore/add/remove/force # Add or remove space around the '.' or '->' operators. Default=Remove. sp_member = remove # ignore/add/remove/force # Add or remove space after the '*' (dereference) operator. Default=Remove # This does not affect the spacing after a '*' that is part of a type. sp_deref = remove # ignore/add/remove/force # Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'. Default=Remove. sp_sign = remove # ignore/add/remove/force # Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;'. Default=Remove. sp_incdec = remove # ignore/add/remove/force # Add or remove space before a backslash-newline at the end of a line. Default=Add. sp_before_nl_cont = force # ignore/add/remove/force # Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;'. sp_after_oc_scope = ignore # ignore/add/remove/force # Add or remove space after the colon in message specs # '-(int) f:(int) x;' vs '-(int) f: (int) x;'. sp_after_oc_colon = ignore # ignore/add/remove/force # Add or remove space before the colon in message specs # '-(int) f: (int) x;' vs '-(int) f : (int) x;'. sp_before_oc_colon = ignore # ignore/add/remove/force # Add or remove space after the colon in immutable dictionary expression # 'NSDictionary *test = @{@"foo" :@"bar"};'. sp_after_oc_dict_colon = ignore # ignore/add/remove/force # Add or remove space before the colon in immutable dictionary expression # 'NSDictionary *test = @{@"foo" :@"bar"};'. sp_before_oc_dict_colon = ignore # ignore/add/remove/force # Add or remove space after the colon in message specs # '[object setValue:1];' vs '[object setValue: 1];'. sp_after_send_oc_colon = ignore # ignore/add/remove/force # Add or remove space before the colon in message specs # '[object setValue:1];' vs '[object setValue :1];'. sp_before_send_oc_colon = ignore # ignore/add/remove/force # Add or remove space after the (type) in message specs # '-(int)f: (int) x;' vs '-(int)f: (int)x;'. sp_after_oc_type = ignore # ignore/add/remove/force # Add or remove space after the first (type) in message specs # '-(int) f:(int)x;' vs '-(int)f:(int)x;'. sp_after_oc_return_type = ignore # ignore/add/remove/force # Add or remove space between '@selector' and '(' # '@selector(msgName)' vs '@selector (msgName)' # Also applies to @protocol() constructs. sp_after_oc_at_sel = ignore # ignore/add/remove/force # Add or remove space between '@selector(x)' and the following word # '@selector(foo) a:' vs '@selector(foo)a:'. sp_after_oc_at_sel_parens = ignore # ignore/add/remove/force # Add or remove space inside '@selector' parens # '@selector(foo)' vs '@selector( foo )' # Also applies to @protocol() constructs. sp_inside_oc_at_sel_parens = ignore # ignore/add/remove/force # Add or remove space before a block pointer caret # '^int (int arg){...}' vs. ' ^int (int arg){...}'. sp_before_oc_block_caret = ignore # ignore/add/remove/force # Add or remove space after a block pointer caret # '^int (int arg){...}' vs. '^ int (int arg){...}'. sp_after_oc_block_caret = ignore # ignore/add/remove/force # Add or remove space between the receiver and selector in a message. # '[receiver selector ...]'. sp_after_oc_msg_receiver = ignore # ignore/add/remove/force # Add or remove space after @property. sp_after_oc_property = ignore # ignore/add/remove/force # Add or remove space between '@synchronized' and the parenthesis # '@synchronized(foo)' vs '@synchronized (foo)'. sp_after_oc_synchronized = ignore # ignore/add/remove/force # Add or remove space around the ':' in 'b ? t : f'. sp_cond_colon = force # ignore/add/remove/force # Add or remove space before the ':' in 'b ? t : f'. Overrides sp_cond_colon. sp_cond_colon_before = ignore # ignore/add/remove/force # Add or remove space after the ':' in 'b ? t : f'. Overrides sp_cond_colon. sp_cond_colon_after = ignore # ignore/add/remove/force # Add or remove space around the '?' in 'b ? t : f'. sp_cond_question = force # ignore/add/remove/force # Add or remove space before the '?' in 'b ? t : f'. Overrides sp_cond_question. sp_cond_question_before = ignore # ignore/add/remove/force # Add or remove space after the '?' in 'b ? t : f'. Overrides sp_cond_question. sp_cond_question_after = ignore # ignore/add/remove/force # In the abbreviated ternary form (a ?: b), add/remove space between ? and :.'. Overrides all other sp_cond_* options. sp_cond_ternary_short = ignore # ignore/add/remove/force # Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. sp_case_label = force # ignore/add/remove/force # Control the space around the D '..' operator. sp_range = ignore # ignore/add/remove/force # Control the spacing after ':' in 'for (TYPE VAR : EXPR)'. Only JAVA. sp_after_for_colon = ignore # ignore/add/remove/force # Control the spacing before ':' in 'for (TYPE VAR : EXPR)'. Only JAVA. sp_before_for_colon = ignore # ignore/add/remove/force # Control the spacing in 'extern (C)' (D). sp_extern_paren = ignore # ignore/add/remove/force # Control the space after the opening of a C++ comment '// A' vs '//A'. sp_cmt_cpp_start = ignore # ignore/add/remove/force # True: If space is added with sp_cmt_cpp_start, do it after doxygen sequences like '///', '///<', '//!' and '//!<'. sp_cmt_cpp_doxygen = false # false/true # True: If space is added with sp_cmt_cpp_start, do it after Qt translator or meta-data comments like '//:', '//=', and '//~'. sp_cmt_cpp_qttr = false # false/true # Controls the spaces between #else or #endif and a trailing comment. sp_endif_cmt = ignore # ignore/add/remove/force # Controls the spaces after 'new', 'delete' and 'delete[]'. sp_after_new = force # ignore/add/remove/force # Controls the spaces between new and '(' in 'new()'. sp_between_new_paren = ignore # ignore/add/remove/force # Controls the spaces between ')' and 'type' in 'new(foo) BAR'. sp_after_newop_paren = ignore # ignore/add/remove/force # Controls the spaces inside paren of the new operator: 'new(foo) BAR'. sp_inside_newop_paren = ignore # ignore/add/remove/force # Controls the space after open paren of the new operator: 'new(foo) BAR'. # Overrides sp_inside_newop_paren. sp_inside_newop_paren_open = ignore # ignore/add/remove/force # Controls the space before close paren of the new operator: 'new(foo) BAR'. # Overrides sp_inside_newop_paren. sp_inside_newop_paren_close = ignore # ignore/add/remove/force # Controls the spaces before a trailing or embedded comment. sp_before_tr_emb_cmt = ignore # ignore/add/remove/force # Number of spaces before a trailing or embedded comment. sp_num_before_tr_emb_cmt = 2 # unsigned number # Control space between a Java annotation and the open paren. sp_annotation_paren = ignore # ignore/add/remove/force # If True, vbrace tokens are dropped to the previous token and skipped. sp_skip_vbrace_tokens = false # false/true # Controls the space after 'noexcept'. sp_after_noexcept = ignore # ignore/add/remove/force # If True, a is inserted after #define. force_tab_after_define = false # false/true # # Indenting # # The number of columns to indent per level. # Usually 2, 3, 4, or 8. Default=8. indent_columns = 2 # unsigned number # The continuation indent. If non-zero, this overrides the indent of '(' and '=' continuation indents. # For FreeBSD, this is set to 4. Negative value is absolute and not increased for each '(' level. indent_continue = 2 # number # The continuation indent, only for class header line(s). If non-zero, this # overrides the indent of 'class' continuation indents. indent_continue_class_head = 0 # unsigned number # Indent empty lines - lines which contain only spaces before newline character indent_single_newlines = false # false/true # The continuation indent for func_*_param if they are true. # If non-zero, this overrides the indent. indent_param = 0 # unsigned number # How to use tabs when indenting code # 0=spaces only # 1=indent with tabs to brace level, align with spaces (default) # 2=indent and align with tabs, using spaces when not on a tabstop indent_with_tabs = 0 # unsigned number # Comments that are not a brace level are indented with tabs on a tabstop. # Requires indent_with_tabs=2. If false, will use spaces. indent_cmt_with_tabs = false # false/true # Whether to indent strings broken by '\' so that they line up. indent_align_string = false # false/true # The number of spaces to indent multi-line XML strings. # Requires indent_align_string=True. indent_xml_string = 0 # unsigned number # Spaces to indent '{' from level. indent_brace = 0 # unsigned number # Whether braces are indented to the body level. indent_braces = false # false/true # Disabled indenting function braces if indent_braces is True. indent_braces_no_func = false # false/true # Disabled indenting class braces if indent_braces is True. indent_braces_no_class = false # false/true # Disabled indenting struct braces if indent_braces is True. indent_braces_no_struct = false # false/true # Indent based on the size of the brace parent, i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc. indent_brace_parent = false # false/true # Indent based on the paren open instead of the brace open in '({\n', default is to indent by brace. indent_paren_open_brace = false # false/true # indent a C# delegate by another level, default is to not indent by another level. indent_cs_delegate_brace = false # false/true # indent a C# delegate(To hanndle delegates with no brace) by another level. default: false indent_cs_delegate_body = false # false/true # Whether the 'namespace' body is indented. indent_namespace = false # false/true # Only indent one namespace and no sub-namespaces. # Requires indent_namespace=True. indent_namespace_single_indent = false # false/true # The number of spaces to indent a namespace block. indent_namespace_level = 0 # unsigned number # If the body of the namespace is longer than this number, it won't be indented. # Requires indent_namespace=True. Default=0 (no limit) indent_namespace_limit = 0 # unsigned number # Whether the 'extern "C"' body is indented. indent_extern = false # false/true # Whether the 'class' body is indented. indent_class = true # false/true # Whether to indent the stuff after a leading base class colon. indent_class_colon = false # false/true # Indent based on a class colon instead of the stuff after the colon. # Requires indent_class_colon=True. Default=False. indent_class_on_colon = false # false/true # Whether to indent the stuff after a leading class initializer colon. indent_constr_colon = true # false/true # Virtual indent from the ':' for member initializers. Default=2. indent_ctor_init_leading = 2 # unsigned number # Additional indent for constructor initializer list. # Negative values decrease indent down to the first column. Default=0. indent_ctor_init = -2 # number # False=treat 'else\nif' as 'else if' for indenting purposes # True=indent the 'if' one level. indent_else_if = false # false/true # Amount to indent variable declarations after a open brace. neg=relative, pos=absolute. indent_var_def_blk = 0 # number # Indent continued variable declarations instead of aligning. indent_var_def_cont = false # false/true # Indent continued shift expressions ('<<' and '>>') instead of aligning. # Turn align_left_shift off when enabling this. indent_shift = false # false/true # True: force indentation of function definition to start in column 1 # False: use the default behavior. indent_func_def_force_col1 = false # false/true # True: indent continued function call parameters one indent level # False: align parameters under the open paren. indent_func_call_param = false # false/true # Same as indent_func_call_param, but for function defs. indent_func_def_param = false # false/true # Same as indent_func_call_param, but for function protos. indent_func_proto_param = false # false/true # Same as indent_func_call_param, but for class declarations. indent_func_class_param = false # false/true # Same as indent_func_call_param, but for class variable constructors. indent_func_ctor_var_param = false # false/true # Same as indent_func_call_param, but for templates. indent_template_param = false # false/true # Double the indent for indent_func_xxx_param options. # Use both values of the options indent_columns and indent_param. indent_func_param_double = false # false/true # Indentation column for standalone 'const' function decl/proto qualifier. indent_func_const = 0 # unsigned number # Indentation column for standalone 'throw' function decl/proto qualifier. indent_func_throw = 0 # unsigned number # The number of spaces to indent a continued '->' or '.' # Usually set to 0, 1, or indent_columns. indent_member = 0 # unsigned number # setting to true will indent lines broken at '.' or '->' by a single indent # UO_indent_member option will not be effective if this is set to true. indent_member_single = false # false/true # Spaces to indent single line ('//') comments on lines before code. indent_sing_line_comments = 0 # unsigned number # If set, will indent trailing single line ('//') comments relative # to the code instead of trying to keep the same absolute column. indent_relative_single_line_comments = false # false/true # Spaces to indent 'case' from 'switch' # Usually 0 or indent_columns. indent_switch_case = 2 # unsigned number # Whether to indent preprocessor statements inside of switch statements. indent_switch_pp = true # false/true # Spaces to shift the 'case' line, without affecting any other lines # Usually 0. indent_case_shift = 0 # unsigned number # Spaces to indent '{' from 'case'. # By default, the brace will appear under the 'c' in case. # Usually set to 0 or indent_columns. # negative value are OK. indent_case_brace = 2 # number # Whether to indent comments found in first column. indent_col1_comment = false # false/true # How to indent goto labels # >0: absolute column where 1 is the leftmost column # <=0: subtract from brace indent # Default=1 indent_label = 1 # number # Same as indent_label, but for access specifiers that are followed by a colon. Default=1 indent_access_spec = 1 # number # Indent the code after an access specifier by one level. # If set, this option forces 'indent_access_spec=0'. indent_access_spec_body = false # false/true # If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended). indent_paren_nl = false # false/true # Controls the indent of a close paren after a newline. # 0: Indent to body level # 1: Align under the open paren # 2: Indent to the brace level indent_paren_close = 2 # unsigned number # Controls the indent of the open paren of a function definition, if on it's own line.If True, indents the open paren indent_paren_after_func_def = false # false/true # Controls the indent of the open paren of a function declaration, if on it's own line.If True, indents the open paren indent_paren_after_func_decl = false # false/true # Controls the indent of the open paren of a function call, if on it's own line.If True, indents the open paren indent_paren_after_func_call = false # false/true # Controls the indent of a comma when inside a paren.If True, aligns under the open paren. indent_comma_paren = false # false/true # Controls the indent of a BOOL operator when inside a paren.If True, aligns under the open paren. indent_bool_paren = false # false/true # Controls the indent of a semicolon when inside a for paren.If True, aligns under the open for paren. indent_semicolon_for_paren = false # false/true # If 'indent_bool_paren' is True, controls the indent of the first expression. If True, aligns the first expression to the following ones. indent_first_bool_expr = false # false/true # If 'indent_semicolon_for_paren' is True, controls the indent of the first expression. If True, aligns the first expression to the following ones. indent_first_for_expr = false # false/true # If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended). indent_square_nl = false # false/true # Don't change the relative indent of ESQL/C 'EXEC SQL' bodies. indent_preserve_sql = false # false/true # Align continued statements at the '='. Default=True # If False or the '=' is followed by a newline, the next line is indent one tab. indent_align_assign = false # false/true # Align continued statements at the '('. Default=True # If FALSE or the '(' is not followed by a newline, the next line indent is one tab. indent_align_paren = true # false/true # Indent OC blocks at brace level instead of usual rules. indent_oc_block = false # false/true # Indent OC blocks in a message relative to the parameter name. # 0=use indent_oc_block rules, 1+=spaces to indent indent_oc_block_msg = 0 # unsigned number # Minimum indent for subsequent parameters indent_oc_msg_colon = 0 # unsigned number # If True, prioritize aligning with initial colon (and stripping spaces from lines, if necessary). # Default=True. indent_oc_msg_prioritize_first_colon = true # false/true # If indent_oc_block_msg and this option are on, blocks will be indented the way that Xcode does by default (from keyword if the parameter is on its own line; otherwise, from the previous indentation level). indent_oc_block_msg_xcode_style = false # false/true # If indent_oc_block_msg and this option are on, blocks will be indented from where the brace is relative to a msg keyword. indent_oc_block_msg_from_keyword = false # false/true # If indent_oc_block_msg and this option are on, blocks will be indented from where the brace is relative to a msg colon. indent_oc_block_msg_from_colon = false # false/true # If indent_oc_block_msg and this option are on, blocks will be indented from where the block caret is. indent_oc_block_msg_from_caret = false # false/true # If indent_oc_block_msg and this option are on, blocks will be indented from where the brace is. indent_oc_block_msg_from_brace = false # false/true # When indenting after virtual brace open and newline add further spaces to reach this min. indent. indent_min_vbrace_open = 0 # unsigned number # True: When identing after virtual brace open and newline add further spaces after regular indent to reach next tabstop. indent_vbrace_open_on_tabstop = false # false/true # If True, a brace followed by another token (not a newline) will indent all contained lines to match the token.Default=True. indent_token_after_brace = false # false/true # If True, cpp lambda body will be indentedDefault=False. indent_cpp_lambda_body = true # false/true # indent (or not) an using block if no braces are used. Only for C#.Default=True. indent_using_block = true # false/true # indent the continuation of ternary operator. # 0: (Default) off # 1: When the `if_false` is a continuation, indent it under `if_false` # 2: When the `:` is a continuation, indent it under `?` indent_ternary_operator = 0 # unsigned number # If true, the indentation of the chunks after a `return new` sequence will be set at return indentation column. indent_off_after_return_new = false # false/true # If true, the tokens after return are indented with regular single indentation.By default (false) the indentation is after the return token. indent_single_after_return = false # false/true # If true, ignore indent and align for asm blocks as they have their own indentation. indent_ignore_asm_block = false # false/true # # Newline adding and removing options # # Whether to collapse empty blocks between '{' and '}'. nl_collapse_empty_body = false # false/true # Don't split one-line braced assignments - 'foo_t f = { 1, 2 };'. nl_assign_leave_one_liners = true # false/true # Don't split one-line braced statements inside a class xx { } body. nl_class_leave_one_liners = true # false/true # Don't split one-line enums: 'enum foo { BAR = 15 };' nl_enum_leave_one_liners = true # false/true # Don't split one-line get or set functions. nl_getset_leave_one_liners = true # false/true # Don't split one-line get or set functions. nl_cs_property_leave_one_liners = false # false/true # Don't split one-line function definitions - 'int foo() { return 0; }'. nl_func_leave_one_liners = true # false/true # Don't split one-line C++11 lambdas - '[]() { return 0; }'. nl_cpp_lambda_leave_one_liners = true # false/true # Don't split one-line if/else statements - 'if(a) b++;'. nl_if_leave_one_liners = true # false/true # Don't split one-line while statements - 'while(a) b++;'. nl_while_leave_one_liners = true # false/true # Don't split one-line OC messages. nl_oc_msg_leave_one_liner = false # false/true # (OC) Add or remove newline between method declaration and '{'. nl_oc_mdef_brace = ignore # ignore/add/remove/force # Add or remove newline between Objective-C block signature and '{'. nl_oc_block_brace = ignore # ignore/add/remove/force # Add or remove newline between @interface and '{'. nl_oc_interface_brace = ignore # ignore/add/remove/force # Add or remove newline between @implementation and '{'. nl_oc_implementation_brace = ignore # ignore/add/remove/force # Add or remove newlines at the start of the file. nl_start_of_file = remove # ignore/add/remove/force # The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force'. nl_start_of_file_min = 0 # unsigned number # Add or remove newline at the end of the file. nl_end_of_file = force # ignore/add/remove/force # The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force'). nl_end_of_file_min = 1 # unsigned number # Add or remove newline between '=' and '{'. nl_assign_brace = ignore # ignore/add/remove/force # Add or remove newline between '=' and '[' (D only). nl_assign_square = ignore # ignore/add/remove/force # Add or remove newline between '[]' and '{'. nl_tsquare_brace = ignore # ignore/add/remove/force # Add or remove newline after '= [' (D only). Will also affect the newline before the ']'. nl_after_square_assign = ignore # ignore/add/remove/force # The number of blank lines after a block of variable definitions at the top of a function body # 0 = No change (default). nl_func_var_def_blk = 0 # unsigned number # The number of newlines before a block of typedefs # 0 = No change (default) # is overridden by the option 'nl_after_access_spec'. nl_typedef_blk_start = 0 # unsigned number # The number of newlines after a block of typedefs # 0 = No change (default). nl_typedef_blk_end = 0 # unsigned number # The maximum consecutive newlines within a block of typedefs # 0 = No change (default). nl_typedef_blk_in = 0 # unsigned number # The number of newlines before a block of variable definitions not at the top of a function body # 0 = No change (default) # is overridden by the option 'nl_after_access_spec'. nl_var_def_blk_start = 0 # unsigned number # The number of newlines after a block of variable definitions not at the top of a function body # 0 = No change (default). nl_var_def_blk_end = 0 # unsigned number # The maximum consecutive newlines within a block of variable definitions # 0 = No change (default). nl_var_def_blk_in = 0 # unsigned number # Add or remove newline between a function call's ')' and '{', as in: # list_for_each(item, &list) { }. nl_fcall_brace = ignore # ignore/add/remove/force # Add or remove newline between 'enum' and '{'. nl_enum_brace = force # ignore/add/remove/force # Add or remove newline between 'enum' and 'class'. nl_enum_class = remove # ignore/add/remove/force # Add or remove newline between 'enum class' and the identifier. nl_enum_class_identifier = remove # ignore/add/remove/force # Add or remove newline between 'enum class' type and ':'. nl_enum_identifier_colon = remove # ignore/add/remove/force # Add or remove newline between 'enum class identifier :' and 'type' and/or 'type'. nl_enum_colon_type = remove # ignore/add/remove/force # Add or remove newline between 'struct and '{'. nl_struct_brace = force # ignore/add/remove/force # Add or remove newline between 'union' and '{'. nl_union_brace = remove # ignore/add/remove/force # Add or remove newline between 'if' and '{'. nl_if_brace = remove # ignore/add/remove/force # Add or remove newline between '}' and 'else'. nl_brace_else = remove # ignore/add/remove/force # Add or remove newline between 'else if' and '{' # If set to ignore, nl_if_brace is used instead. nl_elseif_brace = ignore # ignore/add/remove/force # Add or remove newline between 'else' and '{'. nl_else_brace = remove # ignore/add/remove/force # Add or remove newline between 'else' and 'if'. nl_else_if = remove # ignore/add/remove/force # Add or remove newline before 'if'/'else if' closing parenthesis. nl_before_if_closing_paren = remove # ignore/add/remove/force # Add or remove newline between '}' and 'finally'. nl_brace_finally = remove # ignore/add/remove/force # Add or remove newline between 'finally' and '{'. nl_finally_brace = remove # ignore/add/remove/force # Add or remove newline between 'try' and '{'. nl_try_brace = remove # ignore/add/remove/force # Add or remove newline between get/set and '{'. nl_getset_brace = ignore # ignore/add/remove/force # Add or remove newline between 'for' and '{'. nl_for_brace = remove # ignore/add/remove/force # Add or remove newline between 'catch' and '{'. nl_catch_brace = remove # ignore/add/remove/force # Add or remove newline between '@catch' and '{'. # If set to ignore, nl_catch_brace is used. nl_oc_catch_brace = ignore # ignore/add/remove/force # Add or remove newline between '}' and 'catch'. nl_brace_catch = remove # ignore/add/remove/force # Add or remove newline between '}' and 'catch'. # If set to ignore, nl_brace_catch is used. nl_oc_brace_catch = ignore # ignore/add/remove/force # Add or remove newline between '}' and ']'. nl_brace_square = ignore # ignore/add/remove/force # Add or remove newline between '}' and ')' in a function invocation. nl_brace_fparen = ignore # ignore/add/remove/force # Add or remove newline between 'while' and '{'. nl_while_brace = remove # ignore/add/remove/force # Add or remove newline between 'scope (x)' and '{' (D). nl_scope_brace = ignore # ignore/add/remove/force # Add or remove newline between 'unittest' and '{' (D). nl_unittest_brace = ignore # ignore/add/remove/force # Add or remove newline between 'version (x)' and '{' (D). nl_version_brace = ignore # ignore/add/remove/force # Add or remove newline between 'using' and '{'. nl_using_brace = ignore # ignore/add/remove/force # Add or remove newline between two open or close braces. # Due to general newline/brace handling, REMOVE may not work. nl_brace_brace = ignore # ignore/add/remove/force # Add or remove newline between 'do' and '{'. nl_do_brace = remove # ignore/add/remove/force # Add or remove newline between '}' and 'while' of 'do' statement. nl_brace_while = remove # ignore/add/remove/force # Add or remove newline between 'switch' and '{'. nl_switch_brace = remove # ignore/add/remove/force # Add or remove newline between 'synchronized' and '{'. nl_synchronized_brace = remove # ignore/add/remove/force # Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc. # Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch and nl_catch_brace. nl_multi_line_cond = true # false/true # Force a newline in a define after the macro name for multi-line defines. nl_multi_line_define = false # false/true # Whether to put a newline before 'case' statement, not after the first 'case'. nl_before_case = false # false/true # Add or remove newline between ')' and 'throw'. nl_before_throw = ignore # ignore/add/remove/force # Whether to put a newline after 'case' statement. nl_after_case = false # false/true # Add or remove a newline between a case ':' and '{'. Overrides nl_after_case. nl_case_colon_brace = ignore # ignore/add/remove/force # Newline between namespace and {. nl_namespace_brace = force # ignore/add/remove/force # Add or remove newline between 'template<>' and whatever follows. nl_template_class = force # ignore/add/remove/force # Add or remove newline between 'class' and '{'. nl_class_brace = force # ignore/add/remove/force # Add or remove newline before/after each ',' in the base class list, # (tied to pos_class_comma). nl_class_init_args = ignore # ignore/add/remove/force # Add or remove newline after each ',' in the constructor member initialization. # Related to nl_constr_colon, pos_constr_colon and pos_constr_comma. nl_constr_init_args = ignore # ignore/add/remove/force # Add or remove newline before first element, after comma, and after last element in enum. nl_enum_own_lines = ignore # ignore/add/remove/force # Add or remove newline between return type and function name in a function definition. nl_func_type_name = ignore # ignore/add/remove/force # Add or remove newline between return type and function name inside a class {} # Uses nl_func_type_name or nl_func_proto_type_name if set to ignore. nl_func_type_name_class = ignore # ignore/add/remove/force # Add or remove newline between class specification and '::' in 'void A::f() { }' # Only appears in separate member implementation (does not appear with in-line implmementation). nl_func_class_scope = remove # ignore/add/remove/force # Add or remove newline between function scope and name # Controls the newline after '::' in 'void A::f() { }'. nl_func_scope_name = remove # ignore/add/remove/force # Add or remove newline between return type and function name in a prototype. nl_func_proto_type_name = ignore # ignore/add/remove/force # Add or remove newline between a function name and the opening '(' in the declaration. nl_func_paren = remove # ignore/add/remove/force # Overrides nl_func_paren for functions with no parameters. nl_func_paren_empty = remove # ignore/add/remove/force # Add or remove newline between a function name and the opening '(' in the definition. nl_func_def_paren = remove # ignore/add/remove/force # Overrides nl_func_def_paren for functions with no parameters. nl_func_def_paren_empty = remove # ignore/add/remove/force # Add or remove newline between a function name and the opening '(' in the call nl_func_call_paren = remove # ignore/add/remove/force # Overrides nl_func_call_paren for functions with no parameters. nl_func_call_paren_empty = remove # ignore/add/remove/force # Add or remove newline after '(' in a function declaration. nl_func_decl_start = ignore # ignore/add/remove/force # Add or remove newline after '(' in a function definition. nl_func_def_start = ignore # ignore/add/remove/force # Overrides nl_func_decl_start when there is only one parameter. nl_func_decl_start_single = ignore # ignore/add/remove/force # Overrides nl_func_def_start when there is only one parameter. nl_func_def_start_single = ignore # ignore/add/remove/force # Whether to add newline after '(' in a function declaration if '(' and ')' are in different lines. nl_func_decl_start_multi_line = true # false/true # Whether to add newline after '(' in a function definition if '(' and ')' are in different lines. nl_func_def_start_multi_line = true # false/true # Add or remove newline after each ',' in a function declaration. nl_func_decl_args = ignore # ignore/add/remove/force # Add or remove newline after each ',' in a function definition. nl_func_def_args = ignore # ignore/add/remove/force # Whether to add newline after each ',' in a function declaration if '(' and ')' are in different lines. nl_func_decl_args_multi_line = false # false/true # Whether to add newline after each ',' in a function definition if '(' and ')' are in different lines. nl_func_def_args_multi_line = false # false/true # Add or remove newline before the ')' in a function declaration. nl_func_decl_end = ignore # ignore/add/remove/force # Add or remove newline before the ')' in a function definition. nl_func_def_end = ignore # ignore/add/remove/force # Overrides nl_func_decl_end when there is only one parameter. nl_func_decl_end_single = ignore # ignore/add/remove/force # Overrides nl_func_def_end when there is only one parameter. nl_func_def_end_single = ignore # ignore/add/remove/force # Whether to add newline before ')' in a function declaration if '(' and ')' are in different lines. nl_func_decl_end_multi_line = false # false/true # Whether to add newline before ')' in a function definition if '(' and ')' are in different lines. nl_func_def_end_multi_line = false # false/true # Add or remove newline between '()' in a function declaration. nl_func_decl_empty = ignore # ignore/add/remove/force # Add or remove newline between '()' in a function definition. nl_func_def_empty = ignore # ignore/add/remove/force # Add or remove newline between '()' in a function call. nl_func_call_empty = ignore # ignore/add/remove/force # Whether to add newline after '(' in a function call if '(' and ')' are in different lines. nl_func_call_start_multi_line = true # false/true # Whether to add newline after each ',' in a function call if '(' and ')' are in different lines. nl_func_call_args_multi_line = false # false/true # Whether to add newline before ')' in a function call if '(' and ')' are in different lines. nl_func_call_end_multi_line = false # false/true # Whether to put each OC message parameter on a separate line # See nl_oc_msg_leave_one_liner. nl_oc_msg_args = false # false/true # Add or remove newline between function signature and '{'. nl_fdef_brace = force # ignore/add/remove/force # Add or remove newline between C++11 lambda signature and '{'. nl_cpp_ldef_brace = ignore # ignore/add/remove/force # Add or remove a newline between the return keyword and return expression. nl_return_expr = ignore # ignore/add/remove/force # Whether to put a newline after semicolons, except in 'for' statements. nl_after_semicolon = false # false/true # Java: Control the newline between the ')' and '{{' of the double brace initializer. nl_paren_dbrace_open = ignore # ignore/add/remove/force # Whether to put a newline after the type in an unnamed temporary direct-list-initialization. nl_type_brace_init_lst = ignore # ignore/add/remove/force # Whether to put a newline after open brace in an unnamed temporary direct-list-initialization. nl_type_brace_init_lst_open = ignore # ignore/add/remove/force # Whether to put a newline before close brace in an unnamed temporary direct-list-initialization. nl_type_brace_init_lst_close = ignore # ignore/add/remove/force # Whether to put a newline after brace open. # This also adds a newline before the matching brace close. nl_after_brace_open = false # false/true # If nl_after_brace_open and nl_after_brace_open_cmt are True, a newline is # placed between the open brace and a trailing single-line comment. nl_after_brace_open_cmt = false # false/true # Whether to put a newline after a virtual brace open with a non-empty body. # These occur in un-braced if/while/do/for statement bodies. nl_after_vbrace_open = false # false/true # Whether to put a newline after a virtual brace open with an empty body. # These occur in un-braced if/while/do/for statement bodies. nl_after_vbrace_open_empty = false # false/true # Whether to put a newline after a brace close. # Does not apply if followed by a necessary ';'. nl_after_brace_close = false # false/true # Whether to put a newline after a virtual brace close. # Would add a newline before return in: 'if (foo) a++; return;'. nl_after_vbrace_close = true # false/true # Control the newline between the close brace and 'b' in: 'struct { int a; } b;' # Affects enums, unions and structures. If set to ignore, uses nl_after_brace_close. nl_brace_struct_var = ignore # ignore/add/remove/force # Whether to alter newlines in '#define' macros. nl_define_macro = false # false/true # Whether to alter newlines between consecutive paren closes, # The number of closing paren in a line will depend on respective open paren lines nl_squeeze_paren_close = false # false/true # Whether to remove blanks after '#ifxx' and '#elxx', or before '#elxx' and '#endif'. Does not affect top-level #ifdefs. nl_squeeze_ifdef = false # false/true # Makes the nl_squeeze_ifdef option affect the top-level #ifdefs as well. nl_squeeze_ifdef_top_level = false # false/true # Add or remove blank line before 'if'. nl_before_if = ignore # ignore/add/remove/force # Add or remove blank line after 'if' statement. # Add/Force work only if the next token is not a closing brace. nl_after_if = ignore # ignore/add/remove/force # Add or remove blank line before 'for'. nl_before_for = ignore # ignore/add/remove/force # Add or remove blank line after 'for' statement. nl_after_for = ignore # ignore/add/remove/force # Add or remove blank line before 'while'. nl_before_while = ignore # ignore/add/remove/force # Add or remove blank line after 'while' statement. nl_after_while = ignore # ignore/add/remove/force # Add or remove blank line before 'switch'. nl_before_switch = ignore # ignore/add/remove/force # Add or remove blank line after 'switch' statement. nl_after_switch = ignore # ignore/add/remove/force # Add or remove blank line before 'synchronized'. nl_before_synchronized = ignore # ignore/add/remove/force # Add or remove blank line after 'synchronized' statement. nl_after_synchronized = ignore # ignore/add/remove/force # Add or remove blank line before 'do'. nl_before_do = ignore # ignore/add/remove/force # Add or remove blank line after 'do/while' statement. nl_after_do = ignore # ignore/add/remove/force # Whether to double-space commented-entries in struct/union/enum. nl_ds_struct_enum_cmt = false # false/true # force nl before } of a struct/union/enum # (lower priority than 'eat_blanks_before_close_brace'). nl_ds_struct_enum_close_brace = false # false/true # Add or remove blank line before 'func_class_def'. nl_before_func_class_def = 0 # unsigned number # Add or remove blank line before 'func_class_proto'. nl_before_func_class_proto = 0 # unsigned number # Add or remove a newline before/after a class colon, # (tied to pos_class_colon). nl_class_colon = ignore # ignore/add/remove/force # Add or remove a newline around a class constructor colon. # Related to nl_constr_init_args, pos_constr_colon and pos_constr_comma. nl_constr_colon = force # ignore/add/remove/force # If true turns two liner namespace to one liner,else will make then four liners nl_namespace_two_to_one_liner = false # false/true # Change simple unbraced if statements into a one-liner # 'if(b)\n i++;' => 'if(b) i++;'. nl_create_if_one_liner = false # false/true # Change simple unbraced for statements into a one-liner # 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);'. nl_create_for_one_liner = false # false/true # Change simple unbraced while statements into a one-liner # 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);'. nl_create_while_one_liner = false # false/true # Change simple 4,3,2 liner function def statements into a one-liner nl_create_func_def_one_liner = false # false/true # Change a one-liner if statement into simple unbraced if # 'if(b) i++;' => 'if(b)\n i++;'. nl_split_if_one_liner = false # false/true # Change a one-liner for statement into simple unbraced for # 'for (i=0;<5;i++) foo(i);' => 'for (i=0;<5;i++)\n foo(i);'. nl_split_for_one_liner = false # false/true # Change a one-liner while statement into simple unbraced while # 'while (i<5) foo(i++);' => 'while (i<5)\n foo(i++);'. nl_split_while_one_liner = false # false/true # # Blank line options # # The maximum consecutive newlines (3 = 2 blank lines). nl_max = 3 # unsigned number # The maximum consecutive newlines in function. nl_max_blank_in_func = 0 # unsigned number # The number of newlines after a function prototype, if followed by another function prototype. nl_after_func_proto = 0 # unsigned number # The number of newlines after a function prototype, if not followed by another function prototype. nl_after_func_proto_group = 0 # unsigned number # The number of newlines after a function class prototype, if followed by another function class prototype. nl_after_func_class_proto = 0 # unsigned number # The number of newlines after a function class prototype, if not followed by another function class prototype. nl_after_func_class_proto_group = 0 # unsigned number # Whether one-line method definitions inside a class body should be treated # as if they were prototypes for the purposes of adding newlines. # # Requires nl_class_leave_one_liners=true. Overrides nl_before_func_body_def # and nl_before_func_class_def for one-liners. nl_class_leave_one_liner_groups = false # true/false # The number of newlines before a multi-line function def body. nl_before_func_body_def = 0 # unsigned number # The number of newlines before a multi-line function prototype body. nl_before_func_body_proto = 0 # unsigned number # The number of newlines after '}' of a multi-line function body. nl_after_func_body = 0 # unsigned number # The number of newlines after '}' of a multi-line function body in a class declaration. nl_after_func_body_class = 0 # unsigned number # The number of newlines after '}' of a single line function body. nl_after_func_body_one_liner = 0 # unsigned number # The minimum number of newlines before a multi-line comment. # Doesn't apply if after a brace open or another multi-line comment. nl_before_block_comment = 0 # unsigned number # The minimum number of newlines before a single-line C comment. # Doesn't apply if after a brace open or other single-line C comments. nl_before_c_comment = 0 # unsigned number # The minimum number of newlines before a CPP comment. # Doesn't apply if after a brace open or other CPP comments. nl_before_cpp_comment = 0 # unsigned number # Whether to force a newline after a multi-line comment. nl_after_multiline_comment = false # false/true # Whether to force a newline after a label's colon. nl_after_label_colon = false # false/true # The number of newlines after '}' or ';' of a struct/enum/union definition. nl_after_struct = 0 # unsigned number # The number of newlines before a class definition. nl_before_class = 0 # unsigned number # The number of newlines after '}' or ';' of a class definition. nl_after_class = 0 # unsigned number # The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. # Will not change the newline count if after a brace open. # 0 = No change. nl_before_access_spec = 2 # unsigned number # The number of newlines after a 'private:', 'public:', 'protected:', 'signals:' or 'slots:' label. # 0 = No change. # Overrides 'nl_typedef_blk_start' and 'nl_var_def_blk_start'. nl_after_access_spec = 1 # unsigned number # The number of newlines between a function def and the function comment. # 0 = No change. nl_comment_func_def = 0 # unsigned number # The number of newlines after a try-catch-finally block that isn't followed by a brace close. # 0 = No change. nl_after_try_catch_finally = 0 # unsigned number # The number of newlines before and after a property, indexer or event decl. # 0 = No change. nl_around_cs_property = 0 # unsigned number # The number of newlines between the get/set/add/remove handlers in C#. # 0 = No change. nl_between_get_set = 0 # unsigned number # Add or remove newline between C# property and the '{'. nl_property_brace = ignore # ignore/add/remove/force # The number of newlines after '{' of a namespace. This also adds newlines # before the matching '}'. # # 0 = Apply eat_blanks_after_open_brace or eat_blanks_before_close_brace if # applicable, otherwise no change. # # Overrides eat_blanks_after_open_brace and eat_blanks_before_close_brace. nl_inside_namespace = 0 # unsigned number # Whether to remove blank lines after '{'. eat_blanks_after_open_brace = false # false/true # Whether to remove blank lines before '}'. eat_blanks_before_close_brace = false # false/true # How aggressively to remove extra newlines not in preproc. # 0: No change # 1: Remove most newlines not handled by other config # 2: Remove all newlines and reformat completely by config nl_remove_extra_newlines = 0 # unsigned number # Whether to put a blank line before 'return' statements, unless after an open brace. nl_before_return = false # false/true # Whether to put a blank line after 'return' statements, unless followed by a close brace. nl_after_return = false # false/true # Whether to put a newline after a Java annotation statement. # Only affects annotations that are after a newline. nl_after_annotation = ignore # ignore/add/remove/force # Controls the newline between two annotations. nl_between_annotation = ignore # ignore/add/remove/force # # Positioning options # # The position of arithmetic operators in wrapped expressions. pos_arith = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of assignment in wrapped expressions. # Do not affect '=' followed by '{'. pos_assign = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of boolean operators in wrapped expressions. pos_bool = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of comparison operators in wrapped expressions. pos_compare = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of conditional (b ? t : f) operators in wrapped expressions. pos_conditional = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of the comma in wrapped expressions. pos_comma = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of the comma in enum entries. pos_enum_comma = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of the comma in the base class list if there are more than one line, # (tied to nl_class_init_args). pos_class_comma = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of the comma in the constructor initialization list. # Related to nl_constr_colon, nl_constr_init_args and pos_constr_colon. pos_constr_comma = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of trailing/leading class colon, between class and base class list # (tied to nl_class_colon). pos_class_colon = lead_force # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of colons between constructor and member initialization, # (tied to nl_constr_colon). # Related to nl_constr_colon, nl_constr_init_args and pos_constr_comma. pos_constr_colon = lead_break # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # # Line Splitting options # # Try to limit code width to N number of columns code_width = 100 # unsigned number # Whether to fully split long 'for' statements at semi-colons. ls_for_split_full = false # false/true # Whether to fully split long function protos/calls at commas. ls_func_split_full = false # false/true # Whether to split lines as close to code_width as possible and ignore some groupings. ls_code_width = false # false/true # # Code alignment (not left column spaces/tabs) # # Whether to keep non-indenting tabs. align_keep_tabs = false # false/true # Whether to use tabs for aligning. align_with_tabs = false # false/true # Whether to bump out to the next tab when aligning. align_on_tabstop = false # false/true # Whether to right-align numbers. align_number_right = false # false/true # Whether to keep whitespace not required for alignment. align_keep_extra_space = false # false/true # Align variable definitions in prototypes and functions. align_func_params = false # false/true # The span for aligning parameter definitions in function on parameter name (0=don't align). align_func_params_span = 0 # unsigned number # The threshold for aligning function parameter definitions (0=no limit). align_func_params_thresh = 0 # unsigned number # The gap for aligning function parameter definitions. align_func_params_gap = 0 # unsigned number # Align parameters in single-line functions that have the same name. # The function names must already be aligned with each other. align_same_func_call_params = false # false/true # The span for aligning function-call parameters for single line functions. # 0 = Don't align (default). align_same_func_call_params_span = 0 # unsigned number # The threshold for aligning function-call parameters for single line # functions. # 0 = No limit (default). align_same_func_call_params_thresh = 0 # unsigned number # The span for aligning variable definitions (0=don't align) align_var_def_span = 0 # unsigned number # How to align the star in variable definitions. # 0=Part of the type 'void * foo;' # 1=Part of the variable 'void *foo;' # 2=Dangling 'void *foo;' align_var_def_star_style = 0 # unsigned number # How to align the '&' in variable definitions. # 0=Part of the type # 1=Part of the variable # 2=Dangling align_var_def_amp_style = 0 # unsigned number # The threshold for aligning variable definitions (0=no limit) align_var_def_thresh = 0 # unsigned number # The gap for aligning variable definitions. align_var_def_gap = 0 # unsigned number # Whether to align the colon in struct bit fields. align_var_def_colon = false # false/true # align variable defs gap for bit colons. align_var_def_colon_gap = 0 # unsigned number # Whether to align any attribute after the variable name. align_var_def_attribute = false # false/true # Whether to align inline struct/enum/union variable definitions. align_var_def_inline = false # false/true # The span for aligning on '=' in assignments (0=don't align) align_assign_span = 0 # unsigned number # The threshold for aligning on '=' in assignments (0=no limit) align_assign_thresh = 0 # unsigned number # How to apply align_assign_span to function declaration "assignments", i.e. # 'virtual void foo() = 0' or '~foo() = {default|delete}'. # 0: Align with other assignments (default) # 1: Align with each other, ignoring regular assignments # 2: Don't align align_assign_decl_func = 0 # unsigned number # The span for aligning on '=' in enums (0=don't align) align_enum_equ_span = 0 # unsigned number # The threshold for aligning on '=' in enums (0=no limit) align_enum_equ_thresh = 0 # unsigned number # The span for aligning class (0=don't align) align_var_class_span = 0 # unsigned number # The threshold for aligning class member definitions (0=no limit). align_var_class_thresh = 0 # unsigned number # The gap for aligning class member definitions. align_var_class_gap = 0 # unsigned number # The span for aligning struct/union (0=don't align) align_var_struct_span = 0 # unsigned number # The threshold for aligning struct/union member definitions (0=no limit) align_var_struct_thresh = 0 # unsigned number # The gap for aligning struct/union member definitions. align_var_struct_gap = 0 # unsigned number # The span for aligning struct initializer values (0=don't align) align_struct_init_span = 0 # unsigned number # The minimum space between the type and the synonym of a typedef. align_typedef_gap = 0 # unsigned number # The span for aligning single-line typedefs (0=don't align). align_typedef_span = 0 # unsigned number # How to align typedef'd functions with other typedefs # 0: Don't mix them at all # 1: align the open paren with the types # 2: align the function type name with the other type names align_typedef_func = 0 # unsigned number # Controls the positioning of the '*' in typedefs. Just try it. # 0: Align on typedef type, ignore '*' # 1: The '*' is part of type name: typedef int *pint; # 2: The '*' is part of the type, but dangling: typedef int *pint; align_typedef_star_style = 0 # unsigned number # Controls the positioning of the '&' in typedefs. Just try it. # 0: Align on typedef type, ignore '&' # 1: The '&' is part of type name: typedef int &pint; # 2: The '&' is part of the type, but dangling: typedef int &pint; align_typedef_amp_style = 0 # unsigned number # The span for aligning comments that end lines (0=don't align) align_right_cmt_span = 0 # unsigned number # If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment. align_right_cmt_mix = false # false/true # Whether to only align trailing comments that are at the same brace level. align_right_cmt_same_level = false # true/false # If a trailing comment is more than this number of columns away from the text it follows, # it will qualify for being aligned. This has to be > 0 to do anything. align_right_cmt_gap = 0 # unsigned number # Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore) align_right_cmt_at_col = 0 # unsigned number # The span for aligning function prototypes (0=don't align). align_func_proto_span = 0 # unsigned number # Minimum gap between the return type and the function name. align_func_proto_gap = 0 # unsigned number # Align function protos on the 'operator' keyword instead of what follows. align_on_operator = false # false/true # Whether to mix aligning prototype and variable declarations. # If True, align_var_def_XXX options are used instead of align_func_proto_XXX options. align_mix_var_proto = false # false/true # Align single-line functions with function prototypes, uses align_func_proto_span. align_single_line_func = false # false/true # Aligning the open brace of single-line functions. # Requires align_single_line_func=True, uses align_func_proto_span. align_single_line_brace = false # false/true # Gap for align_single_line_brace. align_single_line_brace_gap = 0 # unsigned number # The span for aligning ObjC msg spec (0=don't align) align_oc_msg_spec_span = 0 # unsigned number # Whether to align macros wrapped with a backslash and a newline. # This will not work right if the macro contains a multi-line comment. align_nl_cont = false # false/true # # Align macro functions and variables together. align_pp_define_together = false # false/true # The minimum space between label and value of a preprocessor define. align_pp_define_gap = 0 # unsigned number # The span for aligning on '#define' bodies (0=don't align, other=number of lines including comments between blocks) align_pp_define_span = 0 # unsigned number # Align lines that start with '<<' with previous '<<'. Default=True. align_left_shift = true # false/true # Align text after asm volatile () colons. align_asm_colon = false # false/true # Span for aligning parameters in an Obj-C message call on the ':' (0=don't align) align_oc_msg_colon_span = 0 # unsigned number # If True, always align with the first parameter, even if it is too short. align_oc_msg_colon_first = false # false/true # Aligning parameters in an Obj-C '+' or '-' declaration on the ':'. align_oc_decl_colon = false # false/true # # Comment modifications # # Try to wrap comments at cmt_width columns cmt_width = 0 # unsigned number # Set the comment reflow mode (Default=0) # 0: no reflowing (apart from the line wrapping due to cmt_width) # 1: no touching at all # 2: full reflow cmt_reflow_mode = 0 # unsigned number # Whether to convert all tabs to spaces in comments. Default is to leave tabs inside comments alone, unless used for indenting. cmt_convert_tab_to_spaces = false # false/true # If False, disable all multi-line comment changes, including cmt_width. keyword substitution and leading chars. # Default=True. cmt_indent_multi = false # false/true # Whether to group c-comments that look like they are in a block. cmt_c_group = false # false/true # Whether to put an empty '/*' on the first line of the combined c-comment. cmt_c_nl_start = false # false/true # Whether to put a newline before the closing '*/' of the combined c-comment. cmt_c_nl_end = false # false/true # Whether to group cpp-comments that look like they are in a block. cmt_cpp_group = false # false/true # Whether to put an empty '/*' on the first line of the combined cpp-comment. cmt_cpp_nl_start = false # false/true # Whether to put a newline before the closing '*/' of the combined cpp-comment. cmt_cpp_nl_end = false # false/true # Whether to change cpp-comments into c-comments. cmt_cpp_to_c = false # false/true # Whether to put a star on subsequent comment lines. cmt_star_cont = false # false/true # The number of spaces to insert at the start of subsequent comment lines. cmt_sp_before_star_cont = 0 # unsigned number # The number of spaces to insert after the star on subsequent comment lines. cmt_sp_after_star_cont = 0 # number # For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of # the comment are the same length. Default=True. cmt_multi_check_last = true # false/true # For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of # the comment are the same length AND if the length is bigger as the first_len minimum. Default=4 cmt_multi_first_len_minimum = 4 # unsigned number # The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. # Will substitute $(filename) with the current file's name. cmt_insert_file_header = "" # string # The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment. # Will substitute $(filename) with the current file's name. cmt_insert_file_footer = "" # string # The filename that contains text to insert before a function implementation if the function isn't preceded with a C/C++ comment. # Will substitute $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. # Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... }. cmt_insert_func_header = "" # string # The filename that contains text to insert before a class if the class isn't preceded with a C/C++ comment. # Will substitute $(class) with the class name. cmt_insert_class_header = "" # string # The filename that contains text to insert before a Obj-C message specification if the method isn't preceded with a C/C++ comment. # Will substitute $(message) with the function name and $(javaparam) with the javadoc @param and @return stuff. cmt_insert_oc_msg_header = "" # string # If a preprocessor is encountered when stepping backwards from a function name, then # this option decides whether the comment should be inserted. # Affects cmt_insert_oc_msg_header, cmt_insert_func_header and cmt_insert_class_header. cmt_insert_before_preproc = false # false/true # If a function is declared inline to a class definition, then # this option decides whether the comment should be inserted. # Affects cmt_insert_func_header. cmt_insert_before_inlines = true # false/true # If the function is a constructor/destructor, then # this option decides whether the comment should be inserted. # Affects cmt_insert_func_header. cmt_insert_before_ctor_dtor = false # false/true # # Code modifying options (non-whitespace) # # Add or remove braces on single-line 'do' statement. mod_full_brace_do = force # ignore/add/remove/force # Add or remove braces on single-line 'for' statement. mod_full_brace_for = force # ignore/add/remove/force # Add or remove braces on single-line function definitions. (Pawn). mod_full_brace_function = force # ignore/add/remove/force # Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. mod_full_brace_if = force # ignore/add/remove/force # Make all if/elseif/else statements in a chain be braced or not. Overrides mod_full_brace_if. # If any must be braced, they are all braced. If all can be unbraced, then the braces are removed. mod_full_brace_if_chain = false # false/true # Make all if/elseif/else statements with at least one 'else' or 'else if' fully braced. # If mod_full_brace_if_chain is used together with this option, all if-else chains will get braces, # and simple 'if' statements will lose them (if possible). mod_full_brace_if_chain_only = false # false/true # Don't remove braces around statements that span N newlines mod_full_brace_nl = 0 # unsigned number # Blocks removal of braces if the parenthesis of if/for/while/.. span multiple lines. mod_full_brace_nl_block_rem_mlcond = false # false/true # Add or remove braces on single-line 'while' statement. mod_full_brace_while = force # ignore/add/remove/force # Add or remove braces on single-line 'using ()' statement. mod_full_brace_using = force # ignore/add/remove/force # Add or remove unnecessary paren on 'return' statement. mod_paren_on_return = remove # ignore/add/remove/force # Whether to change optional semicolons to real semicolons. mod_pawn_semicolon = true # false/true # Add parens on 'while' and 'if' statement around bools. mod_full_paren_if_bool = false # false/true # Whether to remove superfluous semicolons. mod_remove_extra_semicolon = true # false/true # If a function body exceeds the specified number of newlines and doesn't have a comment after # the close brace, a comment will be added. mod_add_long_function_closebrace_comment = 0 # unsigned number # If a namespace body exceeds the specified number of newlines and doesn't have a comment after # the close brace, a comment will be added. mod_add_long_namespace_closebrace_comment = 0 # unsigned number # If a class body exceeds the specified number of newlines and doesn't have a comment after # the close brace, a comment will be added. mod_add_long_class_closebrace_comment = 0 # unsigned number # If a switch body exceeds the specified number of newlines and doesn't have a comment after # the close brace, a comment will be added. mod_add_long_switch_closebrace_comment = 0 # unsigned number # If an #ifdef body exceeds the specified number of newlines and doesn't have a comment after # the #endif, a comment will be added. mod_add_long_ifdef_endif_comment = 0 # unsigned number # If an #ifdef or #else body exceeds the specified number of newlines and doesn't have a comment after # the #else, a comment will be added. mod_add_long_ifdef_else_comment = 0 # unsigned number # If True, will sort consecutive single-line 'import' statements [Java, D]. mod_sort_import = false # false/true # If True, will sort consecutive single-line 'using' statements [C#]. mod_sort_using = false # false/true # If True, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] # This is generally a bad idea, as it may break your code. mod_sort_include = false # false/true # If True, it will move a 'break' that appears after a fully braced 'case' before the close brace. mod_move_case_break = false # false/true # Will add or remove the braces around a fully braced case statement. # Will only remove the braces if there are no variable declarations in the block. mod_case_brace = ignore # ignore/add/remove/force # If True, it will remove a void 'return;' that appears as the last statement in a function. mod_remove_empty_return = true # false/true # Add or remove the comma after the last value of an enumeration. mod_enum_last_comma = ignore # ignore/add/remove/force # If True, it will organize the properties (Obj-C). mod_sort_oc_properties = false # false/true # Determines weight of class property modifier (Obj-C). mod_sort_oc_property_class_weight = 0 # number # Determines weight of atomic, nonatomic (Obj-C). mod_sort_oc_property_thread_safe_weight = 0 # number # Determines weight of readwrite (Obj-C). mod_sort_oc_property_readwrite_weight = 0 # number # Determines weight of reference type (retain, copy, assign, weak, strong) (Obj-C). mod_sort_oc_property_reference_weight = 0 # number # Determines weight of getter type (getter=) (Obj-C). mod_sort_oc_property_getter_weight = 0 # number # Determines weight of setter type (setter=) (Obj-C). mod_sort_oc_property_setter_weight = 0 # number # Determines weight of nullability type (nullable, nonnull, null_unspecified, null_resettable) (Obj-C). mod_sort_oc_property_nullability_weight = 0 # number # # Preprocessor options # # Control indent of preprocessors inside #if blocks at brace level 0 (file-level). pp_indent = ignore # ignore/add/remove/force # Whether to indent #if/#else/#endif at the brace level (True) or from column 1 (False). pp_indent_at_level = false # false/true # Specifies the number of columns to indent preprocessors per level at brace level 0 (file-level). # If pp_indent_at_level=False, specifies the number of columns to indent preprocessors per level at brace level > 0 (function-level). # Default=1. pp_indent_count = 2 # unsigned number # Add or remove space after # based on pp_level of #if blocks. pp_space = ignore # ignore/add/remove/force # Sets the number of spaces added with pp_space. pp_space_count = 0 # unsigned number # The indent for #region and #endregion in C# and '#pragma region' in C/C++. pp_indent_region = 0 # number # Whether to indent the code between #region and #endregion. pp_region_indent_code = false # false/true # If pp_indent_at_level=True, sets the indent for #if, #else and #endif when not at file-level. # 0: indent preprocessors using output_tab_size. # >0: column at which all preprocessors will be indented. pp_indent_if = 0 # number # Control whether to indent the code between #if, #else and #endif. pp_if_indent_code = false # false/true # Whether to indent '#define' at the brace level (True) or from column 1 (false). pp_define_at_level = false # false/true # Whether to ignore the '#define' body while formatting. pp_ignore_define_body = false # false/true # Whether to indent case statements between #if, #else, and #endif. # Only applies to the indent of the preprocesser that the case statements directly inside of. pp_indent_case = true # false/true # Whether to indent whole function definitions between #if, #else, and #endif. # Only applies to the indent of the preprocesser that the function definition is directly inside of. pp_indent_func_def = true # false/true # Whether to indent extern C blocks between #if, #else, and #endif. # Only applies to the indent of the preprocesser that the extern block is directly inside of. pp_indent_extern = true # false/true # Whether to indent braces directly inside #if, #else, and #endif. # Only applies to the indent of the preprocesser that the braces are directly inside of. pp_indent_brace = true # false/true # # Sort includes options # # The regex for include category with priority 0. include_category_0 = "" # string # The regex for include category with priority 1. include_category_1 = "" # string # The regex for include category with priority 2. include_category_2 = "" # string # # Use or Do not Use options # # True: indent_func_call_param will be used (default) # False: indent_func_call_param will NOT be used. use_indent_func_call_param = true # false/true # The value of the indentation for a continuation line is calculate differently if the statement is: # a declaration: your case with QString fileName ... # an assignment: your case with pSettings = new QSettings( ... # At the second case the indentation value might be used twice: # at the assignment # at the function call (if present) # To prevent the double use of the indentation value, use this option with the value 'True'. # True: indent_continue will be used only once # False: indent_continue will be used every time (default). use_indent_continue_only_once = false # false/true # the value might be used twice: # at the assignment # at the opening brace # To prevent the double use of the indentation value, use this option with the value 'True'. # True: indentation will be used only once # False: indentation will be used every time (default). indent_cpp_lambda_only_once = false # false/true # SIGNAL/SLOT Qt macros have special formatting options. See options_for_QT.cpp for details. # Default=True. use_options_overriding_for_qt_macros = true # false/true # # Warn levels - 1: error, 2: warning (default), 3: note # # Warning is given if doing tab-to-\t replacement and we have found one in a C# verbatim string literal. warn_level_tabs_found_in_verbatim_string_literals = 2 # unsigned number # Meaning of the settings: # Ignore - do not do any changes # Add - makes sure there is 1 or more space/brace/newline/etc # Force - makes sure there is exactly 1 space/brace/newline/etc, # behaves like Add in some contexts # Remove - removes space/brace/newline/etc # # # - Token(s) can be treated as specific type(s) with the 'set' option: # `set tokenType tokenString [tokenString...]` # # Example: # `set BOOL __AND__ __OR__` # # tokenTypes are defined in src/token_enum.h, use them without the # 'CT_' prefix: 'CT_BOOL' -> 'BOOL' # # # - Token(s) can be treated as type(s) with the 'type' option. # `type tokenString [tokenString...]` # # Example: # `type int c_uint_8 Rectangle` # # This can also be achieved with `set TYPE int c_uint_8 Rectangle` # # # To embed whitespace in tokenStrings use the '\' escape character, or quote # the tokenStrings. These quotes are supported: "'` # # # - Support for the auto detection of languages through the file ending can be # added using the 'file_ext' command. # `file_ext langType langString [langString..]` # # Example: # `file_ext CPP .ch .cxx .cpp.in` # # langTypes are defined in uncrusify_types.h in the lang_flag_e enum, use # them without the 'LANG_' prefix: 'LANG_CPP' -> 'CPP' # # # - Custom macro-based indentation can be set up using 'macro-open', # 'macro-else' and 'macro-close'. # `(macro-open | macro-else | macro-close) tokenString` # # Example: # `macro-open BEGIN_TEMPLATE_MESSAGE_MAP` # `macro-open BEGIN_MESSAGE_MAP` # `macro-close END_MESSAGE_MAP` # # # option(s) with 'not default' value: 0 # ament_lint-0.12.0/ament_uncrustify/ament_uncrustify/main.py000077500000000000000000000363311420377356500242450ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse from collections import defaultdict from configparser import ConfigParser import difflib import filecmp import glob import os import re import shutil import subprocess import sys import tempfile import time from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr def main(argv=sys.argv[1:]): config_file = os.path.join( os.path.dirname(__file__), 'configuration', 'ament_code_style.cfg') c_extensions = ['c', 'cc', 'h', 'hh'] cpp_extensions = ['cpp', 'cxx', 'hpp', 'hxx'] parser = argparse.ArgumentParser( description='Check code style using uncrustify.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '-c', metavar='CFG', default=config_file, dest='config_file', help='The config file') parser.add_argument( '--linelength', metavar='N', type=int, help='The maximum line length (default: specified in the config file)') parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files ending ' 'in %s will be considered.' % ', '.join([ "'.%s'" % e for e in sorted(c_extensions + cpp_extensions)])) parser.add_argument( '--exclude', metavar='filename', nargs='*', default=[], help='Exclude specific file names from the check.') parser.add_argument( '--language', choices=['C', 'C++', 'CPP'], help="Passed to uncrustify as '-l ' to force a specific " 'language rather then choosing one based on file extension') parser.add_argument( '--reformat', action='store_true', help='Reformat the files in place') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if not os.path.exists(args.config_file): print("Could not config file '%s'" % args.config_file, file=sys.stderr) return 1 temp_config = None temp_path = None try: if args.linelength is not None: # check if different from config file config = ConfigParser() with open(args.config_file, 'r') as h: config_str = h.read() config.read_string('[DEFAULT]\n' + config_str) code_width = config['DEFAULT']['code_width'] code_width = int(re.split('[ \t#]', code_width, maxsplit=1)[0]) if args.linelength != code_width: # generate temporary config file with custom line length temp_config_fd, args.config_file = tempfile.mkstemp(prefix='uncrustify_') temp_config = os.fdopen(temp_config_fd, 'w') temp_config.write(config_str + '\ncode_width=%d' % args.linelength) temp_config.close() if args.xunit_file: start_time = time.time() # replace language set to 'C++' with 'CPP' to be more consistent with uncrustify if args.language == 'C++': language_ = 'CPP' else: language_ = args.language files_by_language = get_files( args.paths, {'C': c_extensions, 'CPP': cpp_extensions}, exclude_patterns=args.exclude, language=language_) if not files_by_language: print('No files found', file=sys.stderr) return 1 uncrustify_bin = find_executable('uncrustify') if not uncrustify_bin: print("Could not find 'uncrustify' executable", file=sys.stderr) return 1 report = [] temp_path = tempfile.mkdtemp(prefix='uncrustify_') suffix = '.uncrustify' # invoke uncrustify on all files all_input_files = [] all_output_files = [] for language, input_files in files_by_language.items(): all_input_files += input_files output_files = invoke_uncrustify( uncrustify_bin, input_files, args, language, temp_path, suffix) if output_files is None: return 1 all_output_files += output_files # compute diff for filename, modified_filename in sorted(zip(all_input_files, all_output_files)): with open(filename, 'r', encoding='utf-8') as original_file: with open(modified_filename, 'r', encoding='utf-8') as modified_file: diff_lines = list(difflib.unified_diff( original_file.readlines(), modified_file.readlines(), fromfile=filename, tofile=filename + suffix, n=0)) report.append((filename, diff_lines)) if args.reformat: # overwrite original with reformatted file with(open(filename, 'wb')) as original_file: with open(modified_filename, 'rb') as modified_file: original_file.write(modified_file.read()) finally: if temp_config: os.remove(args.config_file) if temp_path and os.path.exists(temp_path): shutil.rmtree(temp_path) # output diffs for (filename, diff_lines) in report: if diff_lines: if not args.reformat: print("Code style divergence in file '%s':" % filename, file=sys.stderr) print('', file=sys.stderr) for line in diff_lines: print(line.rstrip('\r\n'), file=sys.stderr) print('', file=sys.stderr) else: print("Code style divergence in file '%s': reformatted file" % filename) else: print("No code style divergence in file '%s'" % filename) if not args.reformat: print('') # output summary error_count = sum([1 if r[1] else 0 for r in report]) if not error_count: print('No problems found') rc = 0 else: print('%d files with code style divergence' % error_count, file=sys.stderr) rc = 1 # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return rc def find_executable(file_name, additional_paths=None): path = None if additional_paths: path = os.getenv('PATH', os.defpath) path += os.path.pathsep + os.path.pathsep.join(additional_paths) return shutil.which(file_name, path=path) def get_files(paths, extension_types, exclude_patterns=[], language=None): excludes = [] for exclude_pattern in exclude_patterns: excludes.extend(glob.glob(exclude_pattern)) excludes = {os.path.realpath(x) for x in excludes} extensions_with_dot_to_language = { f'.{extension}': language or ext_language for ext_language, extensions in extension_types.items() for extension in extensions } files = defaultdict(list) for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] dirnames.sort() # select files by extension for filename in sorted(filenames): _, ext = os.path.splitext(filename) language = extensions_with_dot_to_language.get(ext, None) if language is not None: filepath = os.path.join(dirpath, filename) if os.path.realpath(filepath) not in excludes: files[language].append( os.path.normpath(os.path.join(dirpath, filename))) if os.path.isfile(path): _, ext = os.path.splitext(path) language = extensions_with_dot_to_language.get(ext, None) if language is not None: if os.path.realpath(path) not in excludes: files[language].append(os.path.normpath(path)) return files def invoke_uncrustify( uncrustify_bin, files, args, language, temp_path, suffix ): if not files: return [] # invoke uncrustify on all files input_files = [os.path.abspath(f) for f in files] # on Windows uncrustify fails to concatenate # the absolute prefix path with the absolute input files # https://github.com/bengardner/uncrustify/issues/364 cwd = None if os.name == 'nt': cwd = os.path.commonprefix(input_files) if not os.path.isdir(cwd): cwd = os.path.dirname(cwd) assert os.path.isdir(cwd), \ 'Could not determine common prefix of input files' input_files = [os.path.relpath(f, start=cwd) for f in input_files] try: cmd = [uncrustify_bin, '-c', args.config_file] if language: cmd += ['-l', language] cmd += [ '--prefix', temp_path, '--suffix', suffix] cmd.extend(input_files) subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: if e.output: print(e.output.decode(), file=sys.stderr) print("The invocation of 'uncrustify' failed with error code %d: %s" % (e.returncode, e), file=sys.stderr) return None if cwd: # input files are relative # prepend temp path, append suffix output_files = [ os.path.join(temp_path, f + suffix) for f in input_files] else: # input files are absolute # remove leading slash, prepend temp path, append suffix output_files = [ os.path.join( temp_path, os.sep.join(f.split(os.sep)[1:]) + suffix ) for f in input_files ] uncrustified_files = output_files i = 1 while True: # identify files which have changed since the latest uncrustify run changed_files = [] for input_filename, output_filename in zip( input_files, uncrustified_files): if cwd and not os.path.isabs(input_filename): input_filename = os.path.join(cwd, input_filename) if not filecmp.cmp(input_filename, output_filename): if output_filename == input_filename + suffix: # for repeated invocations # replace the previous uncrustified file dst_filename = input_filename else: # after first invocation remove suffix # otherwise uncrustify behaves different output_filename_without_suffix = \ output_filename[:-len(suffix)] dst_filename = output_filename_without_suffix if os.path.exists(dst_filename): # on Windows os.rename doesn't replace an existing dst os.remove(dst_filename) os.rename(output_filename, dst_filename) changed_files.append(dst_filename) if not changed_files: break # reinvoke uncrustify for previously changed files input_files = changed_files try: cmd = [uncrustify_bin, '-c', args.config_file] if language: cmd += ['-l', language] cmd += ['--suffix', suffix] cmd.extend(input_files) subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: if e.output: print(e.output, file=sys.stderr) print("The invocation of 'uncrustify' failed with error code %d: " '%s' % (e.returncode, e), file=sys.stderr) return None uncrustified_files = [f + suffix for f in input_files] i += 1 if i >= 5: print("'uncrustify' did not settle on a final result even after " '%d invocations' % i, file=sys.stderr) return None return output_files def get_xunit_content(report, testname, elapsed): test_count = len(report) error_count = sum([1 if r[1] else 0 for r in report]) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for (filename, diff_lines) in report: if diff_lines: # report any diff as a failing testcase data = { 'quoted_location': quoteattr(filename), 'testname': testname, 'quoted_message': quoteattr( 'Diff with %d lines' % len(diff_lines) ), 'cdata': ''.join(diff_lines), } xml += """ """ % data else: # if there is no diff report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % r[0] for r in report])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_uncrustify/doc/000077500000000000000000000000001420377356500201045ustar00rootroot00000000000000ament_lint-0.12.0/ament_uncrustify/doc/index.rst000066400000000000000000000013721420377356500217500ustar00rootroot00000000000000ament_uncrustify ================ Checks the code style of C / C++ source files using `Uncrustify `_. Files with the following extensions are being considered: ``.c``, ``.cc``, ``.cpp``, ``.cxx``, ``.h``, ``.hh``, ``.hpp``, ``.hxx``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_uncrustify [ ...] When using the option ``--reformat`` the proposed changes are applied in place. How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_uncrustify `_. ament_lint-0.12.0/ament_uncrustify/package.xml000066400000000000000000000020231420377356500214510ustar00rootroot00000000000000 ament_uncrustify 0.12.0 The ability to check code against style conventions using uncrustify and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas uncrustify_vendor ament_copyright ament_flake8 ament_pep257 ament_pycodestyle python3-pytest ament_python ament_lint-0.12.0/ament_uncrustify/pytest.ini000066400000000000000000000000351420377356500213660ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_uncrustify/resource/000077500000000000000000000000001420377356500211665ustar00rootroot00000000000000ament_lint-0.12.0/ament_uncrustify/resource/ament_uncrustify000066400000000000000000000000001420377356500244760ustar00rootroot00000000000000ament_lint-0.12.0/ament_uncrustify/setup.py000066400000000000000000000026541420377356500210600ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_uncrustify' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], package_data={'': [ 'configuration/ament_code_style.cfg', ]}, zip_safe=False, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check code style using uncrustify.', long_description="""\ The ability to check code against style conventions using uncrustify and generate xUnit test result files.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_uncrustify = ament_uncrustify.main:main', ], }, ) ament_lint-0.12.0/ament_uncrustify/test/000077500000000000000000000000001420377356500203165ustar00rootroot00000000000000ament_lint-0.12.0/ament_uncrustify/test/cases/000077500000000000000000000000001420377356500214145ustar00rootroot00000000000000ament_lint-0.12.0/ament_uncrustify/test/cases/test.cpp000066400000000000000000000013621420377356500231010ustar00rootroot00000000000000// Copyright 2021 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include int main(int argc, char ** argv) { (void) argc; (void) argv; printf("hello world test package\n"); return 0; } ament_lint-0.12.0/ament_uncrustify/test/test_ament_uncrustify.py000066400000000000000000000034051420377356500253300ustar00rootroot00000000000000# Copyright 2021 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os from ament_uncrustify.main import main cases_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'cases') def test_incorrect_exclusion(): """ Checks that excluding a single filename does not work. `ament_uncrustify --exclude ` should not exclude anything. """ rc = main(argv=[os.path.join(cases_path, 'test.cpp'), '--exclude', 'test.cpp']) assert rc == 0, 'Found errors' def test_correct_exclusion(): """ Checks that excluding a file relatively/absolutely works as expected. `ament_copyright --exclude ` should exclude . """ rc = main( argv=[ os.path.join(cases_path, 'test.cpp'), '--exclude', os.path.join(cases_path, 'test.cpp') ]) assert rc == 1, 'Files were found' def test_wildcard_exclusion(): """A wildcard expression which expands to the relative path of an existing file should work.""" rc = main( argv=[ os.path.join(cases_path, 'test.cpp'), '--exclude', os.path.join(cases_path, '*') ]) assert rc == 1, 'Files were found' ament_lint-0.12.0/ament_uncrustify/test/test_copyright.py000066400000000000000000000014261420377356500237420ustar00rootroot00000000000000# Copyright 2021 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_copyright.main import main import pytest @pytest.mark.copyright @pytest.mark.linter def test_copyright(): rc = main(argv=['.', 'test']) assert rc == 0, 'Found errors' ament_lint-0.12.0/ament_uncrustify/test/test_flake8.py000066400000000000000000000015641420377356500231070ustar00rootroot00000000000000# Copyright 2021 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_uncrustify/test/test_pep257.py000066400000000000000000000014431420377356500227530ustar00rootroot00000000000000# Copyright 2021 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pep257.main import main import pytest @pytest.mark.linter @pytest.mark.pep257 def test_pep257(): rc = main(argv=['.', 'test']) assert rc == 0, 'Found code style errors / warnings' ament_lint-0.12.0/ament_uncrustify/test/test_pycodestyle.py000066400000000000000000000014311420377356500242720ustar00rootroot00000000000000# Copyright 2021 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pycodestyle.main import main import pytest @pytest.mark.linter def test_pycodestyle(): rc = main(argv=['.', 'test']) assert rc == 0, 'Found code style errors / warnings' ament_lint-0.12.0/ament_xmllint/000077500000000000000000000000001420377356500166135ustar00rootroot00000000000000ament_lint-0.12.0/ament_xmllint/CHANGELOG.rst000066400000000000000000000075701420377356500206450ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_xmllint ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.12.0 (2022-02-18) ------------------- 0.11.4 (2022-01-14) ------------------- * Update forthcoming version in changelogs * Contributors: Audrow Nash 0.11.3 (2022-01-14) ------------------- * Update maintainers to Michael Jeronimo and Michel Hidalgo (`#340 `_) * Contributors: Audrow Nash 0.11.2 (2021-06-18) ------------------- 0.11.1 (2021-06-18) ------------------- 0.11.0 (2021-06-18) ------------------- 0.10.6 (2021-05-06) ------------------- 0.10.5 (2021-04-14) ------------------- * Remove Claire as a maintainer. (`#312 `_) * Remove Claire as a maintainer. * Remove dead email addresses. * Remove more dead email addresses. * Switch setup.py maintainer to Audrow. * Contributors: Chris Lalancette 0.10.4 (2021-03-18) ------------------- 0.10.3 (2021-03-03) ------------------- * 0.10.3 * Contributors: Audrow Nash 0.10.2 (2021-02-12) ------------------- * Add Audrow as a maintainer (`#294 `_) * Drop trailing tab from package manifests (`#291 `_) Follow-up to 8bf194aa1ac282db5483dd0d3fefff8f325b0db8 * Contributors: Audrow Nash, Scott K Logan 0.10.1 (2021-01-25) ------------------- * Update maintainer (`#274 `_) * update maintainer * add authors * Contributors: Claire Wang 0.10.0 (2020-09-18) ------------------- * Add pytest.ini so local tests don't display warning. (`#259 `_) * Contributors: Chris Lalancette 0.9.4 (2020-05-26) ------------------ 0.9.3 (2020-05-18) ------------------ 0.9.2 (2020-05-08) ------------------ * Allow AMENT_IGNORE markers to be directories (`#232 `_) * Contributors: Dan Rose 0.9.1 (2020-04-10) ------------------ * 0.9.0 * more verbose test_flake8 error messages (same as `ros2/launch_ros#135 `_) * Generate xunit files valid for the junit10.xsd (`#220 `_) * remove status attribute from result XML (`#212 `_) * Contributors: Chris Lalancette, Dirk Thomas, Jose Luis Rivero 0.8.1 (2019-10-23) ------------------ * install resource marker file for packages (`#193 `_) * Contributors: Dirk Thomas 0.8.0 (2019-09-17) ------------------ * install manifest files in Python packages (`#185 `_) * Contributors: Dirk Thomas 0.7.4 (2019-07-31) ------------------ * declare pytest markers (`#164 `_) * declare pytest markers * add markers to ament_xmllint tests * Contributors: Dirk Thomas 0.7.3 (2019-05-09 14:08) ------------------------ 0.7.2 (2019-05-09 09:30) ------------------------ 0.7.1 (2019-05-07) ------------------ * update phrase of status messages (`#137 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-11) ------------------ 0.6.3 (2019-01-14) ------------------ 0.6.2 (2018-12-06) ------------------ 0.6.1 (2018-11-15) ------------------ 0.6.0 (2018-11-14) ------------------ * add zip_safe flag to avoid stderr output (`#104 `_) * add ament\_(cmake\_)xmllint packages (`#104 `_) * add ament\_(cmake\_)xmllint packages * consider xsi:noNamespaceSchemaLocation of root tag * Contributors: Dirk Thomas 0.5.2 (2018-06-27) ------------------ 0.5.1 (2018-06-18 13:47) ------------------------ 0.5.0 (2018-06-18 10:09) ------------------------ 0.4.0 (2017-12-08) ------------------ ament_lint-0.12.0/ament_xmllint/ament_xmllint/000077500000000000000000000000001420377356500214665ustar00rootroot00000000000000ament_lint-0.12.0/ament_xmllint/ament_xmllint/__init__.py000066400000000000000000000000001420377356500235650ustar00rootroot00000000000000ament_lint-0.12.0/ament_xmllint/ament_xmllint/main.py000077500000000000000000000211501420377356500227660ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014-2018 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import os import shutil import subprocess import sys import time from xml.etree import ElementTree from xml.sax import make_parser from xml.sax import SAXParseException from xml.sax.handler import ContentHandler from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr def main(argv=sys.argv[1:]): extensions = ['xml'] parser = argparse.ArgumentParser( description='Check XML markup using xmllint.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( 'paths', nargs='*', default=[os.curdir], help='The files or directories to check. For directories files ending ' 'in %s will be considered.' % ', '.join(["'.%s'" % e for e in extensions])) parser.add_argument( '--exclude', nargs='*', default=[], help='Exclude specific file names and directory names from the check') # not using a file handle directly # in order to prevent leaving an empty file when something fails early parser.add_argument( '--xunit-file', help='Generate a xunit compliant XML file') args = parser.parse_args(argv) if args.xunit_file: start_time = time.time() files = get_files(args.paths, extensions, args.exclude) if not files: print('No files found', file=sys.stderr) return 1 files = [os.path.abspath(f) for f in files] xmllint_bin = shutil.which('xmllint') if not xmllint_bin: return "Could not find 'xmllint' executable" report = [] # invoke xmllint on all files for filename in files: # parse file to extract desired validation information parser = make_parser() handler = CustomHandler() parser.setContentHandler(handler) try: parser.parse(filename) except SAXParseException: pass cmd = [xmllint_bin, '--noout', filename] # choose validation options based on handler information for attributes in handler.xml_model_attributes: schematypens = attributes.get('schematypens') href = attributes.get('href') if schematypens is None or href is None: continue # check for XML schema if schematypens == 'http://www.w3.org/2001/XMLSchema': cmd += ['--schema', href] # check for RelaxNG elif schematypens == 'http://relaxng.org/ns/structure/1.0': cmd += ['--relaxng', href] # check for Schematron elif schematypens == 'http://purl.oclc.org/dsdl/schematron': cmd += ['--schematron', href] if 'xsi:noNamespaceSchemaLocation' in handler.root_attributes: cmd += [ '--schema', handler.root_attributes['xsi:noNamespaceSchemaLocation']] try: subprocess.check_output( cmd, cwd=os.path.dirname(filename), stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: errors = e.output.decode() else: errors = None filename = os.path.relpath(filename, start=os.getcwd()) report.append((filename, errors)) for (filename, errors) in report: if errors is not None: print("File '%s' is invalid:" % filename, file=sys.stderr) for line in errors.splitlines(): print(line, file=sys.stderr) print('', file=sys.stderr) else: print("File '%s' is valid" % filename) print('') # output summary error_count = sum(1 if r[1] else 0 for r in report) if not error_count: print('No problems found') rc = 0 else: print('%d files are invalid' % error_count, file=sys.stderr) rc = 1 # generate xunit file if args.xunit_file: folder_name = os.path.basename(os.path.dirname(args.xunit_file)) file_name = os.path.basename(args.xunit_file) suffix = '.xml' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] suffix = '.xunit' if file_name.endswith(suffix): file_name = file_name[0:-len(suffix)] testname = '%s.%s' % (folder_name, file_name) xml = get_xunit_content(report, testname, time.time() - start_time) path = os.path.dirname(os.path.abspath(args.xunit_file)) if not os.path.exists(path): os.makedirs(path) with open(args.xunit_file, 'w') as f: f.write(xml) return rc def get_files(paths, extensions, excludes=[]): files = [] for path in paths: if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if 'AMENT_IGNORE' in dirnames + filenames: dirnames[:] = [] continue # ignore folder starting with . or _ dirnames[:] = [d for d in dirnames if d[0] not in ['.', '_']] # ignore excluded folders dirnames[:] = [d for d in dirnames if d not in excludes] dirnames.sort() # select files by extension for filename in sorted(filenames): if filename in excludes: continue _, ext = os.path.splitext(filename) if ext not in ['.%s' % e for e in extensions]: continue files.append(os.path.join(dirpath, filename)) if os.path.isfile(path): files.append(path) return [os.path.normpath(f) for f in files] class CustomHandler(ContentHandler): def __init__(self): super().__init__() self.xml_model_attributes = [] self.root_attributes = {} self._first_node = False def processingInstruction(self, target, data): if target != 'xml-model': return root = ElementTree.fromstring('') self.xml_model_attributes.append(root.attrib) def startDocument(self): self._first_node = True def startElement(self, name, attrs): if not self._first_node: return self._first_node = False for attr_name in attrs.getNames(): self.root_attributes[attr_name] = attrs.getValue(attr_name) def get_xunit_content(report, testname, elapsed): test_count = len(report) error_count = len([r for r in report if r[1]]) data = { 'testname': testname, 'test_count': test_count, 'error_count': error_count, 'time': '%.3f' % round(elapsed, 3), } xml = """ """ % data for (filename, diff_lines) in report: if diff_lines: # report any diff as a failing testcase data = { 'quoted_location': quoteattr(filename), 'testname': testname, 'quoted_message': quoteattr( 'Diff with %d lines' % len(diff_lines) ), 'cdata': ''.join(diff_lines), } xml += """ """ % data else: # if there is no diff report a single successful test data = { 'quoted_location': quoteattr(filename), 'testname': testname, } xml += """ """ % data # output list of checked files data = { 'escaped_files': escape(''.join(['\n* %s' % r[0] for r in report])), } xml += """ Checked files:%(escaped_files)s """ % data xml += '\n' return xml if __name__ == '__main__': sys.exit(main()) ament_lint-0.12.0/ament_xmllint/ament_xmllint/pytest_marker.py000066400000000000000000000013701420377356500247320ustar00rootroot00000000000000# Copyright 2019 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def pytest_configure(config): config.addinivalue_line( 'markers', 'xmllint: marks tests checking XML files being well formed and valid') ament_lint-0.12.0/ament_xmllint/doc/000077500000000000000000000000001420377356500173605ustar00rootroot00000000000000ament_lint-0.12.0/ament_xmllint/doc/index.rst000066400000000000000000000011011420377356500212120ustar00rootroot00000000000000ament_xmllint ============= Checks XML markup files using `xmllint `_. Files with the following extensions are being considered: ``.xml``. How to run the check from the command line? ------------------------------------------- .. code:: sh ament_xmllint [ ...] How to run the check from within a CMake ament package as part of the tests? ---------------------------------------------------------------------------- The CMake integration is provided by the package `ament_cmake_xmllint `_. ament_lint-0.12.0/ament_xmllint/package.xml000066400000000000000000000020071420377356500207270ustar00rootroot00000000000000 ament_xmllint 0.12.0 The ability to check XML files like the package manifest using xmllint and generate xUnit test result files. Michael Jeronimo Michel Hidalgo Apache License 2.0 Audrow Nash Claire Wang Dirk Thomas ament_lint libxml2-utils ament_copyright ament_flake8 ament_pep257 python3-pytest ament_python ament_lint-0.12.0/ament_xmllint/pytest.ini000066400000000000000000000000351420377356500206420ustar00rootroot00000000000000[pytest] junit_family=xunit2 ament_lint-0.12.0/ament_xmllint/resource/000077500000000000000000000000001420377356500204425ustar00rootroot00000000000000ament_lint-0.12.0/ament_xmllint/resource/ament_xmllint000066400000000000000000000000001420377356500232260ustar00rootroot00000000000000ament_lint-0.12.0/ament_xmllint/setup.py000066400000000000000000000026571420377356500203370ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_xmllint' setup( name=package_name, version='0.12.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], install_requires=['setuptools'], zip_safe=True, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Michael Jeronimo, Michel Hidalgo', maintainer_email='michael.jeronimo@openrobotics.org, michel@ekumenlabs.com', url='https://github.com/ament/ament_lint', download_url='https://github.com/ament/ament_lint/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Check XML markup using xmllint.', long_description="""\ The ability to check XML files like the package manifest using xmllint and generate xUnit test result files.""", license='Apache License, Version 2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ 'ament_xmllint = ament_xmllint.main:main', ], 'pytest11': [ 'ament_xmllint = ament_xmllint.pytest_marker', ], }, ) ament_lint-0.12.0/ament_xmllint/test/000077500000000000000000000000001420377356500175725ustar00rootroot00000000000000ament_lint-0.12.0/ament_xmllint/test/test_copyright.py000066400000000000000000000014131420377356500232120ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_copyright.main import main import pytest @pytest.mark.copyright @pytest.mark.linter def test_copyright(): rc = main(argv=[]) assert rc == 0, 'Found errors' ament_lint-0.12.0/ament_xmllint/test/test_flake8.py000066400000000000000000000015641420377356500223630ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_flake8.main import main_with_errors import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ '\n'.join(errors) ament_lint-0.12.0/ament_xmllint/test/test_pep257.py000066400000000000000000000014211420377356500222230ustar00rootroot00000000000000# Copyright 2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_pep257.main import main import pytest @pytest.mark.linter @pytest.mark.pep257 def test_pep257(): rc = main(argv=[]) assert rc == 0, 'Found docblock style errors'