@@ -39,13 +39,11 @@ class ImpureStmt extends Stmt {
3939 ImpureStmt ( ) {
4040 exists ( Expr e | e .getEnclosingStmt ( ) = this |
4141 // Only permit calls to set of whitelisted targets.
42- (
43- e instanceof Call and
44- not e .( Call ) .getCallee ( ) .getDeclaringType ( ) .hasQualifiedName ( "java.util" , "Collections" )
45- )
42+ e instanceof Call and
43+ not e .( Call ) .getCallee ( ) .getDeclaringType ( ) .hasQualifiedName ( "java.util" , "Collections" )
4644 or
4745 // Writing to a field that is not an instance field is a no-no
48- ( e instanceof FieldWrite and not e instanceof InstanceFieldWrite )
46+ e instanceof FieldWrite and not e instanceof InstanceFieldWrite
4947 )
5048 }
5149}
@@ -68,22 +66,20 @@ private Stmt getANestedStmt(Block block) {
6866 */
6967class SpringPureClass extends Class {
7068 SpringPureClass ( ) {
71- (
72- // The only permitted statement in static initializers is the initialization of a static
73- // final or effectively final logger fields, or effectively immutable types.
74- forall ( Stmt s | s = getANestedStmt ( getAMember ( ) .( StaticInitializer ) .getBody ( ) ) |
75- exists ( Field f | f = s .( ExprStmt ) .getExpr ( ) .( AssignExpr ) .getDest ( ) .( FieldWrite ) .getField ( ) |
76- (
77- // A logger field
78- f .getName ( ) .toLowerCase ( ) = "logger" or
79- f .getName ( ) .toLowerCase ( ) = "log" or
80- // An immutable type
81- f .getType ( ) instanceof ImmutableType
82- ) and
83- f .isStatic ( ) and
84- // Only written to in this statement e.g. final or effectively final
85- forall ( FieldWrite fw | fw = f .getAnAccess ( ) | fw .getEnclosingStmt ( ) = s )
86- )
69+ // The only permitted statement in static initializers is the initialization of a static
70+ // final or effectively final logger fields, or effectively immutable types.
71+ forall ( Stmt s | s = getANestedStmt ( getAMember ( ) .( StaticInitializer ) .getBody ( ) ) |
72+ exists ( Field f | f = s .( ExprStmt ) .getExpr ( ) .( AssignExpr ) .getDest ( ) .( FieldWrite ) .getField ( ) |
73+ (
74+ // A logger field
75+ f .getName ( ) .toLowerCase ( ) = "logger" or
76+ f .getName ( ) .toLowerCase ( ) = "log" or
77+ // An immutable type
78+ f .getType ( ) instanceof ImmutableType
79+ ) and
80+ f .isStatic ( ) and
81+ // Only written to in this statement e.g. final or effectively final
82+ forall ( FieldWrite fw | fw = f .getAnAccess ( ) | fw .getEnclosingStmt ( ) = s )
8783 )
8884 ) and
8985 // No constructor, instance initializer or Spring bean init or setter method that is impure.
@@ -145,12 +141,10 @@ class SpringBeanFactory extends ClassOrInterface {
145141class LiveSpringBean extends SpringBean {
146142 LiveSpringBean ( ) {
147143 // Must not be needed for side effects due to construction
148- (
149- // Only loaded by the container when required, so construction cannot have any useful side-effects
150- not isLazyInit ( ) and
151- // or has no side-effects when constructed
152- not getClass ( ) instanceof SpringPureClass
153- )
144+ // Only loaded by the container when required, so construction cannot have any useful side-effects
145+ not isLazyInit ( ) and
146+ // or has no side-effects when constructed
147+ not getClass ( ) instanceof SpringPureClass
154148 or
155149 (
156150 // If the class does not exist for this bean, or the class is not a source bean, then this is
0 commit comments