1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.car.internal; 18 19 import android.annotation.IntDef; 20 21 import java.lang.annotation.ElementType; 22 import java.lang.annotation.Target; 23 24 /** 25 * Annotation used to mark code to be excluded from coverage report. 26 */ 27 @Target({ElementType.TYPE, ElementType.CONSTRUCTOR, ElementType.METHOD}) 28 public @interface ExcludeFromCodeCoverageGeneratedReport { 29 30 // Reason annotation and its associated constant values 31 int DEPRECATED_CODE = 0; 32 int BOILERPLATE_CODE = 1; 33 int DUMP_INFO = 2; 34 int DEBUGGING_CODE = 3; 35 int PRIVATE_CONSTRUCTOR = 4; 36 37 @IntDef(prefix = "REASON_", value = { 38 DEPRECATED_CODE, 39 BOILERPLATE_CODE, 40 DUMP_INFO, 41 DEBUGGING_CODE, 42 PRIVATE_CONSTRUCTOR 43 }) 44 @interface Reason { } 45 46 /** 47 * The reason explaining why the code is being excluded from the code coverage report. 48 * <p> 49 * Possible reasons to exclude code from coverage report are: 50 * <p><ul> 51 * <li>{@link ExcludeFromCodeCoverageGeneratedReport#DEPRECATED_CODE} to exclude deprecated 52 * code from coverage report 53 * <li>{@link ExcludeFromCodeCoverageGeneratedReport#BOILERPLATE_CODE} to exclude boilerplate 54 * code like {@link java.lang.Object} methods, {@link android.os.Parcel} methods, etc 55 * <li>{@link ExcludeFromCodeCoverageGeneratedReport#DUMP_INFO} to exclude dump info methods 56 * <li>{@link ExcludeFromCodeCoverageGeneratedReport#DEBUGGING_CODE} to exclude debugging 57 * <li>{@link ExcludeFromCodeCoverageGeneratedReport#PRIVATE_CONSTRUCTOR} to exclude private 58 * constructors from classes that only provide static methods 59 * purpose 60 * code 61 * </ul><p> 62 */ reason()63 @Reason int reason(); 64 65 /** 66 * Optional field used to provide extra details about the excluded code (e.g. it can be used to 67 * tag a follow up bug). 68 */ details()69 String details() default ""; 70 } 71