LCOV - code coverage report
Current view: top level - server/rules - PrologOptions.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 9 9 100.0 %
Date: 2022-11-19 15:00:39 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2019 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.rules;
      16             : 
      17             : import com.google.auto.value.AutoValue;
      18             : import com.google.common.flogger.FluentLogger;
      19             : import com.google.gerrit.common.Nullable;
      20             : import java.util.Optional;
      21             : 
      22             : @AutoValue
      23         103 : public abstract class PrologOptions {
      24         152 :   private static final FluentLogger logger = FluentLogger.forEnclosingClass();
      25             : 
      26             :   public static PrologOptions defaultOptions() {
      27         103 :     return new AutoValue_PrologOptions.Builder().logErrors(true).skipFilters(false).build();
      28             :   }
      29             : 
      30             :   public static PrologOptions dryRunOptions(String ruleToTest, boolean skipFilters) {
      31           1 :     return new AutoValue_PrologOptions.Builder()
      32           1 :         .logErrors(logger.atFine().isEnabled())
      33           1 :         .skipFilters(skipFilters)
      34           1 :         .rule(ruleToTest)
      35           1 :         .build();
      36             :   }
      37             : 
      38             :   /** Whether errors should be logged. */
      39             :   abstract boolean logErrors();
      40             : 
      41             :   /** Whether Prolog filters from parent projects should be skipped. */
      42             :   abstract boolean skipFilters();
      43             : 
      44             :   /**
      45             :    * Prolog rule that should be run. If not given, the Prolog rule that is configured for the
      46             :    * project is used (the rule from rules.pl in refs/meta/config).
      47             :    */
      48             :   abstract Optional<String> rule();
      49             : 
      50             :   @AutoValue.Builder
      51         103 :   abstract static class Builder {
      52             :     abstract PrologOptions.Builder logErrors(boolean logErrors);
      53             : 
      54             :     abstract PrologOptions.Builder skipFilters(boolean skipFilters);
      55             : 
      56             :     abstract PrologOptions.Builder rule(@Nullable String rule);
      57             : 
      58             :     abstract PrologOptions build();
      59             :   }
      60             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750