01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.guard;
13:
14: import org.aspectj.lang.annotation.Aspect;
15: import org.aspectj.lang.annotation.DeclareWarning;
16:
17: /**
18: * This is an annotations based version of the ApiUsageAuditor aspect
19: *
20: * @author Sebastian Thomschke
21: */
22: @Aspect
23: public abstract class ApiUsageAuditor2 {
24: /*
25: * Rule 1: Warn about return value constraints for void methods
26: */
27: @DeclareWarning("execution(@(@net.sf.oval.constraints.Constraint *) void *.*(..))")
28: public static final String rule1 = "OVal API usage violation 1: Method return value constraints are not allowed for methods without return values";
29:
30: /*
31: * Rule 2: Warn about return value constraints for non-void, parameterized methods in classes that are not guarded
32: */
33: @DeclareWarning("execution(@(@net.sf.oval.constraints.Constraint *) !void (!@net.sf.oval.guard.Guarded *).*(*,..))")
34: public static final String rule2 = "OVal API usage violation 2: Method return value constraints for parameterized methods are only allowed in guarded classes";
35:
36: /*
37: * Rule 3: Warn about return value constraints for non-void, non-parameterized methods missing the @Invariant annotation in classes
38: * that are not guarded
39: */
40: @DeclareWarning("execution(!@net.sf.oval.configuration.annotation.IsInvariant @(@net.sf.oval.constraints.Constraint *) !void (!@net.sf.oval.guard.Guarded *).*())")
41: public static final String rule3 = "OVal API usage violation 3: Method return value constraints are only allowed if the method is annotated with @IsInvariant or the declaring class is guarded";
42:
43: /*
44: * Rule 4: Warn about the @PreValidateThis annotation used on methods in classes that are not guarded
45: */
46: @DeclareWarning("execution (@net.sf.oval.guard.PreValidateThis * (!@net.sf.oval.guard.Guarded *).*(..))")
47: public static final String rule4 = "OVal API usage violation 4: @PreValidateThis is only allowed in guarded classes";
48:
49: /*
50: * Rule 5: Warn about the @PostValidateObject annotation used on methods and constructors in classes not annotated with @Guarded
51: */
52: @DeclareWarning("execution (@net.sf.oval.guard.PostValidateThis * (!@net.sf.oval.guard.Guarded *).*(..)) || execution (@net.sf.oval.guard.PostValidateObject (!@net.sf.oval.guard.Guarded *).new(..))")
53: public static final String rule5 = "OVal API usage violation 5: @PostValidateThis is only allowed in guarded classes";
54:
55: /*
56: * Rule 6: Warn about method parameter constraints in classes that are not guarded
57: */
58: @DeclareWarning("execution(* (!@net.sf.oval.guard.Guarded *).*(@(@net.sf.oval.constraints.Constraint *) *, ..)) || execution(* (!@net.sf.oval.guard.Guarded *).*(*, @(@net.sf.oval.constraints.Constraint *) *, ..)) || execution(* (!@net.sf.oval.guard.Guarded *).*(*, *, @(@net.sf.oval.constraints.Constraint *) *, ..)) || execution(* (!@net.sf.oval.guard.Guarded *).*(*, *, *, @(@net.sf.oval.constraints.Constraint *) *, ..)) || execution(* (!@net.sf.oval.guard.Guarded *).*(*, *, *, *, @(@net.sf.oval.constraints.Constraint *) *, ..)) || execution(* (!@net.sf.oval.guard.Guarded *).*(*, *, *, *, *, @(@net.sf.oval.constraints.Constraint *) *, ..))")
59: public static final String rule6 = "OVal API usage violation 6: Method parameter constraints are only allowed in guarded classes";
60:
61: /*
62: * Rule 7: Warn about constructor parameter constraints in classes that are not guarded
63: */
64: @DeclareWarning("execution((!@net.sf.oval.guard.Guarded *).new(@(@net.sf.oval.constraints.Constraint *) *, ..)) || execution((!@net.sf.oval.guard.Guarded *).new(*, @(@net.sf.oval.constraints.Constraint *) *, ..)) || execution((!@net.sf.oval.guard.Guarded *).new(*, *, @(@net.sf.oval.constraints.Constraint *) *, ..)) || execution((!@net.sf.oval.guard.Guarded *).new(*, *, *, @(@net.sf.oval.constraints.Constraint *) *, ..)) || execution((!@net.sf.oval.guard.Guarded *).new(*, *, *, *, @(@net.sf.oval.constraints.Constraint *) *, ..)) || execution((!@net.sf.oval.guard.Guarded *).new(*, *, *, *, *, @(@net.sf.oval.constraints.Constraint *) *, ..))")
65: public static final String rule7 = "OVal API usage violation 7: Method parameter constraints are only allowed in guarded classes";
66:
67: }
|