• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uber / NullAway / #1105

pending completion
#1105

Pull #771

github-actions

web-flow
Merge ad670289a into 0466a02cb
Pull Request #771: Introduce FluentFutureHandler as a workaround for Guava Futures/FluentFuture

5611 of 6047 relevant lines covered (92.79%)

0.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.43
nullaway/../nullaway/src/main/java/com/uber/nullaway/handlers/Handlers.java
1
/*
2
 * Copyright (c) 2017 Uber Technologies, Inc.
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a copy
5
 * of this software and associated documentation files (the "Software"), to deal
6
 * in the Software without restriction, including without limitation the rights
7
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
 * copies of the Software, and to permit persons to whom the Software is
9
 * furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice shall be included in
12
 * all copies or substantial portions of the Software.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
 * THE SOFTWARE.
21
 */
22

23
package com.uber.nullaway.handlers;
24

25
import com.google.common.collect.ImmutableList;
26
import com.uber.nullaway.Config;
27
import com.uber.nullaway.handlers.contract.ContractCheckHandler;
28
import com.uber.nullaway.handlers.contract.ContractHandler;
29
import com.uber.nullaway.handlers.contract.fieldcontract.EnsuresNonNullHandler;
30
import com.uber.nullaway.handlers.contract.fieldcontract.RequiresNonNullHandler;
31
import com.uber.nullaway.handlers.temporary.FluentFutureHandler;
32

33
/** Utility static methods for the handlers package. */
34
public class Handlers {
35

36
  private Handlers() {}
37

38
  /**
39
   * Builds the default handler for the checker.
40
   *
41
   * @param config NullAway config
42
   * @return A {@code CompositeHandler} including the standard handlers for the nullness checker.
43
   */
44
  public static Handler buildDefault(Config config) {
45
    ImmutableList.Builder<Handler> handlerListBuilder = ImmutableList.builder();
1✔
46
    final MethodNameUtil methodNameUtil = new MethodNameUtil();
1✔
47

48
    if (config.acknowledgeRestrictiveAnnotations()) {
1✔
49
      // This runs before LibraryModelsHandler, so that library models can override third-party
50
      // bytecode annotations
51
      handlerListBuilder.add(new RestrictiveAnnotationHandler(config));
1✔
52
    }
53
    if (config.isJarInferEnabled()) {
1✔
54
      handlerListBuilder.add(new InferredJARModelsHandler(config));
1✔
55
    }
56
    if (config.handleTestAssertionLibraries()) {
1✔
57
      handlerListBuilder.add(new AssertionHandler(methodNameUtil));
1✔
58
    }
59
    handlerListBuilder.add(new GuavaAssertionsHandler());
1✔
60
    handlerListBuilder.add(new LibraryModelsHandler(config));
1✔
61
    handlerListBuilder.add(StreamNullabilityPropagatorFactory.getRxStreamNullabilityPropagator());
1✔
62
    handlerListBuilder.add(StreamNullabilityPropagatorFactory.getJavaStreamNullabilityPropagator());
1✔
63
    handlerListBuilder.add(new ContractHandler(config));
1✔
64
    handlerListBuilder.add(new ApacheThriftIsSetHandler());
1✔
65
    handlerListBuilder.add(new GrpcHandler());
1✔
66
    handlerListBuilder.add(new RequiresNonNullHandler());
1✔
67
    handlerListBuilder.add(new EnsuresNonNullHandler());
1✔
68
    if (config.serializationIsActive() && config.getSerializationConfig().fieldInitInfoEnabled) {
1✔
69
      handlerListBuilder.add(
1✔
70
          new FieldInitializationSerializationHandler(config.getSerializationConfig()));
1✔
71
    }
72
    if (config.checkOptionalEmptiness()) {
1✔
73
      handlerListBuilder.add(new OptionalEmptinessHandler(config, methodNameUtil));
1✔
74
    }
75
    if (config.checkContracts()) {
1✔
76
      handlerListBuilder.add(new ContractCheckHandler(config));
1✔
77
    }
78
    handlerListBuilder.add(new LombokHandler(config));
1✔
79
    handlerListBuilder.add(new FluentFutureHandler());
1✔
80

81
    return new CompositeHandler(handlerListBuilder.build());
1✔
82
  }
83

84
  /**
85
   * Builds an empty handler chain (used for the NullAway dummy empty constructor).
86
   *
87
   * @return An empty {@code CompositeHandler}.
88
   */
89
  public static Handler buildEmpty() {
90
    return new CompositeHandler(ImmutableList.of());
×
91
  }
92
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc