<commit_before>/*
 * Copyright 2019-present Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package com.facebook.buck.command.config;

import com.facebook.buck.core.config.BuckConfig;
import com.facebook.buck.core.config.ConfigView;
import com.facebook.buck.core.util.immutables.BuckStyleTuple;
import com.facebook.buck.util.MoreMaps;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.Map;
import org.immutables.value.Value;

/**
 * Contains configuration options that are not affecting daemon state and not causing the daemon to
 * restart.
 */
@BuckStyleTuple
@Value.Immutable(builder = false, copy = false)
public abstract class AbstractConfigIgnoredByDaemon implements ConfigView<BuckConfig> {

  @Override
  public abstract BuckConfig getDelegate();

  private static ImmutableMap<String, ImmutableSet<String>> getIgnoreFieldsForDaemonRestart() {
    ImmutableMap.Builder<String, ImmutableSet<String>> ignoreFieldsForDaemonRestartBuilder =
        ImmutableMap.builder();
    ignoreFieldsForDaemonRestartBuilder.put(
        "apple", ImmutableSet.of("generate_header_symlink_tree_only"));
    ignoreFieldsForDaemonRestartBuilder.put("build", ImmutableSet.of("threads"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "cache",
        ImmutableSet.of("dir", "dir_mode", "http_mode", "http_url", "mode", "slb_server_pool"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "client", ImmutableSet.of("id", "skip-action-graph-cache"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "intellij", ImmutableSet.of("multi_cell_module_support"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "log",
        ImmutableSet.of(
            "chrome_trace_generation",
            "compress_traces",
            "max_traces",
            "public_announcements",
            "log_build_id_to_console_enabled",
            "build_details_template",
            "build_details_commands"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "project", ImmutableSet.of("ide_prompt", "ide_force_kill"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "ui",
        ImmutableSet.of(
            "superconsole",
            "thread_line_limit",
            "thread_line_output_max_columns",
            "warn_on_config_file_overrides",
            "warn_on_config_file_overrides_ignored_files"));
    ignoreFieldsForDaemonRestartBuilder.put("color", ImmutableSet.of("ui"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "version_control", ImmutableSet.of("generate_statistics"));
    return ignoreFieldsForDaemonRestartBuilder.build();
  }

  @Value.Lazy
  public ImmutableMap<String, ImmutableMap<String, String>> getRawConfigForParser() {
    ImmutableMap<String, ImmutableSet<String>> ignoredFields = getIgnoreFieldsForDaemonRestart();
    ImmutableMap<String, ImmutableMap<String, String>> rawSections =<commit_msg>Whitelist more slb/tls related buckconfig options<commit_after>/*
 * Copyright 2019-present Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package com.facebook.buck.command.config;

import com.facebook.buck.core.config.BuckConfig;
import com.facebook.buck.core.config.ConfigView;
import com.facebook.buck.core.util.immutables.BuckStyleTuple;
import com.facebook.buck.util.MoreMaps;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.Map;
import org.immutables.value.Value;

/**
 * Contains configuration options that are not affecting daemon state and not causing the daemon to
 * restart.
 */
@BuckStyleTuple
@Value.Immutable(builder = false, copy = false)
public abstract class AbstractConfigIgnoredByDaemon implements ConfigView<BuckConfig> {

  @Override
  public abstract BuckConfig getDelegate();

  private static ImmutableMap<String, ImmutableSet<String>> getIgnoreFieldsForDaemonRestart() {
    ImmutableMap.Builder<String, ImmutableSet<String>> ignoreFieldsForDaemonRestartBuilder =
        ImmutableMap.builder();
    ignoreFieldsForDaemonRestartBuilder.put(
        "apple", ImmutableSet.of("generate_header_symlink_tree_only"));
    ignoreFieldsForDaemonRestartBuilder.put("build", ImmutableSet.of("threads"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "cache",
        ImmutableSet.of(
            "dir",
            "dir_mode",
            "http_mode",
            "http_url",
            "http_client_tls_cert_required",
            "http_client_tls_for_slb",
            "http_client_tls_cert",
            "http_client_tls_cert_env_var",
            "http_client_tls_key",
            "http_client_tls_key_env_var",
            "http_client_tls_ca",
            "http_client_tls_ca_env_var",
            "mode",
            "slb_server_pool"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "client", ImmutableSet.of("id", "skip-action-graph-cache"));
    ignoreFieldsForDaemonRestartBuilder.put("doctor", ImmutableSet.of("slb_server_pool"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "intellij", ImmutableSet.of("multi_cell_module_support"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "log",
        ImmutableSet.of(
            "chrome_trace_generation",
            "compress_traces",
            "max_traces",
            "public_announcements",
            "log_build_id_to_console_enabled",
            "build_details_template",
            "build_details_commands",
            "slb_server_pool"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "project", ImmutableSet.of("ide_prompt", "ide_force_kill"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "ui",
        ImmutableSet.of(
            "superconsole",
            "thread_line_limit",
            "thread_line_output_max_columns",
            "warn_on_config_file_overrides",
            "warn_on_config_file_overrides_ignored_files"));
    ignoreFieldsForDaemonRestartBuilder.put("color", ImmutableSet.of("ui"));
    ignoreFieldsForDaemonRestartBuilder.put(
        "version_control", ImmutableSet.of("generate_statistics"));
    return ignoreFieldsForDaemonRestartBuilder.build();
  }

  @Value.Lazy
  public ImmutableMap<String, ImmutableMap<String, String>> getRawConfigForParser() {
    ImmutableMap<String, ImmutableSet<String>> ignoredFields = getIgnoreFieldsForDaemonRestart();
    ImmutableMap<String, ImmutableMap<String, String>> rawSections =
{'fraction_non_alphanumeric': 0.09823644676681907, 'fraction_numerical': 0.00209013716525147, 'mean_word_length': 3.9746588693957117, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4556902', 'n_tokens_mistral': 2205, 'n_tokens_neox': 2168, 'n_words': 439}