Skip to content

An Intellij plugin that adds `final` wherever is possible in Java classes

License

Notifications You must be signed in to change notification settings

seguri/final-obsession

Repository files navigation

final-obsession

Build Version Downloads

This plugin adds the final modifier to each possible local parameter and variable when you save a Java class. Fields are left untouched.

Before:

class Foo {
  int couldBeFinalField = 0;
  
  void bar(int canBeFinalParameter) {
    int canBeFinalVariable = 1;
  }
}

After:

class Foo {
  int couldBeFinalField = 0;
  
  void bar(final int canBeFinalParameter) {
           ^^^^^
    final int canBeFinalVariable = 1;
    ^^^^^
  }
}

The plugin is meant to be used as quickly as possible. It has no configuration nor UI. It's a dynamic plugin, so you can install and uninstall it without restarting IntelliJ.

Installation

You can find this plugin in the marketplace.

Q&A

Why?

Why not? Adding final wherever possible is a convention in my team. The Save Actions Plugin is archived and didn't work correctly on newer versions of the IDE. IntelliJ's new "Actions on Save" tool requires too much configuration compared to the aforementioned plugin. I wanted something simple that just works. I also wanted to learn how to write a formatting plugin, so here we are.

Thanks to


Plugin based on the IntelliJ Platform Plugin Template.

About

An Intellij plugin that adds `final` wherever is possible in Java classes

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages