Skip to content

Better quick fix to "Potential null pointer access": check if the variable is not null #4094

Open
@rcsilva83

Description

@rcsilva83

I have the following code:

String s = null;
// do conditional stuff with "s"
s.length() // "Potential null pointer access" warning

Currently VS Code offers me 2 quick fixes:

  1. "Ignore compiler problem(s)"
  2. "Add @SuppressWarnings 'null' to myMethod"

A better quick fix option would be to add a "not nulll" check before the method calling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions