Forbid using standard streams in archunit (#11130)

This commit is contained in:
agilob 2021-12-17 02:11:36 +00:00 committed by GitHub
parent c27ddc67fe
commit ebb69147a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -430,7 +430,6 @@ public class DartDioNextClientCodegen extends AbstractDartCodegen {
* @param serializer
*/
private void addBuiltValueSerializer(BuiltValueSerializer serializer) {
System.out.println("######## Add serializer!");
additionalProperties.compute("builtValueSerializers", (k, v) -> {
Set<BuiltValueSerializer> serializers = v == null ? Sets.newHashSet() : ((Set<BuiltValueSerializer>) v);
serializers.add(serializer);

View File

@ -4,6 +4,7 @@ import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.domain.JavaModifier;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.library.GeneralCodingRules;
import org.junit.Test;
import org.slf4j.Logger;
@ -19,6 +20,14 @@ public class ArchUnitRulesTest {
ArchUnitRulesTest.LOGGERS_SHOULD_BE_NOT_PUBLIC_NOT_STATIC_AND_FINAL.check(importedClasses);
}
@Test
public void classesNotAllowedToUseStandardStreams() {
final JavaClasses importedClasses = new ClassFileImporter()
.importPackages("org.openapitools.codegen.languages");
GeneralCodingRules.NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS.check(importedClasses);
}
@Test
public void abstractClassesAreAbstract() {
final JavaClasses importedClasses = new ClassFileImporter()

View File

@ -0,0 +1,2 @@
# This rule is for ArchUnitRulesTest.classesNotAllowedToUseStandardStreams to ignore method `postProcess()` of CodegenConfig as it contains funding information
.*\.postProcess\(\).*