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 
36     @IntDef(prefix = "REASON_", value = {
37             DEPRECATED_CODE,
38             BOILERPLATE_CODE,
39             DUMP_INFO,
40             DEBUGGING_CODE
41     })
42     @interface Reason { }
43 
44     /**
45      * The reason explaining why the code is being excluded from the code coverage report.
46      * <p>
47      * Possible reasons to exclude code from coverage report are:
48      * <p><ul>
49      * <li>{@link ExcludeFromCodeCoverageGeneratedReport#DEPRECATED_CODE} to exclude deprecated
50      * code from coverage report
51      * <li>{@link ExcludeFromCodeCoverageGeneratedReport#BOILERPLATE_CODE} to exclude boilerplate
52      * code like {@link java.lang.Object} methods, {@link android.os.Parcel} methods, etc
53      * <li>{@link ExcludeFromCodeCoverageGeneratedReport#DUMP_INFO} to exclude dump info methods
54      * <li>{@link ExcludeFromCodeCoverageGeneratedReport#DEBUGGING_CODE} to exclude debugging
55      * purpose
56      * code
57      * </ul><p>
58      */
reason()59     @Reason int reason();
60 
61     /**
62      * Optional field used to provide extra details about the excluded code (e.g. it can be used to
63      * tag a follow up bug).
64      */
details()65     String details() default "";
66 }
67