Package com.tngtech.archunit.library
Class GeneralCodingRules
- java.lang.Object
-
- com.tngtech.archunit.library.GeneralCodingRules
-
public final class GeneralCodingRules extends java.lang.ObjectWhen checking these rules, it is always important to remember that all necessary classes need to be imported. E.g. ifACCESS_STANDARD_STREAMSis checked, which looks for calls on classes assignable toThrowable, it is important to ensure thatExceptionandRuntimeExceptionare imported as well, otherwise ArchUnit does not know about the inheritance structure of these exceptions, and thus will not consider a call ofRuntimeExceptiona violation, since it does not know thatRuntimeExceptionextendsThrowable. For further information refer toClassFileImporter.
-
-
Field Summary
Fields Modifier and Type Field Description static ArchCondition<JavaClass>ACCESS_STANDARD_STREAMSFor information about checking this condition, refer toGeneralCodingRules.static ArchRuleNO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMSIt is generally good practice to use correct logging instead of writing to the console.static ArchRuleNO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONSIt is generally good practice to throw specific exceptions likeIllegalArgumentExceptionor custom exceptions, instead of throwing generic exceptions likeRuntimeException.static ArchRuleNO_CLASSES_SHOULD_USE_JAVA_UTIL_LOGGINGMost projects use the more powerful LOG4J or Logback instead of java.util.logging, often hidden behind SLF4J.static ArchRuleNO_CLASSES_SHOULD_USE_JODATIMEModern Java projects use the [java.time] API instead of the JodaTime library
For information about checking this rule, refer toGeneralCodingRules.static ArchCondition<JavaClass>THROW_GENERIC_EXCEPTIONSFor information about checking this condition, refer toGeneralCodingRules.static ArchCondition<JavaClass>USE_JAVA_UTIL_LOGGINGFor information about checking this condition, refer toGeneralCodingRules.static ArchCondition<JavaClass>USE_JODATIMEFor information about checking this condition, refer toGeneralCodingRules.
-
-
-
Field Detail
-
ACCESS_STANDARD_STREAMS
@PublicAPI(usage=ACCESS) public static final ArchCondition<JavaClass> ACCESS_STANDARD_STREAMS
For information about checking this condition, refer toGeneralCodingRules.
-
NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS
@PublicAPI(usage=ACCESS) public static final ArchRule NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS
It is generally good practice to use correct logging instead of writing to the console.- Writing to the console cannot be configured in production
- Writing to the console is synchronized and can lead to bottle necks
GeneralCodingRules.
-
THROW_GENERIC_EXCEPTIONS
@PublicAPI(usage=ACCESS) public static final ArchCondition<JavaClass> THROW_GENERIC_EXCEPTIONS
For information about checking this condition, refer toGeneralCodingRules.
-
NO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONS
@PublicAPI(usage=ACCESS) public static final ArchRule NO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONS
It is generally good practice to throw specific exceptions likeIllegalArgumentExceptionor custom exceptions, instead of throwing generic exceptions likeRuntimeException.
For information about checking this rule, refer toGeneralCodingRules.
-
USE_JAVA_UTIL_LOGGING
@PublicAPI(usage=ACCESS) public static final ArchCondition<JavaClass> USE_JAVA_UTIL_LOGGING
For information about checking this condition, refer toGeneralCodingRules.
-
NO_CLASSES_SHOULD_USE_JAVA_UTIL_LOGGING
@PublicAPI(usage=ACCESS) public static final ArchRule NO_CLASSES_SHOULD_USE_JAVA_UTIL_LOGGING
Most projects use the more powerful LOG4J or Logback instead of java.util.logging, often hidden behind SLF4J. In this case it's important to ensure consistent use of the agreed logging framework.
For information about checking this rule, refer toGeneralCodingRules.
-
USE_JODATIME
@PublicAPI(usage=ACCESS) public static final ArchCondition<JavaClass> USE_JODATIME
For information about checking this condition, refer toGeneralCodingRules.
-
NO_CLASSES_SHOULD_USE_JODATIME
@PublicAPI(usage=ACCESS) public static final ArchRule NO_CLASSES_SHOULD_USE_JODATIME
Modern Java projects use the [java.time] API instead of the JodaTime library
For information about checking this rule, refer toGeneralCodingRules.
-
-