Skip to content

woltapp/arrow-detekt-rules

Repository files navigation

Detekt rules for Arrow

This project contains Detekt rules for the Arrow ecosystem.

How to use it

  1. Add this project as a Detekt plugin to build.gradle.kts
dependencies {
    detektPlugins("com.wolt.arrow.detekt:rules:*VERSION*")
}
  1. Enable and configure rules in Detekt configuration, example:
ArrowRuleSet:
  NoEffectScopeBindableValueAsStatement:
    active: true

Note that by default Detekt runs without type resolution enabled (just running detekt will not run the rules from this repo), see Detekt documentation on that.

Contribution guidelines

  • Read Detekt documentation about extending it.
  • When adding a new rule, don't forget to include it RuleSetProvider (or create one if adding a new rule set).
  • Note that rules are disabled by default, enable them in the Detekt configuration.

Releasing

  1. Draft a new release on GitHub.
  2. Create a new tag (e.g. v0.1.1 if the previous was v0.1.0 and you want to bump the patch version).
  3. Auto-generate release notes.
  4. Publish the release.
  5. This will trigger a CI workflow to build and publish the library to Sonatype Nexus. You can see it here. After publishing succeeds, login to Sonatype Nexus and select "Staging repositories".
  6. Check the content of the new entry.
  7. If there are no issues, press "Close". It will run the checks required for sync with Maven Central. If there are issues, press "Drop".
  8. Press "Release" to sync with Maven Central (Or "Drop" if there are problems with content/checks).

Rules

NoEffectScopeBindableValueAsStatement

This rule reports any bindable value from Arrow-kt (like Either) that is used as an unbound statement inside scope that allows binding values.

Active by default: No

Requires Type Resolution

Noncompliant code:

fun doSomething() = Either.Left(Throwable("Oh no"))
fun doSomethingElse() = Either.Right(5)
return either {
    doSomething()
    doSomethingElse().bind()
}

Compliant code:

fun doSomething() = Either.Left(Throwable("Oh no"))
fun doSomethingElse() = Either.Right(5)
return either {
    doSomething().bind()
    doSomethingElse().bind()
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages