Mandatory method not called after object creation

Info
Object creation must be followed by mandatory methods that must be called on the created object.
Detector ID
java/mandatory-methods@v1.0
Category
Code Quality
Tags
  • aws-java-sdk
  • maintainability
Common Weakness Enumeration (CWE) 

Noncompliant example

  public void checkParameterDescriptionAllCallNoncompliant() {
    // Noncompliant: does not call mandatory methods on the object after its creation.
    PutParameterRequest putParameterRequest = new PutParameterRequest();
    putParameterRequest.setName("parameterName");
  }

Compliant example

  public void checkParameterDescriptionAllCallCompliant() {
    // Compliant: calls the mandatory methods on the objects after its creation.
    PutParameterRequest putParameterRequest = new PutParameterRequest();
    putParameterRequest.setDescription("Description");
    putParameterRequest.setName("parameterName");
  }