Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: precommit with detekt #1181

Merged
merged 5 commits into from
Jun 25, 2024
Merged

Conversation

thomasBousselin
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the feature New feature or request label Jun 19, 2024
@thomasBousselin thomasBousselin force-pushed the feature/detekt-in-precommit branch from b27f49d to 57f2c08 Compare June 19, 2024 17:26
Copy link
Contributor

github-actions bot commented Jun 19, 2024

Test Results

   57 files  +  7     57 suites  +7   1m 22s ⏱️ +24s
  974 tests +144    974 ✅ +144  0 💤 ±0  0 ❌ ±0 
1 013 runs  +144  1 013 ✅ +144  0 💤 ±0  0 ❌ ±0 

Results for commit 483f9ca. ± Comparison against base commit 27154b5.

This pull request removes 187 and adds 177 tests. Note that renamed tests count towards both.
                      "@id": "https://uri…
                      "@type": "@json",
                      …
                    "@value": "/A/B"
                    "@value": "/C/D"
                    "@value": 20
                    "…
                    {
                   …, withTemporalValues=true, withAudit=false, expectation={
                  "@type": "https://uri.etsi.org/ngsi-ld/DateTime",
…
com.egm.stellio.search.util.PatchAttributeTests ‑ [1] source={
    "attribute": {
        "type": "Property",
        "value": 12.0,
        "observedAt": "2024-04-14T12:34:56Z"
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM"
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "observedAt": "2024-04-14T12:34:56Z"
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [1] source={
    "attribute": {
        "type": "Property",
        "value": 12.0,
        "observedAt": "2024-04-14T12:34:56Z",
        "subAttribute": {
            "type": "Property",
            "value": "subAttribute"
        }
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "subAttribute": {
            "type": "Property",
            "value": "newSubAttributeValue"
        }
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "observedAt": "2024-04-14T12:34:56Z",
        "subAttribute": {
            "type": "Property",
            "value": "newSubAttributeValue"
        }
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [2] source={
    "attribute": {
        "type": "Property",
        "value": { "en": "car", "fr": "voiture" }
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": { "fr": "vélo", "es": "bicicleta" }
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": { "en": "car", "fr": "vélo", "es": "bicicleta" }
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [2] source={
    "incoming": {
        "type": "JsonProperty",
        "json": { "id": 1, "b": null, "c": 12.4 },
        "observedAt": "2022-12-24T14:01:22.066Z",
        "subAttribute": {
            "type": "Property",
            "value": "subAttribute"
        }
    }
}, target={
    "incoming": {
        "type": "JsonProperty",
        "json": { "id": 2, "b": "something" },
        "observedAt": "2023-12-24T14:01:22.066Z"
    }
}, expected={
    "incoming": {
        "type": "JsonProperty",
        "json": { "id": 2, "b": "something" },
        "observedAt": "2023-12-24T14:01:22.066Z",
        "subAttribute": {
            "type": "Property",
            "value": "subAttribute"
        }
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [3] source={
    "attribute": {
        "type": "Property",
        "value": [ "car", "voiture" ]
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": [ "vélo", "bicicleta" ]
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": [ "vélo", "bicicleta" ]
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [3] source={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "stellio"
    }
}, target={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "egm"
    }
}, expected={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "egm"
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [4] source={
    "attribute": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Entity:01"
    }
}, target={
    "attribute": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Entity:02"
    }
}, expected={
    "attribute": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Entity:02"
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [5] source={
    "attribute": {
        "type": "LanguageProperty",
        "languageMap": { "en": "train", "fr": "train" }
    }
}, target={
    "attribute": {
        "type": "LanguageProperty",
        "languageMap": { "fr": "TGV", "es": "tren" }
    }
}, expected={
    "attribute": {
        "type": "LanguageProperty",
        "languageMap": { "en": "train", "fr": "TGV", "es": "tren" }
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [6] source={
    "incoming": {
        "type": "JsonProperty",
        "json": { "a": 1, "b": "thing" }
    }
}, target={
    "incoming": {
        "type": "JsonProperty",
        "json": { "a": 2, "c": "other thing" }
    }
}, expected={
    "incoming": {
        "type": "JsonProperty",
        "json": { "a": 2, "b": "thing", "c": "other thing" }
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [7] source={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "stellio"
    }
}, target={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "egm"
    }
}, expected={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "egm"
    }
}
…

♻️ This comment has been updated with latest results.

@bobeal
Copy link
Member

bobeal commented Jun 19, 2024

Did a try and:

$ git commit --file=/var/folders/86/8jzxb8dd63z_584pglf2tj7m0000gn/T/78C121CB-CB73-4D48-A410-0992A5D24F4D

detekt check.............................................................Failed
- hook id: detekt
- exit code: 1

Executable `/Users/bobeal/egm/dev/datahub/stellio-context-broker/config/detekt/detekt.sh` is not executable

README.md Outdated Show resolved Hide resolved
README.md Outdated
@@ -133,6 +133,17 @@ If you want to build only one of the services, you can launch:

Commits follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).

### Pre-commit
The precommit hook use gradle to automatically apply detekt rules.
It will not be able to work if gradle is not in your $path variable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the script is calling ./gradlew, I think it is not needed to install Gradle beforehand (it will be done when first calling gradlew: https://docs.gradle.org/current/userguide/gradle_wrapper.html).

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@thomasBousselin thomasBousselin force-pushed the feature/detekt-in-precommit branch from 57f2c08 to 1052562 Compare June 20, 2024 07:05
@thomasBousselin thomasBousselin linked an issue Jun 20, 2024 that may be closed by this pull request
@thomasBousselin
Copy link
Contributor Author

thomasBousselin commented Jun 20, 2024

I did git update-index --chmod=+x .\config\detekt\detekt_auto_correct.sh who is supposed to make the file executable.

@bobeal
Copy link
Member

bobeal commented Jun 20, 2024

Looked good when tried today. Remember you wanted to add one last improvement.

@thomasBousselin
Copy link
Contributor Author

thomasBousselin commented Jun 21, 2024

Sadly the return code from auto-correct and unexpected error is the same (1). So the idea of looping only when there was an auto correct is not possible.
I will just reduce the max number of iteration instead.

Copy link

@thomasBousselin thomasBousselin merged commit 640065f into develop Jun 25, 2024
10 checks passed
@thomasBousselin thomasBousselin deleted the feature/detekt-in-precommit branch June 25, 2024 07:19
@github-actions github-actions bot locked and limited conversation to collaborators Jun 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a pre-commit hook to run Detekt
2 participants