patterntesting.check.ct.exception.ExceptionAspect.aj Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of patterntesting-check-ct Show documentation
Show all versions of patterntesting-check-ct Show documentation
PatternTesting Check.CT (patterntesting-check-ct) is a quality framework that
allows to automatically verify that Architecture/Design recommendations
are implemented correctly in the code.
It provides different checks of known anti patterns (like using System.out
for logging) but provides also a test framework for better testing.
The checks are done during compile time (this is the "CT" in Check.CT").
/*
* $Id: ExceptionAspect.aj,v 1.1 2012/08/12 17:48:45 oboehm Exp $
*
* Copyright (c) 2012 by Oliver Boehm
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* (c)reated 11.08.2012 by oliver ([email protected])
*/
package patterntesting.check.ct.exception;
import patterntesting.annotation.check.ct.SuppressExceptionWarning;
/**
* Methods and Constructors should not throw an Exception, a Throwable or either
* an Error. They should throw a specific Exception. Also if you throw an
* exception: don't use the general {@link RuntimeException}, {@link Exception}
* {@link Throwable} or {@link Error}. Use a more specific one.
*
* @author oliver ([email protected])
* @since 1.3 (11.08.2012)
* @version $Revision: 1.1 $
*/
public aspect ExceptionAspect extends AbstractExceptionAspect {
/**
* For every class, every constructor and every method which is not marked
* by @SuppressExceptionWarning
a warning should be printed if
* the signature contains a ... throws Exception
or a similar
* unspecific exception.
*
* @see SuppressExceptionWarning
*/
public pointcut applicationCode() :
!(@within(SuppressExceptionWarning)
|| @withincode(SuppressExceptionWarning)
|| execution(@SuppressExceptionWarning * *..*.*(..))
|| execution(@SuppressExceptionWarning *..*.new(..))
);
}