{"id":13428966,"url":"https://github.com/mkohm/detekt-hint","last_synced_at":"2025-03-16T02:31:00.032Z","repository":{"id":41783924,"uuid":"234338144","full_name":"Mkohm/detekt-hint","owner":"Mkohm","description":"Detection of design principle violations in Kotlin as a plugin to detekt.","archived":false,"fork":false,"pushed_at":"2023-01-25T03:23:47.000Z","size":9391,"stargazers_count":80,"open_issues_count":19,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-27T06:39:30.848Z","etag":null,"topics":["anti-patterns","code-quality","code-smells","danger","design-principles","detections","detekt","detekt-hint","detekt-plugin","kotlin","programming-principles","software-architecture","static-code-analysis"],"latest_commit_sha":null,"homepage":"https://mkohm.github.io/detekt-hint/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mkohm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-16T14:28:18.000Z","updated_at":"2024-09-30T20:43:34.000Z","dependencies_parsed_at":"2023-02-14T04:16:12.764Z","dependency_job_id":null,"html_url":"https://github.com/Mkohm/detekt-hint","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mkohm%2Fdetekt-hint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mkohm%2Fdetekt-hint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mkohm%2Fdetekt-hint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mkohm%2Fdetekt-hint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mkohm","download_url":"https://codeload.github.com/Mkohm/detekt-hint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243815640,"owners_count":20352205,"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":["anti-patterns","code-quality","code-smells","danger","design-principles","detections","detekt","detekt-hint","detekt-plugin","kotlin","programming-principles","software-architecture","static-code-analysis"],"created_at":"2024-07-31T01:01:10.219Z","updated_at":"2025-03-16T02:30:57.983Z","avatar_url":"https://github.com/Mkohm.png","language":"HTML","funding_links":[],"categories":["Tools"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# detekt-hint (Attention: Looking for developers)\nDetection of design principle violations in Kotlin added as comments on pull requests.\n\n## [Getting started](#getting-started) | :checkered_flag: [Roadmap](#upcoming-features) | :thought_balloon: [Ask a question](https://github.com/Mkohm/detekt-hint/issues/new) | :book: [Documentation](https://mkohm.github.io/detekt-hint/docs/)\n\n\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/307995daba5f21506f4d/maintainability)](https://codeclimate.com/github/Mkohm/detekt-hint/maintainability) [![codecov](https://codecov.io/gh/Mkohm/detekt-hint/branch/master/graph/badge.svg)](https://codecov.io/gh/Mkohm/detekt-hint) [![Build Status](https://travis-ci.com/Mkohm/detekt-hint.svg?branch=master)](https://travis-ci.com/Mkohm/detekt-hint) [ ![Download](https://api.bintray.com/packages/bintray/jcenter/io.github.mkohm%3Adetekt-hint/images/download.svg) ](https://bintray.com/bintray/jcenter/io.github.mkohm%3Adetekt-hint/_latestVersion)\n[![Kotlinlang slack](https://img.shields.io/static/v1?label=kotlinlang\u0026message=detekt-hint\u0026color=brightgreen\u0026logo=slack\u0026style=flat-square)](https://app.slack.com/client/T09229ZC6/C012ZSM6L1J)\n[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)\n\n\n![ucih](images/demo.png)\n\n\u003c/div\u003e\n\ndetekt-hint is a plugin for [detekt](https://github.com/arturbosch/detekt) that includes detection of violation of programming principles. Since such violations are hard to detect with low false-positive rates, detekt-hint will provide hints during QA, minimizing noise during development. The idea is that a higher false-positive rate can be accepted if the detection could be of high value, and is easy to ignore. Detections on the architectural level of code is therefore most likely to provide value.\n\nThrough integration with [Danger](https://github.com/danger/danger) comments are added to the PR. Getting feedback directly on the PR makes it easy to ignore possible false-positives. Comments also include context and tips, making it easier for the developer to make the correct decisions. \n\nContributions are very much welcome and if you like the project - help me out with a :star:. Especially help in which rules to implement, how to implement them and how to reduce the false-positives.\n\n## Currently supported detections\n:white_check_mark: Use composition instead of inheritance - Will help developer ensure Liskov Substitution Principle is not violated. Will not report if you inherit from third-party libraries.\n\n:white_check_mark: Lack Of Cohesion of Methods - Notifies you if the LCOM value is too high.\n\n:white_check_mark: Interface Segregation Principles - Notifies you if you implement methods that the class does not need.\n\n:white_check_mark: Open-Closed Principle - This rule reports use of switching on enums and classes, which may be a sign of violation the open closed principle.\n\n### Interface Segregation Principle\n![lcom](images/comment_isp.png)\n\n### Single Responsibility Principle\n![lcom](images/comment_lackOfCohesion.png)\n\n### Open-Closed Principle\n![lcom](images/comment_ocp2.png)\n\n## Using detekt-hint\nIf you just want to analyze some code without bothering with the Danger integration (which really defeats the purpose of the tool) head to the [command line section](#With-the-command-line).\n\n### With Github Actions\n1. Configure a detekt-hint-config.yml to include detekt-hint rules and put it in a folder called \"config\" in your root project folder. \n\nconfig/detekt-hint-config.yml\n```yml\ndetekt-hint:\n  UseCompositionInsteadOfInheritance:\n    active: true\n    yourUniquePackageName: \"io.github.mkohm\"\n  LackOfCohesionMethods:\n    active: true\n    threshold: \"0.8\"\n  InterfaceSegregationPrinciple:\n      active: true\n  OpenClosedPrinciple:\n      active: true\n```\n\nMake sure you enter your unique package name in the configuration for the UseCompositionInsteadOfInheritance rule.\n\n2. Create a github action using the detekt-hint docker action. \n\n.github/workflows/detekt-hint.yml\n```yml\nname: detekt hint\n\non:\n  pull_request:\n    branches:\n      - '*'\n\njobs:\n  gradle:\n    strategy:\n      matrix:\n        os: [ubuntu-latest]\n        jdk: [11]\n    runs-on: ${{ matrix.os }}\n    if: ${{ !contains(github.event.head_commit.message, 'detekt hint skip') }}\n    env:\n      JDK_VERSION:  ${{ matrix.jdk }}\n    steps:\n      - name: Checkout Repo\n        uses: actions/checkout@v2\n        \n      - name: Run detekt hint\n        uses: mkohm/detekt-hint-action@v1.1\n        with:\n          github-api-token: ${{ secrets.GITHUB_TOKEN }}\n```\n\n3. Create a PR and see detekt-hint run as a separate action.\n\nHaving trouble? Please [create an issue](https://github.com/Mkohm/detekt-hint/issues/new) or contact me on the kotlinlang Slack (username: mkohm), and i will help you out.\n\n### With the command line\nIf you only want to do some analysis on your code without the power of Danger commenting on your PR you can use the tool from the command line. You must first clone detekt and detekt-hint repositories, and then build the required jars:\n```\ngit clone https://github.com/Mkohm/detekt-hint \u0026\u0026 git clone https://github.com/arturbosch/detekt \u0026\u0026 cd detekt-hint \u0026\u0026 ./gradlew jar \u0026\u0026 cd ../detekt/ \u0026\u0026 ./gradlew build shadowJar \u0026\u0026 cd ..\n```\nUse the command line utility:\n```bash\njava -jar detekt/detekt-cli/build/libs/detekt-cli-[version]-all.jar --plugins detekt-hint/build/libs/detekt-hint-[version].jar --config detekt-hint/config/detekt.yml --classpath \u003cyour-classpath\u003e --input \u003cpath-to-your-awesome-project\u003e\n```\nFor example:\n```bash\njava -jar detekt/detekt-cli/build/libs/detekt-cli-1.5.0-all.jar --plugins detekt-hint/build/libs/detekt-hint-0.0.2.jar --config detekt-hint/config/detekt.yml --classpath detekt-hint/ --input detekt-hint/\n```\nRemember to enter the [latest](https://mvnrepository.com/artifact/io.gitlab.arturbosch.detekt/detekt-cli) detekt-cli version, the [latest](https://mvnrepository.com/artifact/io.github.mkohm/detekt-hint) detekt-hint version and the path to your classpath and source code. Also, make sure that the detekt.yml you are using contains the unique package name in the configuration for the UseCompositionInsteadOfInheritance rule. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkohm%2Fdetekt-hint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkohm%2Fdetekt-hint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkohm%2Fdetekt-hint/lists"}