Skip to content

Miha-x64/Mikes_IDEA_extensions

Repository files navigation

Mike's IDE extensions

IntelliJ IDEA Plugin IntelliJ IDEA Plugin

This plugin focuses on finding subtle bugs, performance pitfalls, and API misuse that standard inspections often miss in Java, Kotlin, and Android projects.

It's developed for myself developers who care about performance, memory usage, correctness, and want their IDE to actively point out non-obvious problems and better alternatives while they code.

UAST (Java + Kotlin) inspections

  • Atomic can be replaced with volatile
  • Allocation should be cached (Gson(), OkHttpClient())
  • BigDecimal|BigInteger instantiation can be replaced with constant by stokito
  • (BigDecimal|BigInteger).compareTo(ZERO) can be replaced with signum() by stokito

Kotlin inspections

  • Heavyweight property delegation
  • Declaration name is Java keyword
  • Inline function leaks anonymous declaration which will be inlined to the call-site if called from another module
  • Anonymous function won't be inlined; function cannot be inlined if it is a receiver of an extension function
  • Nullable argument to string concatenation should be re-implemented in more reliable way
  • Boxed primitive array allocation (arrayOf(1, 2, 3))

Android inspections

  • <include layout="?themeAttribute"> requires Marshmallow
  • <drawable android:tint> requires Lollipop
  • <layer-list><item android:gravity> requires Marshmallow
  • @TargetApi should be replaced with @RequiresApi
  • Use of reflective ObjectAnimator/PropertyValuesHolder
  • Use of attributes like android.R.attr.enabled in context where state attributes expected, like android.R.attr.state_enabled
  • Color.parseColor(<constexpr>) or <constexpr>.toColorInt() should be replaced with an integer literal
  • Useless resource element
    • Drawables: single-item layer-lists, single stateless item selectors, insetless insets, empty shapes
    • Vector drawables: empty paths and clip-paths, invisible paths, suboptimal paths, useless clip-paths and groups, attributes with no effect
    • Animations and animators: empty and single-element sets
    • Layouts: suspicious combination of (layout_margin|padding)(Left|Top|Right|Bottom|Start|End|Horizontal|Vertical|*)
  • Android TextUtils methods should be replaced with Kotlin extensions
  • setOnClickListener doesn't work on RecyclerView, on VideoView before API 26
  • Kotlin Android Extensions are deprecated
  • Drawable subclass should override getConstantState()
  • Activity#onCreate(, PersistableBundle) will highly likely not be called
  • <AnyScrollableView> should have an ID to save its scroll position
  • Context.obtainStylesAttributes|Context.withStyledAttributes need a sorted array

Regexp inspections

  • Ranges [А-Я], [а-я] do not cover any of Cyrillic alphabets, some letters are out of range

Editor features

  • Inlay hints when upcasting to interface, e.g.
    putExtra(listas Serializable)
  • Inlay hints when overriding an interface method, e.g.
    @Override from Runnable,
    override fun Runnable.run()
  • Inlay hints for vararg array allocation:
    String.format("%d", new[]{1});
    maxOf(1, *[2, 3, 4])
  • ARGB Color swatches in gutter, folding int literals to #[AA]RRGGBB, color picker, pasting CSS colors as int literals
  • Backing property folding for Kotlin
  • Live templates for SVG and Android Vector Drawable pathData
  • Live templates for implementing Property for ObjectAnimator

Plugin page on JetBrains marketplace
Alternatively, new versions are announced on and uploaded to my Telegram channel

About

IntelliJ IDEA: missing parts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5