001/*-------------------------------------------------------------------------+
002|                                                                          |
003| Copyright 2005-2011 the ConQAT Project                                   |
004|                                                                          |
005| Licensed under the Apache License, Version 2.0 (the "License");          |
006| you may not use this file except in compliance with the License.         |
007| You may obtain a copy of the License at                                  |
008|                                                                          |
009|    http://www.apache.org/licenses/LICENSE-2.0                            |
010|                                                                          |
011| Unless required by applicable law or agreed to in writing, software      |
012| distributed under the License is distributed on an "AS IS" BASIS,        |
013| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
014| See the License for the specific language governing permissions and      |
015| limitations under the License.                                           |
016+-------------------------------------------------------------------------*/
017package org.conqat.engine.core.configuration;
018
019import org.conqat.lib.commons.js_export.ExportToJavaScript;
020
021/**
022 * Enum containing all available feature toggles in Teamscale. Feature toggles
023 * are enabled via System properties.
024 */
025@ExportToJavaScript
026public enum EFeatureToggle {
027
028        /**
029         * Enables the code usage widget that shows execution counts per method. This is
030         * currently only usable for ABAP projects with direct coverage report upload.
031         * The toggle will be removed once code usage analysis supports more languages.
032         */
033        CODE_USAGE_WIDGET("com.teamscale.feature-toggle.code-usage-widget"),
034
035        /**
036         * Feature configuration for coverage computations (filter coverable volumes).
037         */
038        BMW_COVERABLE_VOLUME_FILTER("bmw.teamscale.feature-toggle.coverable-volume-filter"),
039
040        /**
041         * Disable the architecture regex overlap check. Use this if you are using super
042         * huge architectures that slow down the architecture analysis significantly.
043         */
044        DISABLE_ARCHITECTURE_OVERLAP_CHECK("com.teamscale.feature-toggle.disable-architecture-overlap-check"),
045
046        /** Enables the landing page that is used for our own demo instance. */
047        ENABLE_DEMO_LANDING_PAGE("com.teamscale.landing.enable"),
048
049        /**
050         * Disable the check for sufficient memory. Doesn't make sense in some scenarios
051         * (e.g. cloud)
052         */
053        DISABLE_MEMORY_CHECK("com.teamscale.disable-memory-check"),
054
055        /**
056         * Disables the commit chart widget that shows the commits per user.
057         */
058        DISABLE_COMMIT_CHART_WIDGET("com.teamscale.feature-toggle.disable-commit-chart-widget"),
059
060        /** Disables the automatic creation of webhooks for repository connectors. */
061        DISABLE_AUTOMATIC_WEBHOOK_CREATION("com.teamscale.feature-toggle.disable-automatic-webhook-creation"),
062
063        /**
064         * Overwrite coverable lines calculated by Teamscale with information from
065         * coverage reports.
066         */
067        USE_COVERABLE_LINES_FROM_COVERAGE_REPORTS("com.teamscale.feature-toggle.use-coverable-lines-from-coverage-reports"),
068
069        /**
070         * Enables support for reading legacy ConQAT in-file review ratings.
071         */
072        ENABLE_CONQAT_INFILE_RATING("com.teamscale.feature-toggle.conqat-infile-rating"),
073
074        /** Enables support for monitoring uploads to PDash. */
075        ENABLE_MONITORING_UPLOAD("com.teamscale.enable-monitoring-uploads"),
076
077        /**
078         * Enables the execution of Roslyn Analysers from within Teamscale using RAËX.
079         */
080        ENABLE_RAEX("com.teamscale.feature-toggle.raex"),
081
082        /**
083         * Enables the merge request view.
084         */
085        ENABLE_MERGE_REQUEST_VIEW("com.teamscale.experimental.merge-request-view"),
086
087        /** Enables the developer mode. */
088        ENABLE_DEV_MODE("com.teamscale.dev-mode"),
089
090        /** Enables the experimental Clang-Tidy integration. */
091        ENABLE_CLANG_TIDY("com.teamscale.experimental.enable-clang-tidy"),
092
093        /** Enables the experimental SonarLint integration. */
094        ENABLE_SONAR_LINT("com.teamscale.experimental.enable-sonar-lint"),
095
096        /**
097         * Enables the teamscale.io mode, which enables making repositories public, adds
098         * a special role for provisioned users etc.
099         */
100        TEAMSCALE_IO_MODE("teamscale.io-mode"),
101
102        /**
103         * Allows to disable simulink dependency extraction as a work-around for
104         * TS-21836.
105         */
106        DISABLE_SIMULINK_DEPENDENCY_EXTRACTION("com.teamscale.simulink.dependency-extracion.disable"),
107
108        /**
109         * Sets the normally hidden option for the instance label server option to
110         * visible. See the InstanceLabelOption class for more info.
111         */
112        INSTANCE_LABEL_OPTION_VISIBLE("com.teamscale.instance-label-option.visible"),
113
114        /**
115         * Enables the new preprocessor.
116         */
117        USE_NEW_PREPROCESSOR("com.teamscale.experimental.new-c-preprocessor"),
118
119        /** Disable creation of default analysis profiles */
120        DISABLE_DEFAULT_ANALYSIS_PROFILES_CREATION(
121                        "com.teamscale.feature-toggle.disable-default-analysis-profiles-creation");
122
123        /**
124         * The feature toggle's id. Also used as key for the corresponding System
125         * property.
126         */
127        private final String id;
128
129        /** Returns whether the given feature toggle is enabled or not. */
130        public boolean isEnabled() {
131                return Boolean.getBoolean(id);
132        }
133
134        /** Constructor */
135        EFeatureToggle(String id) {
136                this.id = id;
137        }
138
139        /** @see #id */
140        public String getId() {
141                return id;
142        }
143
144        /** Allows to enable/disable the feature toggle. */
145        public void setFeatureToggle(boolean value) {
146                System.setProperty(id, Boolean.toString(value));
147        }
148}