nullfree

Null checking library

License

License

GroupId

GroupId

com.nikialeksey
ArtifactId

ArtifactId

nullfree
Last Version

Last Version

1.4.3
Release Date

Release Date

Type

Type

jar
Description

Description

nullfree
Null checking library
Project URL

Project URL

https://github.com/nikialeksey/nullfree
Source Code Management

Source Code Management

https://github.com/nikialeksey/nullfree

Download nullfree

How to add to project

<!-- https://jarcasting.com/artifacts/com.nikialeksey/nullfree/ -->
<dependency>
    <groupId>com.nikialeksey</groupId>
    <artifactId>nullfree</artifactId>
    <version>1.4.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.nikialeksey/nullfree/
implementation 'com.nikialeksey:nullfree:1.4.3'
// https://jarcasting.com/artifacts/com.nikialeksey/nullfree/
implementation ("com.nikialeksey:nullfree:1.4.3")
'com.nikialeksey:nullfree:jar:1.4.3'
<dependency org="com.nikialeksey" name="nullfree" rev="1.4.3">
  <artifact name="nullfree" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.nikialeksey', module='nullfree', version='1.4.3')
)
libraryDependencies += "com.nikialeksey" % "nullfree" % "1.4.3"
[com.nikialeksey/nullfree "1.4.3"]

Dependencies

compile (2)

Group / Artifact Type Version
com.github.javaparser : javaparser-symbol-solver-core jar 3.13.6
org.apache.httpcomponents : httpclient jar 4.5.8

Project Modules

There are no modules declared in this project.

Nullfree

It's deprecated now and won't be supported anymore. If you want to use this type of analysis in your project then use the iwillfailyou.com

Elegant Objects Respected Here

nullfree status

Lib version Gradle plugin version Maven plugin version Build Status codecov

License: MIT

logo

What is it?

It is the service for analysing your project contains or not the null literal. With Nullfree you can add a badge to your project which looks like without nulls, if your project does not contain null, else if project contains at least one null it will looks like with nulls. There's even more, Nullfree will fail project build, if it contains a null.

For what?

Based on statistics from Overops NullPointerException is at the top of all exceptions in Java apps. It's simple: if there is no one null in a codebase, then NullPointerException will be gone. Let's stop using null!

Getting started

Gradle

Add the Nullfree plugin:

plugins {
    id 'com.nikialeksey.nullfree' version '1.5.1'
}

Invoke it:

./gradlew nullfree

Maven

Add the Nullfree plugin:

<plugin>
    <groupId>com.nikialeksey</groupId>
    <artifactId>nullfree-maven-plugin</artifactId>
    <version>1.5.1</version>
</plugin>

Invoke it:

mvn nullfree:nullfree

Add your nullfree badge to the project readme:

![nullfree status](https://iwillfailyou.com/nullfree/<your nickname>/<your repo>)

Suppress

You can suppress any null by @SuppressWarnings("nullfree") annotation:

@SuppressWarnings("nullfree")
class A {
    private final String a = null;
}

Method, field, variable suppresses are all available as well.

Other ways to ignoring nulls

Sometimes (usually in integrations with foreign libraries) it have to use null in comparisions:

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

It's ok, if you use it, NullPointerException does not throw in this place, so you can add option to Nullfree plugin for skipping such nulls:

Gradle plugin

nullfree {
    skipComparisions = true
}

Maven plugin

<plugin>
    <groupId>com.nikialeksey</groupId>
    <artifactId>nullfree-maven-plugin</artifactId>
    <version>1.5.1</version>
    <configuration>
        <skipComparisions>true</skipComparisions>
    </configuration>
</plugin>

Nulls threshold

You can the nulls threshold to allow project has a few nulls, but there would be only few.

Gradle plugin

nullfree {
    threshold = 5
}

Maven plugin

<plugin>
    <groupId>com.nikialeksey</groupId>
    <artifactId>nullfree-maven-plugin</artifactId>
    <version>1.5.1</version>
    <configuration>
        <threshold>5</threshold>
    </configuration>
</plugin>

Offline mode

You could use nullfree without badge and external service https://iwillfailyou.com/nullfree/ with offline mode

Gradle plugin

nullfree {
    offline = true
}

Maven plugin

<plugin>
    <groupId>com.nikialeksey</groupId>
    <artifactId>nullfree-maven-plugin</artifactId>
    <version>1.5.1</version>
    <configuration>
        <offline>true</offline>
    </configuration>
</plugin>

Changelog

1.4.3 - Suppress works with overrides

1.4.2 - Support all (from 1 to 12) java version syntax when parsing nulls

1.4.1 - Parsing error tips in exception message

1.4.0 - Threshold for nulls count

1.3.0 - Send null descriptions to the API instead of badge url

1.2.0 - Fail build if it contains a null

1.1.0 - Skip nulls in comparisions expressions ability

1.0.0 - Changed API of nullfree lib, null suppression ability

0.0.2 - First version of service and plugin, self checking nullfree badge

Versions

Version
1.4.3
1.4.2
1.4.1
1.4.0
1.3.0
1.2.0
1.1.0
1.0.0
0.0.2