Angela Schreiber created SLING-9974:
---------------------------------------

             Summary: Add nullability annotations 
                 Key: SLING-9974
                 URL: https://issues.apache.org/jira/browse/SLING-9974
             Project: Sling
          Issue Type: Improvement
          Components: Content-Package to Feature Model Converter
            Reporter: Angela Schreiber


the code in the "Content-Package to Feature Model Converter" should come with 
nullabillity annotations for method parameters and return values.

take for example 
[https://github.com/apache/sling-org-apache-sling-feature-cpconverter/blob/master/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java#L142-L165:]
 * first checks for list of 'authorizations being null (line 147)
 * on line 160 calls 'addPath', which turn calls 'areEmpty' (i.e. checks for 
null or empty)
 * on line 164 calls 'addAclStatement', which in turn checks for null again and 
also calls 'areEmpty' (ie. checks for null or empty, see also SLING-9973)

if my counting is correct:
 * 4 times testing if the given list is null
 * 2 times testing if the given list is empty

where it could be just 1 single call to 'areEmpty' at the beginning of  the top 
method {{addStatements}} and return if that condition was met. i wouldn't be 
surprised if similar things could be found elsewhere in the module.

IMHO consistently using notnull/nullable annotations and being conscious about 
it helps to prevent that kind of mistakes and makes the code more robust, 
easier to test and to read.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to