{"id":28615500,"url":"https://github.com/siliconlabssoftware/devs-coding-convention-tool","last_synced_at":"2026-01-29T09:34:07.367Z","repository":{"id":268349629,"uuid":"904064100","full_name":"SiliconLabsSoftware/devs-coding-convention-tool","owner":"SiliconLabsSoftware","description":"This is a code formatter tool that helps ensure consistent coding style and detects common issues in source code files.  It integrates with pre-commit, allowing you to automate code formatting and checks as part of your development workflow.","archived":false,"fork":false,"pushed_at":"2025-05-23T10:57:04.000Z","size":420,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-23T13:36:43.588Z","etag":null,"topics":["community-contributions-paused","silicon-labs"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SiliconLabsSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-16T07:26:57.000Z","updated_at":"2025-05-23T10:57:08.000Z","dependencies_parsed_at":"2024-12-16T08:32:32.819Z","dependency_job_id":"2b8deca3-47f9-423e-9dcd-fd7b8c2d5384","html_url":"https://github.com/SiliconLabsSoftware/devs-coding-convention-tool","commit_stats":null,"previous_names":["siliconlabssoftware/coding-convention-tool","siliconlabssoftware/devs-coding-convention-tool"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SiliconLabsSoftware/devs-coding-convention-tool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiliconLabsSoftware%2Fdevs-coding-convention-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiliconLabsSoftware%2Fdevs-coding-convention-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiliconLabsSoftware%2Fdevs-coding-convention-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiliconLabsSoftware%2Fdevs-coding-convention-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SiliconLabsSoftware","download_url":"https://codeload.github.com/SiliconLabsSoftware/devs-coding-convention-tool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiliconLabsSoftware%2Fdevs-coding-convention-tool/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259382324,"owners_count":22848842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["community-contributions-paused","silicon-labs"],"created_at":"2025-06-12T02:09:06.725Z","updated_at":"2026-01-29T09:34:02.346Z","avatar_url":"https://github.com/SiliconLabsSoftware.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coding Convention Tool\nThis is a code formatter tool that helps ensure consistent coding style and detects common issues in source code files. It integrates with [pre-commit](https://pre-commit.com/), allowing you to automate code formatting and checks as part of your development workflow.\n\n## Features\n\n- Automatically fixes end-of-file issues.\n- Removes trailing whitespace from lines.\n- Identifies and suggests fixes for common spelling errors using [codespell](https://github.com/codespell-project/codespell).\n- Formats code according to specified [Uncrustify](https://github.com/uncrustify/uncrustify) rules base on [Silabs's coding standard](https://github.com/SiliconLabsSoftware/agreements-and-guidelines/blob/main/coding_standard.md)\n- Checks for identifiers naming style mismatch of function, definition, struct, variable using [clang-tidy](https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/clang-tidy/index.htmlextensible)\n\n## Project Structure\n\n* **tools**:\n    * **.codespell**\n        * **exclude-file.txt**: Contains lines to be excluded from Codespell checks.\n        * **ignore-words.txt**: Contains words to be ignored by Codespell to avoid false positives.\n    * **uncrustify.cfg**: Configuration file for Uncrustify, specifying the coding style and formatting rules.\n    * **.clang-tidy**: Configuration file for clang-tidy, specifying checks and options for static analysis.\n\n* **.pre-commit-config.yaml**: Configuration file for pre-commit, defining the hooks and their settings to be run before commits.\n## Installation\n### Ubuntu\nRecommended operating system: WSL, Ubuntu 22.04.\n\nEnsure Python3 is installed on your system. Then, install pre-commit clang-format clang-tidy cppcheck by running:\n```\n$ pip install pre-commit\n$ sudo apt install uncrustify clang-tidy cppcheck\n```\n\nRecommended version:\n- Codespell 2.2.4\n- Uncrustify 0.64.0 // Silabs specific uncrustify.cfg support only this version\n- Clang tidy 14.0.0\n\n### Windows\n\nTBD\n\n\n### Exclude Folder\n\nWhen using this tool, you may want to skip some folders. You can specify folders to exclude from formatting and checks by replacing the exclude regex pattern with the folders you want to skip.\n\nHere's how you can exclude folders ```build``` and ```gecko_sdk_xxx```using regex patterns in [.pre-commit-config.yaml](./.pre-commit-config.yaml) file:\n\n```yaml\nexclude: .*/build/.*|.*/gecko_sdk.*/.*\n```\n\n### Exclude File, Ignore Words for Codespell\n\nWhen using Codespell, you may encounter false positives or want to exclude specific files or directories from being checked. Codespell provides configuration options to handle these scenarios.\n\nHere's an example of a codespell configuration file [.codespellrc](tools/.codespell/.codespellrc)\n\n```\nignore-words = ./tools/.codespell/ignore-words.txt\nexclude-file = ./tools/.codespell/exclude-file.txt\ncheck-filenames =\ncheck-hidden =\ncount =\nskip = .git,*.a,\n```\n\nExplanation of Configuration Options\n\n* **[ignore-words](tools/.codespell/ignore-words.txt)** : This option points to a file containing words that should be ignored by Codespell. If you encounter a false positive, add the problematic word to ignore-words.txt. Ensure each word is in lowercase and on a new line.\n\nExample ignore-words.txt:\n\n```\nthe\nfoobar\n```\n* **[exclude-file](tools/.codespell/exclude-file.txt)** : This option points to a file containing lines that should be excluded from spell-checking. If a specific line in your code is causing a false positive, copy and paste the entire line into exclude-file.txt.\n\nExample exclude-file.txt:\n```\nThis is a sample line that should be excluded.\n```\n* **check-filenames**: Set this option to true if you want Codespell to check filenames for spelling errors. By default, this is empty (disabled).\n\n* **check-hidden**: Set this option to true if you want Codespell to check hidden files for spelling errors. By default, this is empty (disabled).\n\n* **count**: Set this option to true if you want Codespell to display the number of occurrences of each misspelled word. By default, this is empty (disabled).\n\n* **skip**: This option allows you to specify files or directories that Codespell should skip. You can list multiple entries separated by commas. For example, .git,*.a, will skip the .git directory and all files with the .a extension.\n\n### Uncrustify\n\nAutomatic source code formatting follows [Silabs's coding standard](https://github.com/SiliconLabsSoftware/agreements-and-guidelines/blob/main/coding_standard.md)\nThe Uncrustify configuration file is located at [/tools/uncrustify/uncrustify.cfg](./tools/uncrustify/uncrustify.cfg).\n\n\n### Clang-Tidy\n\n**Checks for identifiers naming style mismatch**\n\nClang-Tidy supports checking casing types (UPPER_CASE/lower_case) and prefixes of Function, Struct, Enum, Global Constant.\nYou can modify the prefix in the file [.clang-tidy](./tools/.clang-tidy).\n\nFor example, config function with lower_case and prefix 'sl_'\n```\n  - key: readability-identifier-naming.FunctionCase\n    value: lower_case\n  - key: readability-identifier-naming.FunctionPrefix\n    value: 'sl_'\n```\n\n**Adding Extra Arguments**\n\nYou may need to provide additional paths to header files or define macros for Clang-Tidy to ensure it correctly analyzes your code. This can be done using the ```--extra-arg``` option in the hook configuration.\n\nTo add extra arguments to the clang-tidy hook, modify the args section of the hook configuration in your .pre-commit-config.yaml file. Here's an example of how to add extra arguments:\n\n```yaml\n-   repo: https://github.com/pocc/pre-commit-hooks\n    rev: v1.3.5\n    hooks:\n    -   id: clang-tidy\n        args:\n            - --config-file=./tools/.clang-tidy\n            - --use-color\n            - --extra-arg=-I/inc/\n            - --extra-arg=-DMY_MACRO=1\n```\nIn this example, we've added two extra arguments to Clang-Tidy:\n\n```-I/inc/```: Specifies an include directory where Clang-Tidy will look for header files.\n\n```-DMY_MACRO=1```: Defines a macro named MY_MACRO with the value 1 for use in the code analysis.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiliconlabssoftware%2Fdevs-coding-convention-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiliconlabssoftware%2Fdevs-coding-convention-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiliconlabssoftware%2Fdevs-coding-convention-tool/lists"}