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  * @hide
28  */
29 @Target({ElementType.TYPE, ElementType.CONSTRUCTOR, ElementType.METHOD})
30 public @interface ExcludeFromCodeCoverageGeneratedReport {
31 
32     // Reason annotation and its associated constant values
33     int DEPRECATED_CODE = 0;
34     int BOILERPLATE_CODE = 1;
35     int DUMP_INFO = 2;
36     int DEBUGGING_CODE = 3;
37     int PRIVATE_CONSTRUCTOR = 4;
38 
39     @IntDef(prefix = "REASON_", value = {
40             DEPRECATED_CODE,
41             BOILERPLATE_CODE,
42             DUMP_INFO,
43             DEBUGGING_CODE,
44             PRIVATE_CONSTRUCTOR
45     })
46     @interface Reason { }
47 
48     /**
49      * The reason explaining why the code is being excluded from the code coverage report.
50      * <p>
51      * Possible reasons to exclude code from coverage report are:
52      * <p><ul>
53      * <li>{@link ExcludeFromCodeCoverageGeneratedReport#DEPRECATED_CODE} to exclude deprecated
54      * code from coverage report
55      * <li>{@link ExcludeFromCodeCoverageGeneratedReport#BOILERPLATE_CODE} to exclude boilerplate
56      * code like {@link java.lang.Object} methods, {@link android.os.Parcel} methods, etc
57      * <li>{@link ExcludeFromCodeCoverageGeneratedReport#DUMP_INFO} to exclude dump info methods
58      * <li>{@link ExcludeFromCodeCoverageGeneratedReport#DEBUGGING_CODE} to exclude debugging
59      * <li>{@link ExcludeFromCodeCoverageGeneratedReport#PRIVATE_CONSTRUCTOR} to exclude private
60      * constructors from classes that only provide static methods
61      * purpose
62      * code
63      * </ul><p>
64      */
reason()65     @Reason int reason();
66 
67     /**
68      * Optional field used to provide extra details about the excluded code (e.g. it can be used to
69      * tag a follow up bug).
70      */
details()71     String details() default "";
72 }
73