Git Product home page Git Product logo

detekt-sidekt's Introduction

detekt-sidekt

detekt extension that shamelessly kangs IntelliJ annotations. may probably not be needed once Jetbrains releases their gradle/maven plugin to do the same.

Inspections provided:

  • BlockingCallContext: inspect blocking method calls within non-blocking context
  • BlockingCallContextReclaimable: infer blocking calls within Dispatchers.IO context which can be migrated to non-blocking alternatives
  • JerseyMethodParameterDefaultValue: infer if a probable jersey method contains a parameter with a default value

detekt run

requires type resolution, so ensure you are setting the --classpath argument

java -jar detekt-cli-1.16.0-all.jar \
  --plugins sidekt-1.0-SNAPSHOT.jar \
  --classpath 'dep1.jar:dep2.jar' \
  --jvm-target 1.8 \
  --input 'src/' \
  --config defalt-detekt-config.yml

find a way to fail the build if these errors come up by setting very high weights

build:
  maxIssues: 99999 # ...? not sure what's a better way to _force_ an error
  excludeCorrectable: false
  weights:
    BlockingCallContext: 100000
    JerseyMethodParameterDefaultValue: 100000

BlockingCallContext, BlockingCallContextReclaimable

sidekt:
  BlockingCallContext:
    active: true
    # debug: 'stderr'
    blockingMethodAnnotations: ['com.custom.annotations.BlockingCall']
    blockingMethodFqNames: ['com.custom.wrapper.runBlocking']
    blockingExceptionTypes: ['com.amazonaws.http.timers.client.SdkInterruptedException']
    ioDispatcherFqNames: ['com.custom.Dispatchers.DB']
    reclaimableMethodAnnotations: ['com.custom.annotations.ReclaimableBlockingCall']
    reclaimableMethodFqNames: ['com.custom.wrapper.getSync']
    blockingClassAnnotations: ['com.custom.annotations.BlockingClass']
    blockingClassFqNames: ['com.custom.dao.SomeDao']

debug

prints a whole lot of debug information, please do not set this.

takes one of 'stdout', 'stderr', or a directory path

blockingMethodAnnotations

these are the annotations which you may use in your code to denote blocking methods

blockingMethodFqNames

in case the annotations marking the method as blocking cannot be inferred (probably due to annotation retention at SOURCE), then, such known methods' FQ names can be configured

blockingExceptionTypes

methods annotated with @kotlin.jvm.Throws, and which end up throwing certain exceptions, can be used to identify blocking methods.

please note: this will only work for methods in your own source code, and cannot come from the classpath since @kotlin.jvm.Throws annotation retention is at SOURCE

ioDispatcherFqNames

blocking calls are allowed within specific dispatchers, namely, Dispatchers.IO; given they are specifically for the purpose. in case you have an additional IO dispatcher, you may configure the same

reclaimableMethodAnnotations

albeit dispatchers specifically meant for IO are meant for such "blocking" calls, there may be certain methods which already provide non-blocking method alternatives. such methods may be annotated with a distinct annotation, and configured

reclaimableMethodFqNames

same as reclaimableMethodAnnotations, but allowing you to provide FQ names to the methods

blockingClassAnnotations

these are the annotations which you may use in your code to denote blocking classes.

similar to blockingMethodAnnotations, for classes.

blockingClassFqNames

in case the annotations marking the class as blocking cannot be inferred (probably due to annotation retention at SOURCE), then, such known classes' FQ names can be configured.

similar to blockingMethodFqNames, for classes.

JerseyMethodParameterDefaultValue

sidekt:
  JerseyMethodParameterDefaultValue:
    active: true
    # debug: 'stderr'

JerseyMethodParameterDefaultValue

this is in reference to the following issues; even with this being "fixed" (as in, not crash at runtime) in later versions, this is a pitfall; since nullable parameters always get set to null (due to how method matching works), and non-nullable values, if primitives, get set to the default values, and if not, throw a "Parameter specified as non-null is null" error on invocation.

detekt-sidekt's People

Contributors

thewisenerd avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

detekt-sidekt's Issues

Support for class level blocking annotation

Currently the configuration supports function level annotations.
However, there are some classes which I know for certain are completely blocking code e.g. SqlServer Daos.
It would be useful to have support for class level blocking annotations so that I don't need to annotate each function of the Dao.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.