Our website uses cookies to enhance your browsing experience.
Accept
to the top

Webinar: Let's make a programming language. Lexer - 29.04

>
>
>
Examples of errors detected by the...

Examples of errors detected by the V6036 diagnostic

V6036. The value from the uninitialized optional is used.


OpenAPI Generator

V6036 The value from the uninitialized 'op.pathParams.stream().filter(p -> p.paramName.equals(pathParam)).findFirst()' optional is used. ScalaCaskServerCodegen.java 1021


private static CodegenParameter pathParamForName(
  CodegenOperation op,
  String pathParam
) {
  final CodegenParameter
    param = op.pathParams.stream()
                         .filter(p -> p.paramName.equals(pathParam))
                         .findFirst()
                         .get();
  if (param == null) {
    throw new RuntimeException("Bug: path param " + pathParam + " not found");
  }
  return param;
}

XMage

V6036 The value from the uninitialized 'selectUser' optional is used. Session.java(227)


public String connectUserHandling(String userName, String password)
{
  ....
  if (!selectUser.isPresent()) {  // user already exists
      selectUser = UserManager.instance.getUserByName(userName);
      if (selectUser.isPresent()) {
          User user = selectUser.get();
            ....
      }
  }
  User user = selectUser.get();
  ....
}