Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-4026

FP in S2637 with user defined preconditions

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Symbolic Execution
    • Labels:
      None

      Description

      When a user defines preconditions in a separate file, the symbolic execution engine is not able to understand that the value assigned to a field can never be null.

      File 1:

      public class Job {
         private @NonNull String name;
      
         public Job(@Nullable String jobName) {
            this.name = checkNotNull(jobName, "Name cannot be null");
         }
      }
      

      File 2:

      public static <T> @NonNull T checkNotNull(@Nullable T value, @NonNull String message) {
         if (value == null)
            throw new NullPointerException(message);
         return (value);
      }
      

      Full reproducer (from community user starkos): https://github.com/starkos/sonarlint-s2637

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              quentin.jaquier Quentin Jaquier
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: