Skip to content

Improve code style by using CI and pre-commit hooks #223

@gikari

Description

@gikari

The problem

I encountered a problem, when committing a change to the repo: my automatic cargo fmt formatted an unrelated line in the file:

Diff in /lagann/Development/qmetaobject-rs/qmetaobject/src/qtdeclarative.rs at line 506:
 ///
 /// [qt]: https://doc.qt.io/qt-5/qqmlengine.html#qmlRegisterModule
 #[cfg(qt_5_9)]
-pub fn qml_register_module(
-    uri: &CStr,
-    version_major: u32,
-    version_minor: u32,
-) {
+pub fn qml_register_module(uri: &CStr, version_major: u32, version_minor: u32) {
     let uri_ptr = uri.as_ptr();

     cpp!(unsafe [

To commit my changes, I had to exclude the diff above from the git, which is inconvenient.

Apparently, this was left, because there wasn't an automatic check in the CI, when the PR was merged.

Possible solution

  • There should be an automatic check in the CI to prevent merging the PR with incorrect code formatting.
  • To simplify the life of the developers, there should be a pre-commit hook, that formats the code automatically before committing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ToolsArea: Tooling and build systems, including CMakeC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions