Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit e82d34b

Browse files
authored
Add code style checks (#134)
2 parents 406e5e5 + a998db5 commit e82d34b

40 files changed

+975
-956
lines changed

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
ColumnLimit: 120

.git-blame-ignore-revs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Add git commit hashes to ignore for blame
2+
a5a1b5cb51afa766e7c9f72fbba2f79a858641c2
3+
975eb13a66bcf2e50525886453b40dd48b3b168f
4+
874863ef235c3713aa1f50b507cb9017afdba0f5

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Code style checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-python@v3
14+
- name: Install cppcheck
15+
run: sudo apt install cppcheck -y
16+
- uses: pre-commit/action@v3.0.0

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.0.277
4+
hooks:
5+
- id: ruff
6+
args:
7+
- "--fix"
8+
- "--exit-non-zero-on-fix"
9+
- repo: https://github.com/psf/black
10+
rev: 23.3.0
11+
hooks:
12+
- id: black
13+
- repo: https://github.com/pocc/pre-commit-hooks
14+
rev: v1.3.5
15+
hooks:
16+
- id: clang-format
17+
args:
18+
- "-i"
19+
- id: cppcheck
20+
args:
21+
- "--suppress=missingInclude"
22+
- "--suppress=unmatchedSuppression"
23+
- "--suppress=unusedFunction"

bitbots_buttons/docs/conf.py

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Full list of options at http://www.sphinx-doc.org/en/master/config
43

@@ -10,18 +9,20 @@
109
#
1110
import os
1211
import sys
13-
import catkin_pkg.package
1412

13+
import catkin_pkg.package
1514
from exhale import utils
1615

1716
package_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1817
catkin_package = catkin_pkg.package.parse_package(
19-
os.path.join(package_dir, catkin_pkg.package.PACKAGE_MANIFEST_FILENAME))
18+
os.path.join(package_dir, catkin_pkg.package.PACKAGE_MANIFEST_FILENAME)
19+
)
2020
sys.path.insert(0, os.path.abspath(os.path.join(package_dir, "src")))
2121

2222

2323
# -- Helper functions --------------------------------------------------------
2424

25+
2526
def count_files():
2627
""":returns tuple of (num_py, num_cpp)"""
2728
num_py = 0
@@ -42,7 +43,7 @@ def count_files():
4243
# -- Project information -----------------------------------------------------
4344

4445
project = catkin_package.name
45-
copyright = '2019, Bit-Bots'
46+
copyright = "2019, Bit-Bots"
4647
author = ", ".join([a.name for a in catkin_package.authors])
4748

4849
# The short X.Y version
@@ -60,27 +61,27 @@ def count_files():
6061
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
6162
# ones.
6263
extensions = [
63-
'sphinx.ext.autodoc',
64-
'sphinx.ext.doctest',
65-
'sphinx.ext.intersphinx',
66-
'sphinx.ext.todo',
67-
'sphinx.ext.coverage',
68-
'sphinx.ext.imgmath',
69-
'sphinx.ext.viewcode',
70-
'sphinx_rtd_theme',
64+
"sphinx.ext.autodoc",
65+
"sphinx.ext.doctest",
66+
"sphinx.ext.intersphinx",
67+
"sphinx.ext.todo",
68+
"sphinx.ext.coverage",
69+
"sphinx.ext.imgmath",
70+
"sphinx.ext.viewcode",
71+
"sphinx_rtd_theme",
7172
]
7273

7374
# Add any paths that contain templates here, relative to this directory.
74-
templates_path = ['_templates']
75+
templates_path = ["_templates"]
7576

7677
# The suffix(es) of source filenames.
7778
# You can specify multiple suffix as a list of string:
7879
#
7980
# source_suffix = ['.rst', '.md']
80-
source_suffix = '.rst'
81+
source_suffix = ".rst"
8182

8283
# The master toctree document.
83-
master_doc = 'index'
84+
master_doc = "index"
8485

8586
# The language for content autogenerated by Sphinx. Refer to documentation
8687
# for a list of supported languages.
@@ -92,7 +93,7 @@ def count_files():
9293
# List of patterns, relative to source directory, that match files and
9394
# directories to ignore when looking for source files.
9495
# This pattern also affects html_static_path and html_extra_path.
95-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
96+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
9697

9798
# The name of the Pygments (syntax highlighting) style to use.
9899
pygments_style = None
@@ -108,24 +109,17 @@ def count_files():
108109

109110
if num_files_cpp > 0:
110111
extensions += [
111-
'breathe',
112-
'exhale',
112+
"breathe",
113+
"exhale",
113114
]
114115

115-
breathe_projects = {
116-
project: os.path.join("_build", "doxyoutput", "xml")
117-
}
116+
breathe_projects = {project: os.path.join("_build", "doxyoutput", "xml")}
118117
breathe_default_project = project
119118

120119
def specifications_for_kind(kind):
121120
# Show all members for classes and structs
122121
if kind == "class" or kind == "struct":
123-
return [
124-
":members:",
125-
":protected-members:",
126-
":private-members:",
127-
":undoc-members:"
128-
]
122+
return [":members:", ":protected-members:", ":private-members:", ":undoc-members:"]
129123
# An empty list signals to Exhale to use the defaults
130124
else:
131125
return []
@@ -136,21 +130,19 @@ def specifications_for_kind(kind):
136130
"rootFileName": "library_root.rst",
137131
"rootFileTitle": "C++ Library API",
138132
"doxygenStripFromPath": "..",
139-
"customSpecificationsMapping": utils.makeCustomSpecificationsMapping(
140-
specifications_for_kind
141-
),
133+
"customSpecificationsMapping": utils.makeCustomSpecificationsMapping(specifications_for_kind),
142134
# Suggested optional arguments
143135
"createTreeView": True,
144136
"exhaleExecutesDoxygen": True,
145-
"exhaleDoxygenStdin": "INPUT = {}".format(os.path.join(package_dir, "include"))
137+
"exhaleDoxygenStdin": "INPUT = {}".format(os.path.join(package_dir, "include")),
146138
}
147139

148140
# -- Options for HTML output -------------------------------------------------
149141

150142
# The theme to use for HTML and HTML Help pages. See the documentation for
151143
# a list of builtin themes.
152144
#
153-
html_theme = 'sphinx_rtd_theme'
145+
html_theme = "sphinx_rtd_theme"
154146

155147
# Theme options are theme-specific and customize the look and feel of a theme
156148
# further. For a list of options available for each theme, see the
@@ -161,7 +153,7 @@ def specifications_for_kind(kind):
161153
# Add any paths that contain custom static files (such as style sheets) here,
162154
# relative to this directory. They are copied after the builtin static files,
163155
# so a file named "default.css" will overwrite the builtin "default.css".
164-
html_static_path = ['_static']
156+
html_static_path = ["_static"]
165157

166158
# Custom sidebar templates, must be a dictionary that maps document names
167159
# to template names.
@@ -173,21 +165,23 @@ def specifications_for_kind(kind):
173165
#
174166
# html_sidebars = {}
175167

176-
html_logo = os.path.join('_static', 'logo.png')
177-
html_favicon = os.path.join('_static', 'logo.png')
168+
html_logo = os.path.join("_static", "logo.png")
169+
html_favicon = os.path.join("_static", "logo.png")
178170

179171

180172
# -- Options for intersphinx extension ---------------------------------------
181173

182174
# Example configuration for intersphinx: refer to the Python standard library.
183-
intersphinx_mapping = {'https://docs.python.org/': None}
175+
intersphinx_mapping = {"https://docs.python.org/": None}
184176

185177
# -- Options for todo extension ----------------------------------------------
186178

187179
# If true, `todo` and `todoList` produce output, else they produce nothing.
188180
todo_include_todos = True
189181

190182
# -- RST Standard variables ---------------------------------------------------
191-
rst_prolog = ".. |project| replace:: {}\n".format(project)
183+
rst_prolog = f".. |project| replace:: {project}\n"
192184
rst_prolog += ".. |description| replace:: {}\n".format(catkin_package.description.replace("\n\n", "\n"))
193-
rst_prolog += ".. |modindex| replace:: {}\n".format(":ref:`modindex`" if num_files_py > 0 else "Python module index is not available")
185+
rst_prolog += ".. |modindex| replace:: {}\n".format(
186+
":ref:`modindex`" if num_files_py > 0 else "Python module index is not available"
187+
)

0 commit comments

Comments
 (0)