<commit_before>import { getConfigProperties, getMaterialIconsJSON, getThemeConfig, promptToReload } from '.';
import { createIconFile } from '../icons/index';
import { IconJsonOptions } from '../models';
import * as versioning from './../helpers/versioning';
import { getObjectPropertyValue, setObjectPropertyValue } from './objects';

/** Compare the workspace and the user configurations with the current setup of the icons. */
export const detectConfigChanges = () => {
    const changes = compareConfigs();

    // if there's nothing to update
    if (Object.keys(changes.updatedConfigs).length === 0) return;

    try {
        // update icon json file with new options
        createIconFile(changes.updatedConfigs, changes.updatedJSONConfig);
    } catch (error) {
        console.error(error);
    }
};

/**
 * Compares a specific configuration in the settings with a current configuration state.
 * The current configuration state is read from the icons json file.
 * @returns List of configurations that needs to be updated.
 */
const compareConfigs = (): { updatedConfigs: IconJsonOptions; updatedJSONConfig: IconJsonOptions } => {
    const configs = Object.keys(getConfigProperties())
        .map(c => c.split('.').slice(1).join('.'))
        // remove configurable notification messages
        .filter((c) => !/show(Welcome|Update|Reload)Message/g.test(c));

    const json = getMaterialIconsJSON();
    return configs.reduce((result, configName) => {
        try {
            const themeConfig = getThemeConfig(configName);
            const configValue = themeConfig.globalValue ?? themeConfig.defaultValue;
            const currentState = getObjectPropertyValue(json.options, configName);

            if (JSON.stringify(configValue) !== JSON.stringify(currentState)) {
                setObjectPropertyValue(json.options, configName, configValue);
                setObjectPropertyValue(result.updatedConfigs, configName, configValue);
            }
        } catch (error) {
            console.error(error);
        }

        return result;
    }, { updatedConfigs: {}, updatedJSONConfig: json.options });
};
<commit_msg>Remove unused imports<commit_after>import { getConfigProperties, getMaterialIconsJSON, getThemeConfig } from '.';
import { createIconFile } from '../icons/index';
import { IconJsonOptions } from '../models';
import { getObjectPropertyValue, setObjectPropertyValue } from './objects';

/** Compare the workspace and the user configurations with the current setup of the icons. */
export const detectConfigChanges = () => {
    const changes = compareConfigs();

    // if there's nothing to update
    if (Object.keys(changes.updatedConfigs).length === 0) return;

    try {
        // update icon json file with new options
        createIconFile(changes.updatedConfigs, changes.updatedJSONConfig);
    } catch (error) {
        console.error(error);
    }
};

/**
 * Compares a specific configuration in the settings with a current configuration state.
 * The current configuration state is read from the icons json file.
 * @returns List of configurations that needs to be updated.
 */
const compareConfigs = (): { updatedConfigs: IconJsonOptions; updatedJSONConfig: IconJsonOptions } => {
    const configs = Object.keys(getConfigProperties())
        .map(c => c.split('.').slice(1).join('.'))
        // remove configurable notification messages
        .filter((c) => !/show(Welcome|Update|Reload)Message/g.test(c));

    const json = getMaterialIconsJSON();
    return configs.reduce((result, configName) => {
        try {
            const themeConfig = getThemeConfig(configName);
            const configValue = themeConfig.globalValue ?? themeConfig.defaultValue;
            const currentState = getObjectPropertyValue(json.options, configName);

            if (JSON.stringify(configValue) !== JSON.stringify(currentState)) {
                setObjectPropertyValue(json.options, configName, configValue);
                setObjectPropertyValue(result.updatedConfigs, configName, configValue);
            }
        } catch (error) {
            console.error(error);
        }

        return result;
    }, { updatedConfigs: {}, updatedJSONConfig: json.options });
};

{'fraction_non_alphanumeric': 0.1132655474107354, 'fraction_numerical': 0.0009458500827618822, 'mean_word_length': 3.2641129032258065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4529542', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1054, 'n_words': 296}