Iwillfailyou

Elegant Objects Respected Here

nullfree status staticfree status

Build Status codecov

License: MIT

logo

What is it?

Iwillfailyou is the static analyser for your elegant code.

How it works?

Just see, what it can find in seemingly usual code:

package com.example;

import java.util.Collection;
import java.util.StringTokenizer;

public class Words {
    public static final String DELIM = " ,.";

    private Collection<String> words;

    public Words() {
        this.words = null;
    }

    public Words(Collection<String> words) {
        this.words = words;
    }

    public boolean containsIn(String text) {
        if (words == null) return false;

        StringTokenizer tokenizer = new StringTokenizer(text, DELIM);
        while (tokenizer.hasMoreTokens()) {
            String nextWord = tokenizer.nextToken();
            if (words.contains(nextWord)) return true;
        }

        return false;
    }
}

The violations of the iwillfailyou analysis:

nullfree
com.example.Words(Words.java:12) > this.words = null
com.example.Words.containsIn(Words.java:20) > words == null

staticfree
com.example.Words(Words.java:7) > public static final String DELIM = " ,.";

Get started

Gradle

Add the plugin to the root build.gradle

plugins {
    id 'com.iwillfailyou' version 'x.y.z'
}

// then configure it, if you need:
iwillfailyou {
    offline = true // default false
    nullfree {
        skipComparisions = true // default false
        threshold = 3 // default 0
    }
    staticfree {
        threshold = 3 // default 0
    }
}

Where x.y.z is actual version from gradle plugins Gradle plugin version

Invoke it:

./gradlew iwillfailyou

Maven

Add the plugin to the pom.xml

<plugin>
  <groupId>com.iwillfailyou</groupId>
  <artifactId>iwillfailyou-maven-plugin</artifactId>
  <version>x.y.z</version>

  <!-- then configure it, if you need: -->
  <configuration>
    <offline>true</offline><!-- default false -->
    <nullfree>
      <skipComparisions>true</skipComparisions><!-- default false -->
      <threshold>3</threshold><!-- default 0 -->
    </nullfree>
    <staticfree>
      <threshold>3</threshold><!-- default 0 -->
    </staticfree>
  </configuration>
</plugin>

Invoke it:

mvn iwillfailyou:iwillfailyou

Where x.y.z is actual version from maven central Maven plugin version

Inspections

  1. nullfree (Why null is bad?) elegant code must not use the null keywords

  2. staticfree (Why static is bad?) elegant code must not use the static keywords

  3. 🔄 allfinal [in progress] every class, every field, every argument, every local variable must be final in the elegant code

  4. 🔄 instanceoffree [in progress] elegant code must not use the instanceof keywords

  5. 🔄 inheritancefree [in progress] elegant code must not use the class inheritance (when one class extends another one), only composition and type inheritance has been allowed

  6. 🔄 enumfree [in progress] elegant code must not use the enums

  7. 🔄 nomultiplereturn [in progress] elegant code must contain only one (or no one) return in an any method

  8. 🔄 getterfree [in progress] elegant code must not contain any getters

  9. 🔄 setterfree [in progress] elegant code must not contain any getters

  10. 🔄 privatefree [in progress] elegant code must not use the private methods

  11. 🔄 nopublicmethodnotoverrides [in progress] every public method in the elegant code must be overrided from an interface

Nullfree

Plugin configuration options:

if (some == null) {
    ...
}

Can be suppressed in the code by @SuppressWarnings("nullfree")

Staticfree

Plugin configuration options:

Can be suppressed in the code by @SuppressWarnings("nullfree")

Badges

If you use iwillfailyou plugin without offline = true settings, then you can attach the inspection badges to your readme file:

License

MIT