]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9478 Deprecate Settings and introduce new Configuration interface
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 29 Jun 2017 13:08:28 +0000 (15:08 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 4 Jul 2017 21:47:46 +0000 (23:47 +0200)
387 files changed:
plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/XooTokenizerTest.java
server/sonar-ce/src/test/java/org/sonar/ce/cluster/HazelcastClientWrapperImplTest.java
server/sonar-server/src/main/java/org/sonar/ce/settings/ProjectSettings.java
server/sonar-server/src/test/java/org/sonar/ce/http/CeHttpClientTest.java
server/sonar-server/src/test/java/org/sonar/server/app/ProcessCommandWrapperImplTest.java
server/sonar-server/src/test/java/org/sonar/server/authentication/JwtHttpHandlerTest.java
server/sonar-server/src/test/java/org/sonar/server/authentication/JwtSerializerTest.java
server/sonar-server/src/test/java/org/sonar/server/authentication/RealmAuthenticatorTest.java
server/sonar-server/src/test/java/org/sonar/server/authentication/SsoAuthenticatorTest.java
server/sonar-server/src/test/java/org/sonar/server/authentication/UserIdentityAuthenticatorTest.java
server/sonar-server/src/test/java/org/sonar/server/authentication/UserSessionInitializerTest.java
server/sonar-server/src/test/java/org/sonar/server/authentication/ws/ValidateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/dbcleaner/ProjectCleanerTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/api/measurecomputer/MeasureComputerContextImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/SettingsRepositoryTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/DefaultAssigneeTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/ScmAccountToUserLoaderTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/filter/IssueFilterTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitymodel/RatingSettingsTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PurgeDatastoresStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateLoadingStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookPostTaskTest.java
server/sonar-server/src/test/java/org/sonar/server/es/EsClientProviderTest.java
server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java
server/sonar-server/src/test/java/org/sonar/server/es/IndexCreatorTest.java
server/sonar-server/src/test/java/org/sonar/server/es/IndexerStartupTaskTest.java
server/sonar-server/src/test/java/org/sonar/server/es/NewIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueUpdaterTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDefinitionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/notification/IssueChangesEmailTemplateTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/AuthorsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/TagsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/notification/NotificationDaemonTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationCreationImplTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/RemoveMemberActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/ServerIdLoaderTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/ServerLoggingTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/UrlSettingsTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/cluster/ClusterImplTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseFactoryTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/EsMonitorTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/SettingsMonitorTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/SonarQubeMonitorTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkUpdateKeyActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexDefinitionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/TagsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ProjectSettingsFactoryTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java
server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java
server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java
server/sonar-server/src/test/java/org/sonar/server/ui/ws/SettingsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java
server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java
server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexDefinitionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/util/OkHttpClientProviderTest.java
server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexDefinitionTest.java
server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java
sonar-core/src/test/java/org/sonar/core/timemachine/PeriodsTest.java
sonar-core/src/test/java/org/sonar/core/util/DefaultHttpDownloaderTest.java
sonar-plugin-api/src/main/java/org/sonar/api/Properties.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtRemediationFunction.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobContext.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/internal/DefaultCpdTokens.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
sonar-plugin-api/src/main/java/org/sonar/api/config/Configuration.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/config/EmailSettings.java
sonar-plugin-api/src/main/java/org/sonar/api/config/MapSettings.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java
sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java
sonar-plugin-api/src/main/java/org/sonar/api/config/internal/ConfigurationBridge.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/config/internal/MapSettings.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileExclusions.java
sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java
sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/cpd/internal/DefaultCpdTokensTest.java
sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
sonar-plugin-api/src/test/java/org/sonar/api/config/EmailSettingsTest.java
sonar-plugin-api/src/test/java/org/sonar/api/config/MapSettingsTest.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java [new file with mode: 0644]
sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/FileExclusionsTest.java
sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/ProjectAnalysisInfo.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/AnalysisTempFolderProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalProperties.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalSettings.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MetricProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MutableGlobalSettings.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerExtensionDictionnary.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploder.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginPredicate.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/UserProperties.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/config/CsvParser.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/config/package-info.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/DuplicationPredicates.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/CpdMappings.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/DefaultCpdBlockIndexer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/JavaCpdBlockIndexer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/DeprecatedSensorContext.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/ScannerPerspectives.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/events/EventBus.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/index/DefaultIndex.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueCallback.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueFilterChain.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultProjectIssues.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DeprecatedIssueAdapterForFilter.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DeprecatedIssueFilterChain.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssueCache.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssueFilters.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ModuleIssues.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/EnforceIssuesFilter.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/IgnoreIssuesFilter.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/AbstractPatternInitializer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueInclusionPatternInitializer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssuePattern.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/LineRange.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/PatternDecoder.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/PatternMatcher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoader.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/tracking/DefaultServerLineHashesLoader.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/tracking/IssueTrackingInput.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/tracking/IssueTransition.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/tracking/TrackedIssue.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/TaskResult.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/InitializersExecutor.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/SensorsPhaseEvent.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/DefaultPostJobContext.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ContextPropertiesPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionAndCoveragePublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultQualityProfileLoader.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/QualityProfileLoader.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/LanguagesRepository.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRulesLoader.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ModuleQProfiles.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/QProfile.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/QProfileVerifier.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RuleFinderCompatibility.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesProfileProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesProfileWrapper.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DefaultInputModuleHierarchy.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettings.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettingsProvider.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectLock.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettings.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettingsProvider.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/WorkDirectoryCleaner.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/BatchIdGenerator.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ByteCharsetDetector.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/CharsetDetector.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/DefaultModuleFileSystem.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/SameInputFilePredicate.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/MeasureCache.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ConsoleReport.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/HtmlReport.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReport.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ReportRuleKey.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ResourceReport.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/RuleNameProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/RuleReport.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmConfiguration.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/SensorOptimizer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/coverage/CoverageExclusions.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/storage/Storages.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/task/Tasks.java
sonar-scanner-engine/src/test/java/org/sonar/batch/bootstrapper/BatchTest.java
sonar-scanner-engine/src/test/java/org/sonar/batch/bootstrapper/EnvironmentInformationTest.java
sonar-scanner-engine/src/test/java/org/sonar/batch/bootstrapper/LogCallbackAppenderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/ProjectAnalysisInfoTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/WsTestUtil.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/analysis/AnalysisTempFolderProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/analysis/DefaultAnalysisModeTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DroppedPropertyCheckerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionUtilsTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/FileCacheProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java [new file with mode: 0644]
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalContainerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalModeTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalPropertiesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalSettingsTest.java [deleted file]
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/MetricProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginPredicateTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginRepositoryTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdComponentsTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/DuplicationPredicatesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/deprecated/DefaultCpdBlockIndexerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/deprecated/JavaCpdBlockIndexerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/events/BatchStepEventTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/events/EventBusTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/index/AbstractCachesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/index/DefaultIndexTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultFilterableIssueTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultIssueCallbackTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultIssueFilterChainTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultProjectIssuesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DeprecatedIssueAdapterForFilterTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DeprecatedIssueFilterChainTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ModuleIssuesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/TrackedIssueAdapterTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/EnforceIssuesFilterTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/IgnoreIssuesFilterTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/IssueInclusionPatternInitializerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/IssuePatternTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/LineRangeTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/PatternDecoderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/PatternMatcherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoaderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScannerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/tracking/RollingFileHashesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/tracking/SourceHashHolderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/tracking/TrackedIssueTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/LogOutputRecorder.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/NoLanguagesPluginsMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/ProjectBuilderMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/IssuesIssuesModeMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issuesmode/EmptyFileTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issuesmode/IssueModeAndReportsMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issuesmode/NoPreviousAnalysisTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issuesmode/ScanOnlyChangedTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/scm/ScmMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tests/CoveragePerTestMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/PostJobsExecutorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/SensorsExecutorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/PostJobOptimizerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/profiling/PhasesSumUpTimeProfilerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ActiveRulesPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/AnalysisContextReportPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ContextPropertiesPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultQualityProfileLoaderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/RuleFinderCompatibilityTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/RulesProfileProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/RulesProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/DefaultComponentTreeTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/DefaultInputModuleHierarchyTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleSettingsTest.java [deleted file]
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableModuleSettingsTest.java [new file with mode: 0644]
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableProjectSettingsTest.java [new file with mode: 0644]
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectBuildersExecutorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectLockTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectScanContainerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectSettingsTest.java [deleted file]
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/WorkDirectoryCleanerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/AdditionalFilePredicatesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ByteCharsetDetectorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetValidationTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ExclusionFiltersTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputFileBuilderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/LanguageDetectionTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/StatusDetectionFactoryTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/StatusDetectionTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/ConsoleReportTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/RuleNameProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/DefaultBlameOutputTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/SensorOptimizerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/coverage/CoverageExclusionsTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/source/DefaultHighlightableTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/source/DefaultSymbolizableTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/source/DeprecatedDefaultSymbolTableTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/storage/StorageTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/storage/StoragesManagerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/storage/StoragesTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/task/ListTaskTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/task/TasksTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ScannerUtilsTest.java

index 967f87dafdbc52b39ee86b6459ab1c1696db5fbe..cb6b6ec94a5daae7c836ee4d662835e4d31f11ad 100644 (file)
@@ -35,8 +35,8 @@ import org.sonar.api.batch.fs.internal.DefaultFileSystem;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.duplications.cpd.FileCodeLoaderWithoutCache;
 
 import static org.assertj.core.api.Assertions.assertThat;
index b86fe768c947a5a1d92eef4da08dd5108defe5bc..1267693e9e1de9f3134f2d3493cd6d207732c1a1 100644 (file)
@@ -50,9 +50,9 @@ import org.junit.rules.ExpectedException;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.process.NetworkUtils;
 import org.sonar.process.ProcessProperties;
 
index 38748c6f3eaaf34a23f8d5e0331985ce75c4e985..46ffc995a2ee557e758d0dae2b2f9750cd79906c 100644 (file)
@@ -24,9 +24,10 @@ import java.util.Map;
 import java.util.Optional;
 import org.sonar.api.ce.ComputeEngineSide;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.SettingsReader;
 
 @ComputeEngineSide
-public class ProjectSettings extends Settings {
+public class ProjectSettings extends Settings implements SettingsReader {
 
   private final Map<String, String> projectProps = new HashMap<>();
   private final Settings globalSettings;
index 98b3dfcf2076b676cb5abe0949f8a18e4ed28760..e6c8c25247fac59ff3bcf41f3dde653701ceeddd 100644 (file)
@@ -30,8 +30,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.process.DefaultProcessCommands;
 import org.sonar.process.ProcessEntryPoint;
index 8572c04fc50c121f89863fb8c23caa84c2d8e84c..223b965fcfff6c59cde780120a504fcaca42cc46 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.process.DefaultProcessCommands;
 
 import static org.assertj.core.api.Assertions.assertThat;
index 842600bbf5c2db192a617a79f0c00e9e5996d710..6d552b4aa9a2bf7dd76424a132f2bd07957e4062 100644 (file)
@@ -33,8 +33,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
index 9095b04f43c03d75ec323bf91c8ddd9f2c4a50d0..0c3a97f8c02c863967fba80b3e332e1a057c4b45 100644 (file)
@@ -32,8 +32,8 @@ import javax.crypto.spec.SecretKeySpec;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.util.UuidFactory;
index 61f87fd593e702756150e8189afd07c9a4255002..45c19a9ace3e216081c316f0e14be7e44db022df 100644 (file)
@@ -25,8 +25,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.security.Authenticator;
 import org.sonar.api.security.ExternalGroupsProvider;
 import org.sonar.api.security.ExternalUsersProvider;
index ddd673119d4f5ccf47bb8d227fff9528344f71d7..3cd623bd8a2982aeaeb2a18daefd39a723d29a75 100644 (file)
@@ -31,8 +31,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.internal.AlwaysIncreasingSystem2;
 import org.sonar.core.util.stream.MoreCollectors;
index f54e0f93ff48e7e380bfdbd97caf453c7a94b109..9f84bab5786159b3f15c549cbd1e9571cd71eea7 100644 (file)
@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.authentication.UserIdentity;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.internal.AlwaysIncreasingSystem2;
index 8a669ce9779adb068f8a468c1f7241a50090ba0d..4f16213740931777549232d4f0b900a31c3d8e52 100644 (file)
@@ -26,8 +26,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.authentication.BaseIdentityProvider;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
index 745ee860146e3308f13bc4af7a565c219a20760c..414195baff8d1ce07b3278818ec3aac0dedd8672 100644 (file)
@@ -27,8 +27,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import org.junit.Before;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.server.authentication.BasicAuthenticator;
 import org.sonar.server.authentication.JwtHttpHandler;
 import org.sonar.server.authentication.event.AuthenticationException;
index 576821ca300ea8275c163c6efe3fae75f0b71264..4fca15eacc432e402acbef42e4399a9b1840ee1a 100644 (file)
@@ -24,7 +24,7 @@ import java.io.IOException;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.System2;
 import org.sonar.api.web.UserRole;
index 49b79d4b857bbf686719a1d0be80e9f6ea505af7..a467d42b4408805f963963b162ff400916abc47b 100644 (file)
@@ -26,7 +26,7 @@ import java.util.stream.Collectors;
 import org.assertj.core.api.AbstractListAssert;
 import org.junit.Before;
 import org.junit.Rule;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
index 925de147601850736ad9a109ae8318aad105c944..7324b52cce2a37c244b930c980e8b0b1f9c35fc4 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.server.component.index;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
index 18608c01696ec068e1ba2fdc9b6dacdb8211d967..6208aa2fa2cffaed967cef358e60ad057c870407 100644 (file)
@@ -32,7 +32,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.Change;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.server.ws.WebService.Param;
index 0dfe390aaed1e09d488941067d0e24f1797666ec..a1d07572f772a65f7c12c282668cc5c4c279ba5d 100644 (file)
@@ -27,7 +27,7 @@ import org.assertj.core.groups.Tuple;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.server.ws.Change;
 import org.sonar.api.server.ws.WebService;
index 1a5505bad6ec4167d02d5229f9cda2ff03de5261..b9c8007ef110c70f9bfeb0047ff70c059b0403ee 100644 (file)
@@ -23,7 +23,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.core.config.PurgeConstants;
 import org.sonar.db.DbSession;
index a86892f28a6333ad216b207d56988d316f517b5e..f7e4c33359a27b64ae29dced26b017678c0542a5 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.ce.measure.Component;
 import org.sonar.api.ce.measure.MeasureComputer;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.Duration;
index 9f24e9b29e25cd1f11f3e91bf09853fdf36dcd20..de328c1d514540fff02f2f73a46c1fe806a0c7af 100644 (file)
@@ -23,8 +23,8 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.ce.settings.ProjectSettingsFactory;
 import org.sonar.db.DbClient;
index 32bb7fead29fb2d8603ebea318787232ade6dc31..b75ebdb223e14e19c9ec337c8cd215c7389a9860 100644 (file)
@@ -25,8 +25,8 @@ import java.util.Collection;
 import java.util.Collections;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.duplications.block.Block;
index e3830d1132c7ab8ae2539b46b9a0e97969e4087c..024844859bebebf978791a75f2b694414438e434 100644 (file)
@@ -23,8 +23,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.db.DbTester;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.user.UserDto;
index 3e9b983f09402c219e509b3126d0a0b17bcbfb01..0afcc53cbee2e5d60f6186c1083a275b00b9dfca 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.server.computation.task.projectanalysis.issue;
 
 import java.util.Collections;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.server.es.EsTester;
index 2b357840099e0e736f08471eecebd802b0544c11..d119b23ee3f9fc9a40164249c71a82959fc03307 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.core.issue.DefaultIssue;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
index 1ec6065c24c0088c2152508752f7e160bef78718..43bad73e48c66cac9df741f5b3782a8e5839c495 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.utils.MessageException;
 
index b3fc362bbb32acd06cf1c4d7f8b5363e97bdd83c..a150f7857e3a29c39cde658d91c7681921e3dab0 100644 (file)
@@ -27,8 +27,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
index 5dbd5895a6c8f2eaf98e1fd35a9770e1f8325a20..b3f606a450e5ac8c4a3698ae396b103210f4d3f0 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.purge.IdUuidPair;
index 5bcc594e84cafdf49c040ec5800273fe8c882b42..f33bb6fea8dac70dc95bb01a57d135cd68dbe1d6 100644 (file)
@@ -24,7 +24,7 @@ import java.util.Collections;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
 import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
 import org.sonar.server.computation.task.projectanalysis.component.SettingsRepository;
index 4a7d4d829c38bbea73086cb390c17c5d6a520a14..5592797964e4ca52fbf3971ccd02201f5eb8753a 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.sonar.api.SonarQubeSide;
 import org.sonar.api.SonarRuntime;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.internal.SonarRuntimeImpl;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.Version;
index 79d5f994eb7ca6eaa83727279a1917ce5728fdee..14d69d2c41b1057450946b1d05ed3a502d651ee5 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.ce.posttask.CeTask;
 import org.sonar.api.ce.posttask.PostProjectAnalysisTaskTester;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.server.computation.task.projectanalysis.component.SettingsRepository;
index e1d6ba9459216cf3074ec6f2a1e092c139346f7a..b31e8864491b7ebdb0cf262b0b83193846ede4d8 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.process.ProcessProperties;
index e4131b8d7a772cfcc58b9bb35972bc00c5e94b8b..00bb513b2009532269d3f99b3da051b916032ad9 100644 (file)
@@ -45,7 +45,7 @@ import org.elasticsearch.node.Node;
 import org.elasticsearch.node.NodeBuilder;
 import org.elasticsearch.search.SearchHit;
 import org.junit.rules.ExternalResource;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.core.platform.ComponentContainer;
 
 import static com.google.common.base.Preconditions.checkState;
index db96552920a19d1fb471f0ab723b1973f4a45fde..72ba6c74e7a7fed28af61fb83d11f0e78fdd4215 100644 (file)
@@ -27,7 +27,7 @@ import org.elasticsearch.cluster.metadata.MappingMetaData;
 import org.elasticsearch.common.collect.ImmutableOpenMap;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 2ee3a7ac81891c972365277ff8296ce432165189..9b42bc4311417f84ce1effdc84564e555a3e769b 100644 (file)
@@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableSet;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 
index 521ce5e37628315c67d647892144dbaafb311e47..4f9c787a8ac8cd8958baf95ff3f24f788a081286 100644 (file)
@@ -26,7 +26,7 @@ import org.elasticsearch.common.settings.Settings;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.process.ProcessProperties;
 
 import static org.assertj.core.api.Assertions.assertThat;
index ccd47a3d5c82cf7d0700c8e82d801b507bcfc085..0769a2c5b8a0e355e4529367cb562f1c4b5f0e27 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.utils.System2;
 import org.sonar.core.issue.DefaultIssue;
index 06f24f830bcfb3359ca9318d9d36129b24471f04..24bc6f65dabb665f2a58be83dff5485743304f65 100644 (file)
@@ -24,7 +24,7 @@ import java.util.TimeZone;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.rule.RuleKey;
index f807008f62e4aa450af7d11ed068df01eb5eec41..ed7045f351c345fc802a227d0e465d86f8d45269 100644 (file)
@@ -20,7 +20,7 @@
 package org.sonar.server.issue.index;
 
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.server.es.IndexDefinition;
 import org.sonar.server.es.NewIndex;
 
index 367da182d68fe167203b540d0646c5ec3a4b3448..3a74e53b93ea951e1f53279e30c5d82f8644942b 100644 (file)
@@ -31,7 +31,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.resources.Scopes;
 import org.sonar.api.rule.RuleKey;
index dab696ce3ac4a1b00f72156c7ee6fff2330b0162..77c4f20a4a6fea5dbeb80d61b4e963cbf89e6ccc 100644 (file)
@@ -28,7 +28,7 @@ import org.apache.commons.lang.StringUtils;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
index b7b2a0429d2926ccd6d5387ac08e1abdb8479648..04f7992bcaa4b91f03bd7c0e1546aa487711c829 100644 (file)
@@ -25,8 +25,8 @@ import org.apache.commons.lang.StringUtils;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.config.EmailSettings;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.notifications.Notification;
 import org.sonar.db.DbTester;
 import org.sonar.plugins.emailnotifications.api.EmailMessage;
index 34d29e771078cb4ea4ccaa9e7e7e68767ffeea4a..738bc7d340257c195c82211a7ab6fca7965a2f56 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
index c3194e61e062223bd43892a80b60df2c07535c30..0d96c89e57b6d06db214b666f5f62b332e45ab43 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.utils.internal.TestSystem2;
index 4221b769458bfc29de59cdb724bcea9ff43108fc..0fcd4dc71a3c467d7889c3880e5dc19854796883 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.server.issue.ws;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
index 0af455960ad32970ce5bd1f12fad27f895b0f6ca..792d7767f7fd1f604d344311c39af4229e833199 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rules.RuleType;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.utils.System2;
index 19a024fc56b50484f57ac6d01293613a4866164a..f58f36c3cf4ed9436fa0871c581c4d048cda4cb9 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.utils.System2;
index 8e2bfa92268e94387ec3eeaf8807e464223a95d9..545a35bb029cac4b951f5c9baf6ef60f2e72f241 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
index 12220f3320343253ef7d29edb50910bb49b42abb..2016cd557178b1ed28029065daefc819a9c824ed 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService.Action;
index bc492ea7be52c952186c5b60694d90a605c2b53c..d396dbc6f292a18b9fdb7fe6e33a4f116da310c7 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
index 1768bc0c6bb8b4b8b340b76febede201603d1423..660f40738b7cdab00133bcd00ff68daab529fc2a 100644 (file)
@@ -23,7 +23,7 @@ import java.util.Collections;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService.Action;
 import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.utils.System2;
index 7870e00dc4c1368f0573acf295d1e81398e25b06..d70cdb9ed27654d94829dc550819ec0bdc7bc8d4 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.measures.Metric.ValueType;
 import org.sonar.api.utils.System2;
index da3ea281ce263d2bba1282ea684a417405955e56..c0987df1b4fe671a401ca4438461f3c7974aae95 100644 (file)
@@ -23,7 +23,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.utils.System2;
 import org.sonar.api.web.UserRole;
index 448f72bf84114f1823fde4841c552ace478ea9c7..04f01197b67a3ec8beef3866cee360b4f1790fc0 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.Metric.ValueType;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.utils.DateUtils;
index 00269798c5b074755ed475ea5bb31bb06b254e04..35110f592cca9b2f2afe470acef61eb61da8ef40 100644 (file)
@@ -23,7 +23,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.Metric.ValueType;
 import org.sonar.api.utils.System2;
 import org.sonar.api.web.UserRole;
index e6d819df1f450507d8273d32994372b21d3056f1..c7cc1c68a696886d3ff5e621a2c239a8ca8aefd4 100644 (file)
@@ -33,7 +33,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
index c7f2f9bbbf7aaded52eb8010fa974dfaf5d834df..44b249c934e077c970ea9761eeb284f9866204b6 100644 (file)
@@ -25,7 +25,7 @@ import java.util.Map;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.organization.OrganizationDto;
index 9461055492f5f153845ad43d9167022a8cf0dee9..2612e8b5c5b3904b5b37562d53c2d2b4f4d56c4e 100644 (file)
@@ -23,7 +23,7 @@ import java.util.Date;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
index 2db3d99820a12fe13853b20b93a4b79100886965..c03a81c8f31e782165a6e05d845bf2f6216be8a8 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Test;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.notifications.Notification;
 import org.sonar.api.notifications.NotificationChannel;
 import org.sonar.db.DbClient;
index 7e363765e55b9f4b43f782546888b4f38254d705..b0d17f73fff8b3cb1e3166a8b3ddb6b70bdd8b4f 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.internal.TestSystem2;
 import org.sonar.api.web.UserRole;
index 5eefc948b3350b075435cb69f2ea764e9e9caa97..f55ef8e42bcb0efc077dcdf5c47d1cc53b7f0f25 100644 (file)
@@ -26,7 +26,7 @@ import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
index d4d28e5d89545d9ce6c992b199afebf91f15cb76..b54c7c0d4c5bd98b21ef6c729bf430ee3255e24b 100644 (file)
@@ -28,8 +28,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.utils.System2;
 import org.sonar.api.web.UserRole;
index cf543edbb1bac8a20bab21ef7c9a3f36fb865f82..e075709858afa149d7691b5474cdc6ff3fb709df 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.utils.System2;
 import org.sonar.core.util.UuidFactory;
index e52406a05d1c5a4f5aa53a5e37b29cca0c9bd7e1..025c354a88c2cc2255f01fb49c9f7399e6798423 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
index 7dbe1c793562436d180ccf52c7dff10657d67c3c..215c224ce70a1b3b119454c4261b3f42fbdb709a 100644 (file)
@@ -24,7 +24,7 @@ import java.util.stream.IntStream;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.db.DbClient;
index 37b7af4377d008dd01f62bc182b6c364eef38f9d..d04803cf455111be18c5403d3d92c3d0af705999 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.server.platform;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentTesting;
index c9a4ab0cb069668e564cefbd8131942e5282c8ea..64ce279889914c189f2ca786be758a98c57019d6 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.platform;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 
index 98e46b16e475b628d4c8fa7cdb936bab05116155..6968ccac511d053ea1fffa0138d94d783a79a526 100644 (file)
@@ -23,7 +23,7 @@ import com.google.common.base.Optional;
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index a8d4c29068b4c9507a21a3cdd02721eed4d95ffd..6fea447e18386f17511f47da77c52c27897f3e41 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.rules.TemporaryFolder;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.SonarRuntime;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.Version;
 
 import static org.assertj.core.api.Assertions.assertThat;
index 8d3b06fcc99492615b3356a4de62964a286527c1..d001c95631eda80f166a351d6f2caf69ffac3db4 100644 (file)
@@ -30,8 +30,8 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.process.ProcessProperties;
index 50585e2785543473ec525b4e359a2fca31e3ddb9..cf1e60766ce92b276c89fd468e039be5a9571b5d 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.core.config.CorePropertyDefinitions;
 
 import static org.assertj.core.api.Assertions.assertThat;
index f867f414ceab5c5fe4fa898cf02b3c607146b10b..33b32974b5a53e4cc26af69ff4b031f2d2806df7 100644 (file)
@@ -22,8 +22,8 @@ package org.sonar.server.platform.cluster;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 0d48ed030c769ffd3bca8583cb3a114542b5e22e..d88d4b4467f22d1f15795363980b535cf858d3e0 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.server.platform.db;
 
 import org.junit.Test;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.database.DatabaseProperties;
 import org.sonar.api.utils.System2;
 
index c11637b90af49b6a7d16dcb8a97d30104c26fe90..bdbd0f4ae064e0386107738b688de6c547a3b11a 100644 (file)
@@ -31,7 +31,7 @@ import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.process.NetworkUtils;
index 7e94421be46445498abb6e01552fad0f81b4b341..b2b5da6461c5d2d9b1e3d746c2d03fbf7e8ba7d3 100644 (file)
@@ -24,7 +24,7 @@ import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.cluster.health.ClusterHealthStatus;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.server.es.EsClient;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.issue.index.IssueIndexDefinition;
index 8db2ed953fecc7597dea36ccfe6c836bf94f016a..9c1edb795a2e623da6fd4690472efa91757c0850 100644 (file)
@@ -25,7 +25,7 @@ import org.sonar.api.PropertyType;
 import org.sonar.api.config.PropertyDefinition;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.apache.commons.lang.StringUtils.repeat;
 import static org.assertj.core.api.Assertions.assertThat;
index abc8395c453df9d8f0a5b83153e72411e0870ead..cd0f60d7d4842e6c6b7ec6cb5ab5a8e9b2d7011a 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.platform.Server;
 import org.sonar.api.security.SecurityRealm;
 import org.sonar.api.utils.log.LoggerLevel;
index 85708a638654fdb3f78129058c0448ba69fb086d..4de4e0684a9d007cf3d276ffb0221fb38ec7fdac 100644 (file)
@@ -24,8 +24,8 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.server.app.ProcessCommandWrapper;
index a5beb84627f83711f4574a1b9bdb48bf48efb32e..8dab6dfd604bffc73713e8398e90576b3db34978 100644 (file)
@@ -24,8 +24,8 @@ import java.net.URISyntaxException;
 import java.nio.charset.StandardCharsets;
 import org.junit.Before;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.SonarException;
 import org.sonar.api.utils.UriReader;
 import org.sonar.core.config.WebConstants;
index 115d0549b012d3e961d00793d0a4190300ce49cc..5b90603bbd41e10810a3e72b4a1788ecc71d87bb 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
index 855f8697f802c519cdd719ae5b71f0665343faca..3156a4fc7606f69424d9cf27cf9d24fb6bc05921 100644 (file)
@@ -25,7 +25,7 @@ import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.db.component.ComponentDto;
index 8f3a6ae214b1557bcb4195e97d0e24c4308be51e..c199fab75d23e553d6a70f0c36a83cc50ede6817 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.PropertyType;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
index dd35ef503b4755264cec8227bd99e3db08470bb8..fd696cfac52fe15a3264537948a7e645ceb5551d 100644 (file)
@@ -23,7 +23,7 @@ import java.util.List;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.organization.OrganizationDto;
index 5de88bfbdd7ccc9589899127acd0514daf8d01a6..a67d0db9f6df8764d1a9f8a56d539c01d5078852 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Language;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.rule.RuleKey;
index 17fdd6b12daede14c23dfad5e0206ebd67a11157..480d0deddd006b8927837d3b707d21ef32369b67 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.profiles.ProfileImporter;
 import org.sonar.api.profiles.RulesProfile;
 import org.sonar.api.rules.RulePriority;
index df88fa461d77d6403379a2d8cf1c7ea31b576347..15ecc3c0bcd78d57bba2181a514c18281302fd6c 100644 (file)
@@ -25,7 +25,7 @@ import java.util.Date;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
index 4304db8ef8e8e02762c29c8eda3207d979aa0144..abf4932caa45ba193598811454ee4baeb2741a2c 100644 (file)
@@ -23,7 +23,7 @@ import java.util.Date;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Language;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.rule.RuleKey;
index 19c751e6de8d8f4a3a5fd8d0ff2aece8a98bbab0..17ee475d67f0afc742246e6b04cf6f42dad7cfb6 100644 (file)
@@ -27,7 +27,7 @@ import org.assertj.core.api.Fail;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
index 10f1dabf5ae158c57a864fc786b4e5acc1c891f5..cca9a5543243f851f45bcd2be08871074f03f8de 100644 (file)
@@ -30,7 +30,7 @@ import javax.annotation.Nonnull;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
index 10630b27d482250c470d35e429bf97fe65800234..2583bf06acdd856c5e3faa4f98346d1896da266a 100644 (file)
@@ -25,8 +25,8 @@ import org.apache.commons.lang.StringUtils;
 import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.process.ProcessProperties;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.es.IndexDefinition;
index 807d239bfeb1f51f48cf02d522868a3a7d1c7bef..228fc6658dd68d201d3f247f5bc0a18cd7d2501a 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.utils.System2;
index 6ba22ff90c745ffff86ffac8b8f53874708b7da5..2bb330d9d5988818d67643b7eb3436fc4031b7a8 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.server.rule.index;
 import com.google.common.collect.ImmutableSet;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.rules.RuleType;
index 360cb45b4c8e9987aedf218cfe40f45c3ee18e90..a0e5e607eea775b4233d07aedd641ddb1b5e189b 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.server.rule.ws;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
index 43a69948204e46ad9ae116ec3aa4252bdb1306c7..5428e4189f654a571e603eb2f0ed962e4177c128 100644 (file)
@@ -28,7 +28,7 @@ import org.assertj.core.api.iterable.Extractor;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
index c4e2e4266e9e92d626a6dde9cb416be48cb4b204..a932f239ed3ce5b8d1e35565b484affcbad618fa 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Languages;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
index ad368aee96982815087f833dee9b223aeb60f984..a79430649cf5959b7ccb950069b1538f1e6a7a49 100644 (file)
@@ -23,7 +23,7 @@ package org.sonar.server.rule.ws;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
index bf4962032a6cc12558e778246a9e303dd02b2761..d602ab95a440f11da6788ec1fa33ed6b839f477c 100644 (file)
@@ -24,7 +24,7 @@ import java.io.IOException;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
index 937aa0f2dbb2d9a7b1de2bf66b2bcf76b7de54af..3e1a393142c38915c27a7f183a800e9608a6addb 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.setting;
 
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.ce.settings.ProjectSettingsFactory;
 import org.sonar.db.DbClient;
 import org.sonar.db.property.PropertyDto;
index 3aeceb8710efa2a0ce13db6f810d398b77baf8d2..fbfd3fe0308ab7ff3c54cf5445b9ea9661276c43 100644 (file)
@@ -27,8 +27,8 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.config.Encryption;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.tester.UserSessionRule;
index 4798ed07c72df78bd74ff1930271dbffde04209f..35373212e3b66b9bab1584c674e3086e33236297 100644 (file)
@@ -28,8 +28,8 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.config.Encryption;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
index f91fa01fe2bb0dfb7521a3c772cdb4c50c0ffd93..22e501e92681d2bed398013efdf6a037cf9e8c22 100644 (file)
@@ -27,8 +27,8 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.config.Encryption;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.tester.UserSessionRule;
index b84f330a391e42a6a85186b1dca4396922b8e058..013b64d1db03a47bdfe27db98385ba4d24725c8e 100644 (file)
@@ -23,7 +23,7 @@ import com.google.common.base.Optional;
 import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.es.SearchOptions;
 
index 341bb2e0125b712c0722f9b1cca9cf0717b276d1..37e3ff543eca2a9bcc63985ed6b53a6adee21d04 100644 (file)
@@ -32,7 +32,7 @@ import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.search.SearchHit;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.protobuf.DbFileSources;
index 87d3d72e8d85271156097cdd51b0a1ea28413f1d..1e2c493c2d4ae69e1c4845a10cc7e280b1f0aeea 100644 (file)
@@ -23,7 +23,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
index 85e45dab932317e20bca71f223678fbbce5d612c..a6c5c628538449c9ec077b8156f2d79c21480487 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.ui.ws;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.platform.Server;
 import org.sonar.api.resources.ResourceType;
 import org.sonar.api.resources.ResourceTypeTree;
index a1bc33f96f25d5223ac0c35a2cc7e46ae39438d2..4ee023e0c65c604f2b7251bbcaa5bc544288fcf1 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.ui.ws;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.web.page.Page;
 import org.sonar.api.web.page.PageDefinition;
 import org.sonar.core.config.WebConstants;
index a2b87d40fc54db91e48c9b8d4102a1f1434e1935..4878432140c55b4450d2eb4dbb21caa8664ad3ef 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.user;
 
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.security.LoginPasswordAuthenticator;
 import org.sonar.api.security.SecurityRealm;
 import org.sonar.api.utils.SonarException;
index d7aaeabb1a9946b2951cfee20ca882161198d06d..d7c4f1c5983abb00b00d5486e23f088592a68a4c 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.platform.NewUserHandler;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.internal.TestSystem2;
index f6e7776b053e9ceaf481d1e673cb2a6ecf74a646..5f2dc268a055b57207f1bb13cfa16befae8d866f 100644 (file)
@@ -20,7 +20,7 @@
 package org.sonar.server.user.index;
 
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.server.es.IndexDefinition;
 import org.sonar.server.es.NewIndex;
 
index 9a572262c1b16093dd08c2b7b046ff2f82e6d1bd..c0543add15a73a582118eb7f9bb6dfd747bbc23c 100644 (file)
@@ -25,7 +25,7 @@ import java.util.Locale;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.es.SearchOptions;
 
index d17ed19990be34bf4b455914609e5ef58056d1db..02b87851c3230e1742b68b8349eee5c79c060805 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.server.user.index;
 import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.user.UserDto;
index 76389fe45cc6fef463ef762efaeb0008cb162f84..d3f69cd7664aa4a880f61fd0ebbb1ac2e90523eb 100644 (file)
@@ -23,7 +23,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.server.es.EsTester;
index 9022c7c79e5ee197d1ae9897d9c6577c41013580..3115195f30a77aef5d860478c22b0e613670e5ea 100644 (file)
@@ -25,8 +25,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.internal.AlwaysIncreasingSystem2;
 import org.sonar.core.config.CorePropertyDefinitions;
index fdaf85ccec236c75e69186a4384986f6ed610c19..34538b90c4cda2dd517198d569ca6204f60986c2 100644 (file)
@@ -23,7 +23,7 @@ import java.util.Optional;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.internal.AlwaysIncreasingSystem2;
 import org.sonar.db.DbClient;
index fb56bfffbe6b8e68370b3cdde9508d9aa84d7596..a6f01a4acf1f5cd91a779486ab324cc85b1e1453 100644 (file)
@@ -24,7 +24,7 @@ import java.util.List;
 import java.util.function.Consumer;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
index 53f5461133fbe9ca50546d9ab7db1d6d6fb08d97..05af1353c6703c1b95c2a7936639a2469b840861 100644 (file)
@@ -22,8 +22,8 @@ package org.sonar.server.user.ws;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
index a0dd69f21fe498d60aaf8a82c2756ce3c721fbf2..ff096b38b830093533673f4886ea83f60452de4e 100644 (file)
@@ -32,8 +32,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.SonarQubeSide;
 import org.sonar.api.SonarRuntime;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.internal.SonarRuntimeImpl;
 import org.sonar.api.utils.Version;
 
index af70d7108946a6e0302114d6573315b902fce9e1..ea9b451535fbc5377640eb4945d46a709b077f47 100644 (file)
@@ -20,7 +20,7 @@
 package org.sonar.server.view.index;
 
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.server.es.IndexDefinition;
 import org.sonar.server.es.NewIndex;
 
index 54675cfc5d6ddfe5f7c6e3504a245501dd47d8dc..2e3dc5ceaf4381811e4897ad8ebf6bf3129fea7c 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.server.view.index;
 import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.server.es.EsTester;
 
 import static com.google.common.collect.Lists.newArrayList;
index f763ecb707464bc15d0f51a6faaac4fece2fe59b..426b9d5094537d07cf738134678070222d190d92 100644 (file)
@@ -24,7 +24,7 @@ import java.util.List;
 import java.util.Map;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
index 0044bcbdae6d7974b7fcecc113891e88e21e9be9..35c150acd669a351c48fa39f7dffac5336c26519 100644 (file)
@@ -42,14 +42,13 @@ import javax.annotation.Nullable;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.IOUtils;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.platform.Server;
 import org.sonar.api.utils.HttpDownloader;
 import org.sonar.api.utils.SonarException;
 import org.sonar.api.utils.log.Loggers;
 
 import static org.apache.commons.io.FileUtils.copyInputStreamToFile;
-import static org.apache.commons.lang.StringUtils.isNotEmpty;
 import static org.sonar.core.util.FileUtils.deleteQuietly;
 
 /**
@@ -63,32 +62,32 @@ public class DefaultHttpDownloader extends HttpDownloader {
   private final Integer readTimeout;
   private final Integer connectTimeout;
 
-  public DefaultHttpDownloader(Server server, Settings settings) {
-    this(server, settings, null);
+  public DefaultHttpDownloader(Server server, Configuration config) {
+    this(server, config, null);
   }
 
-  public DefaultHttpDownloader(Server server, Settings settings, @Nullable Integer readTimeout) {
-    this(server, settings, null, readTimeout);
+  public DefaultHttpDownloader(Server server, Configuration config, @Nullable Integer readTimeout) {
+    this(server, config, null, readTimeout);
   }
 
-  public DefaultHttpDownloader(Server server, Settings settings, @Nullable Integer connectTimeout, @Nullable Integer readTimeout) {
+  public DefaultHttpDownloader(Server server, Configuration config, @Nullable Integer connectTimeout, @Nullable Integer readTimeout) {
     this.readTimeout = readTimeout;
     this.connectTimeout = connectTimeout;
-    downloader = new BaseHttpDownloader(new AuthenticatorFacade(), settings, server.getVersion());
+    downloader = new BaseHttpDownloader(new AuthenticatorFacade(), config, server.getVersion());
   }
 
-  public DefaultHttpDownloader(Settings settings) {
-    this(settings, null);
+  public DefaultHttpDownloader(Configuration config) {
+    this(config, null);
   }
 
-  public DefaultHttpDownloader(Settings settings, @Nullable Integer readTimeout) {
-    this(settings, null, readTimeout);
+  public DefaultHttpDownloader(Configuration config, @Nullable Integer readTimeout) {
+    this(config, null, readTimeout);
   }
 
-  public DefaultHttpDownloader(Settings settings, @Nullable Integer connectTimeout, @Nullable Integer readTimeout) {
+  public DefaultHttpDownloader(Configuration config, @Nullable Integer connectTimeout, @Nullable Integer readTimeout) {
     this.readTimeout = readTimeout;
     this.connectTimeout = connectTimeout;
-    downloader = new BaseHttpDownloader(new AuthenticatorFacade(), settings, null);
+    downloader = new BaseHttpDownloader(new AuthenticatorFacade(), config, null);
   }
 
   @Override
@@ -173,22 +172,22 @@ public class DefaultHttpDownloader extends HttpDownloader {
 
     private String userAgent;
 
-    BaseHttpDownloader(AuthenticatorFacade system, Settings settings, @Nullable String userAgent) {
-      initProxy(system, settings);
-      initUserAgent(userAgent, settings);
+    BaseHttpDownloader(AuthenticatorFacade system, Configuration config, @Nullable String userAgent) {
+      initProxy(system, config);
+      initUserAgent(userAgent, config);
     }
 
-    private void initProxy(AuthenticatorFacade system, Settings settings) {
+    private void initProxy(AuthenticatorFacade system, Configuration config) {
       // register credentials
-      String login = settings.getString(HTTP_PROXY_USER);
-      if (isNotEmpty(login)) {
-        system.setDefaultAuthenticator(new ProxyAuthenticator(login, settings.getString(HTTP_PROXY_PASSWORD)));
+      Optional<String> login = config.get(HTTP_PROXY_USER);
+      if (login.isPresent()) {
+        system.setDefaultAuthenticator(new ProxyAuthenticator(login.get(), config.get(HTTP_PROXY_PASSWORD).orElse(null)));
       }
     }
 
-    private void initUserAgent(@Nullable String sonarVersion, Settings settings) {
-      String serverId = settings.getString(CoreProperties.SERVER_ID);
-      userAgent = sonarVersion == null ? "SonarQube" : String.format("SonarQube %s # %s", sonarVersion, Optional.ofNullable(serverId).orElse(""));
+    private void initUserAgent(@Nullable String sonarVersion, Configuration settings) {
+      Optional<String> serverId = settings.get(CoreProperties.SERVER_ID);
+      userAgent = sonarVersion == null ? "SonarQube" : String.format("SonarQube %s # %s", sonarVersion, serverId.orElse(""));
       System.setProperty("http.agent", userAgent);
     }
 
index 4cf76e10ccdad7f286b32b33d4df5714c3fce76c..305d83ec6c1bc73ca7d638b91df6b9e05d19bdc1 100644 (file)
@@ -24,8 +24,8 @@ import java.util.Locale;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.i18n.I18n;
 
 import static org.mockito.Matchers.anyString;
index 77fa075d13f22594a469856f3296d209ca18191b..090abdb8be3ce45284c54556193fc4d302a21c66 100644 (file)
@@ -54,8 +54,7 @@ import org.simpleframework.http.Response;
 import org.simpleframework.http.core.Container;
 import org.simpleframework.transport.connect.SocketConnection;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.platform.Server;
 import org.sonar.api.utils.SonarException;
 
@@ -141,41 +140,41 @@ public class DefaultHttpDownloaderTest {
       @Override
       public boolean matches(Object ex) {
         return
-            // Java 8
-            ex instanceof NoRouteToHostException || ex instanceof SocketException
-                // Java 7 or before
-            || ex instanceof SocketTimeoutException;
+        // Java 8
+        ex instanceof NoRouteToHostException || ex instanceof SocketException
+        // Java 7 or before
+          || ex instanceof SocketTimeoutException;
       }
 
       @Override
       public void describeTo(Description arg0) {
       }
     }));
-    DefaultHttpDownloader downloader = new DefaultHttpDownloader(new MapSettings(), 10, 50000);
+    DefaultHttpDownloader downloader = new DefaultHttpDownloader(new MapSettings().asConfig(), 10, 50000);
     downloader.openStream(new URI(url));
   }
 
   @Test
   public void downloadBytes() throws URISyntaxException {
-    byte[] bytes = new DefaultHttpDownloader(new MapSettings()).readBytes(new URI(baseUrl));
+    byte[] bytes = new DefaultHttpDownloader(new MapSettings().asConfig()).readBytes(new URI(baseUrl));
     assertThat(bytes.length).isGreaterThan(10);
   }
 
   @Test
   public void readString() throws URISyntaxException {
-    String text = new DefaultHttpDownloader(new MapSettings()).readString(new URI(baseUrl), StandardCharsets.UTF_8);
+    String text = new DefaultHttpDownloader(new MapSettings().asConfig()).readString(new URI(baseUrl), StandardCharsets.UTF_8);
     assertThat(text.length()).isGreaterThan(10);
   }
 
   @Test
   public void readGzipString() throws URISyntaxException {
-    String text = new DefaultHttpDownloader(new MapSettings()).readString(new URI(baseUrl + "/gzip/"), StandardCharsets.UTF_8);
+    String text = new DefaultHttpDownloader(new MapSettings().asConfig()).readString(new URI(baseUrl + "/gzip/"), StandardCharsets.UTF_8);
     assertThat(text).isEqualTo("GZIP response");
   }
 
   @Test
   public void readStringWithDefaultTimeout() throws URISyntaxException {
-    String text = new DefaultHttpDownloader(new MapSettings()).readString(new URI(baseUrl + "/timeout/"), StandardCharsets.UTF_8);
+    String text = new DefaultHttpDownloader(new MapSettings().asConfig()).readString(new URI(baseUrl + "/timeout/"), StandardCharsets.UTF_8);
     assertThat(text.length()).isGreaterThan(10);
   }
 
@@ -191,7 +190,7 @@ public class DefaultHttpDownloaderTest {
       public void describeTo(Description arg0) {
       }
     });
-    new DefaultHttpDownloader(new MapSettings(), 50).readString(new URI(baseUrl + "/timeout/"), StandardCharsets.UTF_8);
+    new DefaultHttpDownloader(new MapSettings().asConfig(), 50).readString(new URI(baseUrl + "/timeout/"), StandardCharsets.UTF_8);
   }
 
   @Test
@@ -199,7 +198,7 @@ public class DefaultHttpDownloaderTest {
     File toDir = temporaryFolder.newFolder();
     File toFile = new File(toDir, "downloadToFile.txt");
 
-    new DefaultHttpDownloader(new MapSettings()).download(new URI(baseUrl), toFile);
+    new DefaultHttpDownloader(new MapSettings().asConfig()).download(new URI(baseUrl), toFile);
     assertThat(toFile).exists();
     assertThat(toFile.length()).isGreaterThan(10l);
   }
@@ -211,7 +210,7 @@ public class DefaultHttpDownloaderTest {
 
     try {
       int port = new InetSocketAddress("localhost", 0).getPort();
-      new DefaultHttpDownloader(new MapSettings()).download(new URI("http://localhost:" + port), toFile);
+      new DefaultHttpDownloader(new MapSettings().asConfig()).download(new URI("http://localhost:" + port), toFile);
     } catch (SonarException e) {
       assertThat(toFile).doesNotExist();
     }
@@ -224,7 +223,7 @@ public class DefaultHttpDownloaderTest {
     MapSettings settings = new MapSettings();
     settings.setProperty(CoreProperties.SERVER_ID, "blablabla");
 
-    InputStream stream = new DefaultHttpDownloader(server, settings).openStream(new URI(baseUrl));
+    InputStream stream = new DefaultHttpDownloader(server, settings.asConfig()).openStream(new URI(baseUrl));
     Properties props = new Properties();
     props.load(stream);
     stream.close();
@@ -237,7 +236,7 @@ public class DefaultHttpDownloaderTest {
     Server server = mock(Server.class);
     when(server.getVersion()).thenReturn("2.2");
 
-    InputStream stream = new DefaultHttpDownloader(server, new MapSettings()).openStream(new URI(baseUrl));
+    InputStream stream = new DefaultHttpDownloader(server, new MapSettings().asConfig()).openStream(new URI(baseUrl));
     Properties props = new Properties();
     props.load(stream);
     stream.close();
@@ -247,7 +246,7 @@ public class DefaultHttpDownloaderTest {
 
   @Test
   public void userAgent_is_static_value_when_server_is_not_provided() throws URISyntaxException, IOException {
-    InputStream stream = new DefaultHttpDownloader(new MapSettings()).openStream(new URI(baseUrl));
+    InputStream stream = new DefaultHttpDownloader(new MapSettings().asConfig()).openStream(new URI(baseUrl));
     Properties props = new Properties();
     props.load(stream);
     stream.close();
@@ -257,7 +256,7 @@ public class DefaultHttpDownloaderTest {
 
   @Test
   public void followRedirect() throws URISyntaxException {
-    String content = new DefaultHttpDownloader(new MapSettings()).readString(new URI(baseUrl + "/redirect/"), StandardCharsets.UTF_8);
+    String content = new DefaultHttpDownloader(new MapSettings().asConfig()).readString(new URI(baseUrl + "/redirect/"), StandardCharsets.UTF_8);
     assertThat(content).contains("agent");
   }
 
@@ -277,24 +276,24 @@ public class DefaultHttpDownloaderTest {
 
   @Test
   public void supported_schemes() {
-    assertThat(new DefaultHttpDownloader(new MapSettings()).getSupportedSchemes()).contains("http");
+    assertThat(new DefaultHttpDownloader(new MapSettings().asConfig()).getSupportedSchemes()).contains("http");
   }
 
   @Test
   public void uri_description() throws URISyntaxException {
-    String description = new DefaultHttpDownloader(new MapSettings()).description(new URI("http://sonarsource.org"));
+    String description = new DefaultHttpDownloader(new MapSettings().asConfig()).description(new URI("http://sonarsource.org"));
     assertThat(description).matches("http://sonarsource.org \\(.*\\)");
   }
 
   @Test
   public void configure_http_proxy_credentials() {
     DefaultHttpDownloader.AuthenticatorFacade system = mock(DefaultHttpDownloader.AuthenticatorFacade.class);
-    Settings settings = new MapSettings();
+    MapSettings settings = new MapSettings();
     settings.setProperty("https.proxyHost", "1.2.3.4");
     settings.setProperty("http.proxyUser", "the_login");
     settings.setProperty("http.proxyPassword", "the_passwd");
 
-    new DefaultHttpDownloader.BaseHttpDownloader(system, settings, null);
+    new DefaultHttpDownloader.BaseHttpDownloader(system, settings.asConfig(), null);
 
     verify(system).setDefaultAuthenticator(argThat(new TypeSafeMatcher<Authenticator>() {
       @Override
index 9efca22299accd01edfd3c5cebac2f7be6d46fcb..c38f1ecc257facbec08c5ef12be515dcc5c36325 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.api;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
+import org.sonar.api.config.Configuration;
 
 /**
  * Plugin properties. This annotation is only used on classes implementing org.sonar.api.Plugin.
@@ -28,7 +29,7 @@ import java.lang.annotation.RetentionPolicy;
  * Note that {@link org.sonar.api.config.PropertyDefinition} is an alternative, programmatic and recommended approach
  * to declare properties.
  * <br>
- * Effective property values are accessible at runtime through the component {@link org.sonar.api.config.Settings}
+ * Effective property values are accessible at runtime through the component {@link Configuration}
  *
  * @since 1.10
  */
index 74cad4f2ae63cce9f7b28aec25bcc569c62dc3d4..9bf8eef05b4df6524145d734627c9fef89097447 100644 (file)
@@ -186,7 +186,7 @@ public class ProjectDefinition {
     }
     return null;
   }
-  
+
   @CheckForNull
   public String getOriginalVersion() {
     return properties.get(CoreProperties.PROJECT_VERSION_PROPERTY);
@@ -199,7 +199,7 @@ public class ProjectDefinition {
     }
     return version;
   }
-  
+
   @CheckForNull
   public String getOriginalName() {
     return properties.get(CoreProperties.PROJECT_NAME_PROPERTY);
@@ -320,6 +320,7 @@ public class ProjectDefinition {
     return this;
   }
 
+  @CheckForNull
   public ProjectDefinition getParent() {
     return parent;
   }
index 44917519e7226cc8459ce5ed30dfef931d0537d9..96ff255364c1522a8afef7e45250ec0a5f099061 100644 (file)
@@ -25,6 +25,7 @@ import org.sonar.api.utils.Duration;
 
 /**
  * @since 4.3
+ * @deprecated since 6.5 debt model will soon be unavailable on batch side
  */
 public class DebtRemediationFunction {
 
index 2baa34478d25175b3f910249b06dbca7c768b0bb..cfe881f28661313218db1547deb451b4755ba7a6 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.api.batch.postjob;
 
 import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.postjob.issue.PostJobIssue;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.config.Settings;
 
 /**
@@ -30,10 +31,16 @@ import org.sonar.api.config.Settings;
 public interface PostJobContext {
 
   /**
-   * Get settings of the current project.
+   * @deprecated since 6.5 use {@link PostJobContext#config()}
    */
   Settings settings();
 
+  /**
+   * Get configuration of the current project.
+   * @since 6.5
+   */
+  Configuration config();
+
   AnalysisMode analysisMode();
 
   // ----------- Only available in preview mode --------------
index f47c408ccf040f84bf0eea85a6953dc054bfc9e9..8da60fb974e77943cbc6c1437bcd5132e987feae 100644 (file)
@@ -24,6 +24,7 @@ import org.sonar.api.SonarRuntime;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.InputModule;
+import org.sonar.api.batch.postjob.PostJobContext;
 import org.sonar.api.batch.rule.ActiveRules;
 import org.sonar.api.batch.sensor.coverage.NewCoverage;
 import org.sonar.api.batch.sensor.cpd.NewCpdTokens;
@@ -36,6 +37,7 @@ import org.sonar.api.batch.sensor.measure.Measure;
 import org.sonar.api.batch.sensor.measure.NewMeasure;
 import org.sonar.api.batch.sensor.symbol.NewSymbolTable;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.Version;
 
 /**
@@ -46,10 +48,16 @@ import org.sonar.api.utils.Version;
 public interface SensorContext {
 
   /**
-   * Get settings of the current module.
+   * @deprecated since 6.5 use {@link PostJobContext#config()}
    */
   Settings settings();
 
+  /**
+   * Get settings of the current module, or of the project for a global Sensor.
+   * @since 6.5
+   */
+  Configuration config();
+
   /**
    * Get filesystem of the current module.
    */
index 3ff672988da61ba931d65e5d8d5252336b139850..abdb03c9ecc7005341bf4cd0e8761c405ae377f2 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.api.batch.fs.internal.PathPattern;
 import org.sonar.api.batch.sensor.cpd.NewCpdTokens;
 import org.sonar.api.batch.sensor.internal.DefaultStorable;
 import org.sonar.api.batch.sensor.internal.SensorStorage;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.duplications.internal.pmd.TokensLine;
 
 import static com.google.common.base.Preconditions.checkState;
@@ -37,7 +37,7 @@ import static java.util.Objects.requireNonNull;
 
 public class DefaultCpdTokens extends DefaultStorable implements NewCpdTokens {
 
-  private final Settings settings;
+  private final Configuration config;
   private final ArrayList<TokensLine> result = new ArrayList<>();
   private InputFile inputFile;
   private int startLine = Integer.MIN_VALUE;
@@ -47,15 +47,15 @@ public class DefaultCpdTokens extends DefaultStorable implements NewCpdTokens {
   private TextRange lastRange;
   private boolean excluded;
 
-  public DefaultCpdTokens(Settings settings, SensorStorage storage) {
+  public DefaultCpdTokens(Configuration config, SensorStorage storage) {
     super(storage);
-    this.settings = settings;
+    this.config = config;
   }
 
   @Override
   public DefaultCpdTokens onFile(InputFile inputFile) {
     this.inputFile = requireNonNull(inputFile, "file can't be null");
-    String[] cpdExclusions = settings.getStringArray(CoreProperties.CPD_EXCLUSIONS);
+    String[] cpdExclusions = config.getStringArray(CoreProperties.CPD_EXCLUSIONS);
     for (PathPattern cpdExclusion : PathPattern.create(cpdExclusions)) {
       if (cpdExclusion.match(inputFile)) {
         this.excluded = true;
index 4a3d60763ec26d5879d9f58d7c237ed6ebec8fa9..711821e7909be688e12a53dc8f4fa4b23174f127 100644 (file)
@@ -64,8 +64,10 @@ import org.sonar.api.batch.sensor.measure.NewMeasure;
 import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
 import org.sonar.api.batch.sensor.symbol.NewSymbolTable;
 import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.ConfigurationBridge;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.internal.ApiVersion;
 import org.sonar.api.internal.SonarRuntimeImpl;
 import org.sonar.api.measures.Metric;
@@ -122,6 +124,11 @@ public class SensorContextTester implements SensorContext {
     return settings;
   }
 
+  @Override
+  public Configuration config() {
+    return new ConfigurationBridge(settings);
+  }
+
   public SensorContextTester setSettings(Settings settings) {
     this.settings = settings;
     return this;
@@ -269,7 +276,7 @@ public class SensorContextTester implements SensorContext {
 
   @Override
   public NewCpdTokens newCpdTokens() {
-    return new DefaultCpdTokens(settings, sensorStorage);
+    return new DefaultCpdTokens(config(), sensorStorage);
   }
 
   @Override
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Configuration.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/Configuration.java
new file mode 100644 (file)
index 0000000..f91996a
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.api.config;
+
+import java.util.Optional;
+import org.sonar.api.batch.ScannerSide;
+import org.sonar.api.ce.ComputeEngineSide;
+import org.sonar.api.config.internal.MapSettings;
+import org.sonar.api.server.ServerSide;
+import org.sonarsource.api.sonarlint.SonarLintSide;
+
+/**
+ * Component to get effective configuration. Values of properties depend on the runtime environment:
+ * <ul>
+ *   <li>immutable project or module configuration in scanner.</li>
+ *   <li>global configuration in web server. It does not allow to get the settings overridden on projects.</li>
+ *   <li>project configuration in Compute Engine.</li>
+ * </ul>
+ *
+ * <h3>Usage</h3>
+ * <pre>
+ * public class MyExtension {
+ *
+ *   private final Configuration config;
+ *
+ *   public MyExtension(Configuration config) {
+ *     this.config = config;
+ *   }
+ *   public void doSomething() {
+ *     String fooValue = config.get("sonar.foo").orElse(null);
+ *     // ..
+ *   }
+ * }
+ * </pre>
+ *
+ * <h3>Scanner example</h3>
+ * Scanner sensor can get the reference on Configuration directly through SensorContext,
+ * without injecting the component into constructor.
+ *
+ * <pre>
+ * public class MySensor implements Sensor {
+ *   {@literal @}Override
+ *   public void execute(SensorContext context) {
+ *     String fooValue = context.config().get("sonar.foo").orElse(null);
+ *     // ..
+ *   }
+ * }
+ * </pre>
+ *
+ * <p>
+ * For testing, and only for testing, the in-memory implementation {@link MapSettings} can be used.
+ * <pre>
+ * {@literal @}Test
+ * public void my_test() {
+ *   MapSettings settings = new MapSettings();
+ *   settings.setProperty("foo", "bar");
+ *   MyExtension underTest = new MyExtension(settings.asConfig());
+ *   // ...
+ * }
+ * </pre>
+ *
+ * @see MapSettings
+ * @see PropertyDefinition
+ * @since 6.5
+ */
+@ScannerSide
+@ServerSide
+@ComputeEngineSide
+@SonarLintSide
+public interface Configuration {
+
+  /**
+   * The effective value of the specified property. Can return {@code Optional#empty()} if the property is not set and has no defined default value.
+   * <p>
+   * If the property is encrypted with a secret key, then the returned value is decrypted.
+   * </p>
+   *
+   * @throws IllegalStateException if value is encrypted but fails to be decrypted.
+   */
+  Optional<String> get(String key);
+
+  /**
+   * @return {@code true} if the property has a non-default value, else {@code false}.
+   */
+  boolean hasKey(String key);
+
+  /**
+   * Used to read multi-valued properties. 
+   * <p>
+   * See {@link PropertyDefinition.Builder#multiValues(boolean)}
+   * Multi-valued properties coming from scanner are parsed as CSV lines (ie comma separator and optional double quotes to escape values).
+   * Non quoted values are trimmed.
+   * <br>
+   * Examples :
+   * <ul>
+   * <li>"one,two,three " -&gt; ["one", "two", "three"]</li>
+   * <li>"  one, two, three " -&gt; ["one", "two", "three"]</li>
+   * <li>"one, , three" -&gt; ["one", "", "three"]</li>
+   * <li>"one,\"two,three\",\" four \"" -&gt; ["one", "two,three", " four "]</li>
+   * </ul>
+   */
+  String[] getStringArray(String key);
+
+  /**
+   * Effective value as boolean. It is {@code empty} if {@link #get(String)} is empty or if it
+   * does not return {@code "true"}, even if it's not a boolean representation.
+   * @return {@code true} if the effective value is {@code "true"}, {@code false} for any other non empty value. 
+   * If the property does not have value nor default value, then {@code empty} is returned.
+   */
+  default Optional<Boolean> getBoolean(String key) {
+    return get(key).map(Boolean::parseBoolean);
+  }
+
+  /**
+   * Effective value as {@code int}.
+   * @return the value as {@code int}. If the property does not have value nor default value, then {@code empty} is returned.
+   * @throws NumberFormatException if value is not empty and is not a parsable integer
+   */
+  default Optional<Integer> getInt(String key) {
+    try {
+      return get(key).map(Integer::parseInt);
+    } catch (NumberFormatException e) {
+      throw new IllegalStateException(String.format("The property '%s' is not an int value: %s", key, e.getMessage()));
+    }
+  }
+
+  /**
+   * Effective value as {@code long}.
+   * @return the value as {@code long}. If the property does not have value nor default value, then {@code empty} is returned.
+   * @throws NumberFormatException if value is not empty and is not a parsable {@code long}
+   */
+  default Optional<Long> getLong(String key) {
+    try {
+      return get(key).map(Long::parseLong);
+    } catch (NumberFormatException e) {
+      throw new IllegalStateException(String.format("The property '%s' is not an long value: %s", key, e.getMessage()));
+    }
+  }
+
+  /**
+   * Effective value as {@code Float}.
+   * @return the value as {@code Float}. If the property does not have value nor default value, then {@code empty} is returned.
+   * @throws NumberFormatException if value is not empty and is not a parsable number
+   */
+  default Optional<Float> getFloat(String key) {
+    try {
+      return get(key).map(Float::valueOf);
+    } catch (NumberFormatException e) {
+      throw new IllegalStateException(String.format("The property '%s' is not an float value: %s", key, e.getMessage()));
+    }
+  }
+
+  /**
+   * Effective value as {@code Double}.
+   * @return the value as {@code Double}. If the property does not have value nor default value, then {@code empty} is returned.
+   * @throws NumberFormatException if value is not empty and is not a parsable number
+   */
+  default Optional<Double> getDouble(String key) {
+    try {
+      return get(key).map(Double::valueOf);
+    } catch (NumberFormatException e) {
+      throw new IllegalStateException(String.format("The property '%s' is not an double value: %s", key, e.getMessage()));
+    }
+  }
+
+}
index dc4498845220a99bdb101ddbad9278da3b4e4b3b..dae2594593acc05640685523b84fefb1f25b998f 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.api.config;
 
 import java.util.List;
 import org.sonar.api.PropertyType;
-import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.ce.ComputeEngineSide;
 import org.sonar.api.server.ServerSide;
 
@@ -34,11 +33,8 @@ import static org.sonar.api.PropertyType.INTEGER;
 import static org.sonar.api.PropertyType.SINGLE_SELECT_LIST;
 
 /**
- * If batch extensions use this component, then batch must be executed with administrator rights (see properties sonar.login and sonar.password)
- *
  * @since 3.2
  */
-@ScannerSide
 @ServerSide
 @ComputeEngineSide
 public class EmailSettings {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/MapSettings.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/MapSettings.java
deleted file mode 100644 (file)
index 5a73567..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.config;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
-import static java.util.Collections.unmodifiableMap;
-
-/**
- * In-memory map-based implementation of {@link Settings}. It must be used
- * <b>only for unit tests</b>. This is not the implementation
- * deployed at runtime, so non-test code must never cast
- * {@link Settings} to {@link MapSettings}.
- *
- * @since 6.1
- */
-public class MapSettings extends Settings {
-
-  private final Map<String, String> props = new HashMap<>();
-
-  public MapSettings() {
-    super(new PropertyDefinitions(), new Encryption(null));
-  }
-
-  public MapSettings(PropertyDefinitions definitions) {
-    super(definitions, new Encryption(null));
-  }
-
-  @Override
-  protected Optional<String> get(String key) {
-    return Optional.ofNullable(props.get(key));
-  }
-
-  @Override
-  protected void set(String key, String value) {
-    props.put(key, value);
-  }
-
-  @Override
-  protected void remove(String key) {
-    props.remove(key);
-  }
-
-  @Override
-  public Map<String, String> getProperties() {
-    return unmodifiableMap(props);
-  }
-
-  /**
-   * Delete all properties
-   */
-  public MapSettings clear() {
-    props.clear();
-    return this;
-  }
-}
index 02d64853e8e51fcad7bc58d0051f5ad9378dd14a..13c407d000b0f5284ea0dfded19c2be5383e212b 100644 (file)
@@ -57,7 +57,7 @@ import static org.sonar.api.PropertyType.REGULAR_EXPRESSION;
 import static org.sonar.api.PropertyType.SINGLE_SELECT_LIST;
 
 /**
- * Declare a plugin property. Values are available at runtime through the component {@link Settings}.
+ * Declare a plugin property. Values are available at runtime through the components {@link Settings} or {@link org.sonar.api.Configuration.SettingsReader}.
  * <br>
  * It's the programmatic alternative to the annotation {@link org.sonar.api.Property}. It is more
  * testable and adds new features like sub-categories and ordering.
index 9a0834b62be4bed0b4aaa43ea8a399179e5e1417..b0e5275674fd8c1cc4c084f84995278e7c61b6cf 100644 (file)
@@ -165,6 +165,7 @@ public final class PropertyDefinitions {
     return byCategory;
   }
 
+  @CheckForNull
   public String getDefaultValue(String key) {
     PropertyDefinition def = get(key);
     if (def == null) {
index 7e182dcd55561489516172f4db62b6b730de372c..20fb15bff452bd1a323896697360c906527d3085 100644 (file)
@@ -35,69 +35,19 @@ import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.ce.ComputeEngineSide;
 import org.sonar.api.server.ServerSide;
 import org.sonar.api.utils.DateUtils;
+import org.sonarsource.api.sonarlint.SonarLintSide;
 
 import static java.util.Objects.requireNonNull;
 import static org.apache.commons.lang.StringUtils.trim;
 
 /**
- * Component to get effective settings. Values of properties depend on the runtime environment:
- * <ul>
- *   <li>project settings in scanner.</li>
- *   <li>global settings in web server. It does not allow to get the settings overridden on projects.</li>
- *   <li>project settings in Compute Engine.</li>
- * </ul>
- *
- * <h3>Usage</h3>
- * <pre>
- * public class MyExtension {
- *
- *   private final Settings settings;
- *
- *   public MyExtension(Settings settings) {
- *     this.settings = settings;
- *   }
- *   public void doSomething() {
- *     String fooValue = settings.getString("sonar.foo");
- *     // ..
- *   }
- * }
- * </pre>
- *
- * <h3>Scanner example</h3>
- * Scanner sensor can get the reference on Settings directly through SensorContext,
- * without injecting the component into constructor.
- *
- * <pre>
- * public class MySensor implements Sensor {
- *   {@literal @}Override
- *   public void execute(SensorContext context) {
- *     String fooValue = context.settings().getString("sonar.foo");
- *     // ..
- *   }
- * }
- * </pre>
- *
- * <p>
- * For testing, and only for testing, the in-memory implementation {@link MapSettings} can be used.
- * <pre>
- * {@literal @}Test
- * public void my_test() {
- *   Settings settings = new MapSettings();
- *   settings.setProperty("foo", "bar");
- *   MyExtension underTest = new MyExtension(settings);
- *   // ...
- * }
- * </pre>
- *
- * History - this class is abstract since 6.1.
- *
- * @see MapSettings
- * @see PropertyDefinition
- * @since 2.12
+ * @deprecated since 6.5 use {@link Configuration}
  */
-@ScannerSide
 @ServerSide
 @ComputeEngineSide
+@ScannerSide
+@SonarLintSide
+@Deprecated
 public abstract class Settings {
 
   private final PropertyDefinitions definitions;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/ConfigurationBridge.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/ConfigurationBridge.java
new file mode 100644 (file)
index 0000000..4e8ef58
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.api.config.internal;
+
+import java.util.Optional;
+import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
+
+/**
+ * Used to help migration from {@link Settings} to {@link Configuration}
+ */
+public class ConfigurationBridge implements Configuration {
+
+  private final Settings settings;
+
+  public ConfigurationBridge(Settings settings) {
+    this.settings = settings;
+  }
+
+  @Override
+  public Optional<String> get(String key) {
+    return Optional.ofNullable(settings.getString(key));
+  }
+
+  @Override
+  public boolean hasKey(String key) {
+    return settings.hasKey(key);
+  }
+
+  @Override
+  public String[] getStringArray(String key) {
+    return settings.getStringArray(key);
+  }
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/MapSettings.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/MapSettings.java
new file mode 100644 (file)
index 0000000..6d45e12
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.api.config.internal;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.sonar.api.config.Configuration;
+import org.sonar.api.config.Encryption;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.config.Settings;
+
+import static java.util.Collections.unmodifiableMap;
+
+/**
+ * In-memory map-based implementation of {@link Settings}. It must be used
+ * <b>only for unit tests</b>. This is not the implementation
+ * deployed at runtime, so non-test code must never cast
+ * {@link Settings} to {@link MapSettings}.
+ *
+ * @since 6.1
+ */
+public class MapSettings extends Settings {
+
+  private final Map<String, String> props = new HashMap<>();
+  private final ConfigurationBridge configurationBridge;
+
+  public MapSettings() {
+    this(new PropertyDefinitions());
+  }
+
+  public MapSettings(PropertyDefinitions definitions) {
+    super(definitions, new Encryption(null));
+    configurationBridge = new ConfigurationBridge(this);
+  }
+
+  @Override
+  protected Optional<String> get(String key) {
+    return Optional.ofNullable(props.get(key));
+  }
+
+  @Override
+  protected void set(String key, String value) {
+    props.put(key, value);
+  }
+
+  @Override
+  protected void remove(String key) {
+    props.remove(key);
+  }
+
+  @Override
+  public Map<String, String> getProperties() {
+    return unmodifiableMap(props);
+  }
+
+  /**
+   * Delete all properties
+   */
+  public MapSettings clear() {
+    props.clear();
+    return this;
+  }
+
+  /**
+   * @return a {@link Configuration} proxy on top of this existing {@link Settings} implementation. Changes are reflected in the {@link Configuration} object.
+   * @since 6.5
+   */
+  public Configuration asConfig() {
+    return configurationBridge;
+  }
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java
new file mode 100644 (file)
index 0000000..4fb297e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.api.config.internal;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index 1a071e6275893dda450df69d9362a45ea8035271..af7e9550b96edb45c8f691174cf1d519d5b24b6d 100644 (file)
@@ -24,7 +24,7 @@ import java.util.stream.Stream;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 
 /**
  * Configuration of file inclusions and exclusions.
@@ -35,9 +35,9 @@ import org.sonar.api.config.Settings;
  */
 @ScannerSide
 public class FileExclusions {
-  private final Settings settings;
+  private final Configuration settings;
 
-  public FileExclusions(Settings settings) {
+  public FileExclusions(Configuration settings) {
     this.settings = settings;
   }
 
index b8b08a4e4dcacb85d9c1a8caec2678ad82fa3507..72fd4a8539ce9dfe1274ebef779a3233b0c51564 100644 (file)
@@ -23,7 +23,7 @@ import java.io.File;
 import org.junit.Test;
 import org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.core.Is.is;
index 9b20b94d700a208389d61ddddd2c4f1bbc94d383..62a268f00f73e62959930638f22bd7cd8fe52459 100644 (file)
@@ -24,7 +24,7 @@ import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.sensor.internal.SensorStorage;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.fail;
@@ -44,7 +44,7 @@ public class DefaultCpdTokensTest {
   @Test
   public void save_no_tokens() {
     SensorStorage sensorStorage = mock(SensorStorage.class);
-    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings(), sensorStorage)
+    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings().asConfig(), sensorStorage)
       .onFile(INPUT_FILE);
 
     tokens.save();
@@ -57,7 +57,7 @@ public class DefaultCpdTokensTest {
   @Test
   public void save_one_token() {
     SensorStorage sensorStorage = mock(SensorStorage.class);
-    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings(), sensorStorage)
+    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings().asConfig(), sensorStorage)
       .onFile(INPUT_FILE)
       .addToken(INPUT_FILE.newRange(1, 2, 1, 5), "foo");
 
@@ -71,9 +71,9 @@ public class DefaultCpdTokensTest {
   @Test
   public void handle_exclusions_by_pattern() {
     SensorStorage sensorStorage = mock(SensorStorage.class);
-    Settings settings = new MapSettings();
+    MapSettings settings = new MapSettings();
     settings.setProperty("sonar.cpd.exclusions", "src/Foo.java,another");
-    DefaultCpdTokens tokens = new DefaultCpdTokens(settings, sensorStorage)
+    DefaultCpdTokens tokens = new DefaultCpdTokens(settings.asConfig(), sensorStorage)
       .onFile(INPUT_FILE)
       .addToken(INPUT_FILE.newRange(1, 2, 1, 5), "foo");
 
@@ -87,7 +87,7 @@ public class DefaultCpdTokensTest {
   @Test
   public void save_many_tokens() {
     SensorStorage sensorStorage = mock(SensorStorage.class);
-    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings(), sensorStorage)
+    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings().asConfig(), sensorStorage)
       .onFile(INPUT_FILE)
       .addToken(INPUT_FILE.newRange(1, 2, 1, 5), "foo")
       .addToken(INPUT_FILE.newRange(1, 6, 1, 10), "bar")
@@ -108,7 +108,7 @@ public class DefaultCpdTokensTest {
   @Test
   public void basic_validation() {
     SensorStorage sensorStorage = mock(SensorStorage.class);
-    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings(), sensorStorage);
+    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings().asConfig(), sensorStorage);
     try {
       tokens.save();
       fail("Expected exception");
@@ -138,7 +138,7 @@ public class DefaultCpdTokensTest {
   @Test
   public void validate_tokens_order() {
     SensorStorage sensorStorage = mock(SensorStorage.class);
-    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings(), sensorStorage)
+    DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings().asConfig(), sensorStorage)
       .onFile(INPUT_FILE)
       .addToken(INPUT_FILE.newRange(1, 6, 1, 10), "bar");
 
index 4893f6fdd63b849117270037b93efaffd8a4b3a1..566facb4a1afef09de92e07511bce01a04cec567 100644 (file)
@@ -38,8 +38,8 @@ import org.sonar.api.batch.sensor.error.NewAnalysisError;
 import org.sonar.api.batch.sensor.highlighting.TypeOfText;
 import org.sonar.api.batch.sensor.issue.NewIssue;
 import org.sonar.api.batch.sensor.symbol.NewSymbolTable;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.SonarException;
index b5504b5d2b31230249287c1bc8466b986d7658c2..507ab123b085d9642c0f17e97a6c761c306f3f8c 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.api.config;
 
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/MapSettingsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/MapSettingsTest.java
deleted file mode 100644 (file)
index 284d35e..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.config;
-
-import java.util.Date;
-import org.assertj.core.data.Offset;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
-import org.sonar.api.PropertyType;
-import org.sonar.api.utils.DateUtils;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class MapSettingsTest {
-
-  private PropertyDefinitions definitions;
-
-  @Properties({
-    @Property(key = "hello", name = "Hello", defaultValue = "world"),
-    @Property(key = "date", name = "Date", defaultValue = "2010-05-18"),
-    @Property(key = "datetime", name = "DateTime", defaultValue = "2010-05-18T15:50:45+0100"),
-    @Property(key = "boolean", name = "Boolean", defaultValue = "true"),
-    @Property(key = "falseboolean", name = "False Boolean", defaultValue = "false"),
-    @Property(key = "integer", name = "Integer", defaultValue = "12345"),
-    @Property(key = "array", name = "Array", defaultValue = "one,two,three"),
-    @Property(key = "multi_values", name = "Array", defaultValue = "1,2,3", multiValues = true),
-    @Property(key = "sonar.jira", name = "Jira Server", type = PropertyType.PROPERTY_SET, propertySetKey = "jira"),
-    @Property(key = "newKey", name = "New key", deprecatedKey = "oldKey"),
-    @Property(key = "newKeyWithDefaultValue", name = "New key with default value", deprecatedKey = "oldKeyWithDefaultValue", defaultValue = "default_value"),
-    @Property(key = "new_multi_values", name = "New multi values", defaultValue = "1,2,3", multiValues = true, deprecatedKey = "old_multi_values")
-  })
-  private static class Init {
-  }
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  @Before
-  public void init_definitions() {
-    definitions = new PropertyDefinitions();
-    definitions.addComponent(Init.class);
-  }
-
-  @Test
-  public void default_values_should_be_loaded_from_definitions() {
-    Settings settings = new MapSettings(definitions);
-    assertThat(settings.getDefaultValue("hello")).isEqualTo("world");
-  }
-
-  @Test
-  public void set_property_int() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", 123);
-    assertThat(settings.getInt("foo")).isEqualTo(123);
-    assertThat(settings.getString("foo")).isEqualTo("123");
-    assertThat(settings.getBoolean("foo")).isFalse();
-  }
-
-  @Test
-  public void default_number_values_are_zero() {
-    Settings settings = new MapSettings();
-    assertThat(settings.getInt("foo")).isEqualTo(0);
-    assertThat(settings.getLong("foo")).isEqualTo(0L);
-  }
-
-  @Test
-  public void getInt_value_must_be_valid() {
-    thrown.expect(NumberFormatException.class);
-
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "not a number");
-    settings.getInt("foo");
-  }
-
-  @Test
-  public void all_values_should_be_trimmed_set_property() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "   FOO ");
-    assertThat(settings.getString("foo")).isEqualTo("FOO");
-  }
-
-  @Test
-  public void test_get_default_value() {
-    Settings settings = new MapSettings(definitions);
-    assertThat(settings.getDefaultValue("unknown")).isNull();
-  }
-
-  @Test
-  public void test_get_string() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("hello", "Russia");
-    assertThat(settings.getString("hello")).isEqualTo("Russia");
-  }
-
-  @Test
-  public void setProperty_date() {
-    Settings settings = new MapSettings();
-    Date date = DateUtils.parseDateTime("2010-05-18T15:50:45+0100");
-    settings.setProperty("aDate", date);
-    settings.setProperty("aDateTime", date, true);
-
-    assertThat(settings.getString("aDate")).isEqualTo("2010-05-18");
-    assertThat(settings.getString("aDateTime")).startsWith("2010-05-18T");
-  }
-
-  @Test
-  public void test_get_date() {
-    Settings settings = new MapSettings(definitions);
-    assertThat(settings.getDate("unknown")).isNull();
-    assertThat(settings.getDate("date").getDate()).isEqualTo(18);
-    assertThat(settings.getDate("date").getMonth()).isEqualTo(4);
-  }
-
-  @Test
-  public void test_get_date_not_found() {
-    Settings settings = new MapSettings(definitions);
-    assertThat(settings.getDate("unknown")).isNull();
-  }
-
-  @Test
-  public void test_get_datetime() {
-    Settings settings = new MapSettings(definitions);
-    assertThat(settings.getDateTime("unknown")).isNull();
-    assertThat(settings.getDateTime("datetime").getDate()).isEqualTo(18);
-    assertThat(settings.getDateTime("datetime").getMonth()).isEqualTo(4);
-    assertThat(settings.getDateTime("datetime").getMinutes()).isEqualTo(50);
-  }
-
-  @Test
-  public void test_get_double() {
-    Settings settings = new MapSettings();
-    settings.setProperty("from_double", 3.14159);
-    settings.setProperty("from_string", "3.14159");
-    assertThat(settings.getDouble("from_double")).isEqualTo(3.14159, Offset.offset(0.00001));
-    assertThat(settings.getDouble("from_string")).isEqualTo(3.14159, Offset.offset(0.00001));
-    assertThat(settings.getDouble("unknown")).isNull();
-  }
-
-  @Test
-  public void test_get_float() {
-    Settings settings = new MapSettings();
-    settings.setProperty("from_float", 3.14159f);
-    settings.setProperty("from_string", "3.14159");
-    assertThat(settings.getDouble("from_float")).isEqualTo(3.14159f, Offset.offset(0.00001));
-    assertThat(settings.getDouble("from_string")).isEqualTo(3.14159f, Offset.offset(0.00001));
-    assertThat(settings.getDouble("unknown")).isNull();
-  }
-
-  @Test
-  public void test_get_bad_float() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "bar");
-
-    thrown.expect(IllegalStateException.class);
-    thrown.expectMessage("The property 'foo' is not a float value");
-    settings.getFloat("foo");
-  }
-
-  @Test
-  public void test_get_bad_double() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "bar");
-
-    thrown.expect(IllegalStateException.class);
-    thrown.expectMessage("The property 'foo' is not a double value");
-    settings.getDouble("foo");
-  }
-
-  @Test
-  public void testSetNullFloat() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", (Float) null);
-    assertThat(settings.getFloat("foo")).isNull();
-  }
-
-  @Test
-  public void testSetNullDouble() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", (Double) null);
-    assertThat(settings.getDouble("foo")).isNull();
-  }
-
-  @Test
-  public void getStringArray() {
-    Settings settings = new MapSettings(definitions);
-    String[] array = settings.getStringArray("array");
-    assertThat(array).isEqualTo(new String[] {"one", "two", "three"});
-  }
-
-  @Test
-  public void setStringArray() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("multi_values", new String[] {"A", "B"});
-    String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[] {"A", "B"});
-  }
-
-  @Test
-  public void setStringArrayTrimValues() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("multi_values", new String[] {" A ", " B "});
-    String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[] {"A", "B"});
-  }
-
-  @Test
-  public void setStringArrayEscapeCommas() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("multi_values", new String[] {"A,B", "C,D"});
-    String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[] {"A,B", "C,D"});
-  }
-
-  @Test
-  public void setStringArrayWithEmptyValues() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("multi_values", new String[] {"A,B", "", "C,D"});
-    String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[] {"A,B", "", "C,D"});
-  }
-
-  @Test
-  public void setStringArrayWithNullValues() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("multi_values", new String[] {"A,B", null, "C,D"});
-    String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[] {"A,B", "", "C,D"});
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void shouldFailToSetArrayValueOnSingleValueProperty() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("array", new String[] {"A", "B", "C"});
-  }
-
-  @Test
-  public void getStringArray_no_value() {
-    Settings settings = new MapSettings();
-    String[] array = settings.getStringArray("array");
-    assertThat(array).isEmpty();
-  }
-
-  @Test
-  public void shouldTrimArray() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "  one,  two, three  ");
-    String[] array = settings.getStringArray("foo");
-    assertThat(array).isEqualTo(new String[] {"one", "two", "three"});
-  }
-
-  @Test
-  public void shouldKeepEmptyValuesWhenSplitting() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "  one,  , two");
-    String[] array = settings.getStringArray("foo");
-    assertThat(array).isEqualTo(new String[] {"one", "", "two"});
-  }
-
-  @Test
-  public void testDefaultValueOfGetString() {
-    Settings settings = new MapSettings(definitions);
-    assertThat(settings.getString("hello")).isEqualTo("world");
-  }
-
-  @Test
-  public void set_property_boolean() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", true);
-    settings.setProperty("bar", false);
-    assertThat(settings.getBoolean("foo")).isTrue();
-    assertThat(settings.getBoolean("bar")).isFalse();
-    assertThat(settings.getString("foo")).isEqualTo("true");
-    assertThat(settings.getString("bar")).isEqualTo("false");
-  }
-
-  @Test
-  public void ignore_case_of_boolean_values() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "true");
-    settings.setProperty("bar", "TRUE");
-    // labels in UI
-    settings.setProperty("baz", "True");
-
-    assertThat(settings.getBoolean("foo")).isTrue();
-    assertThat(settings.getBoolean("bar")).isTrue();
-    assertThat(settings.getBoolean("baz")).isTrue();
-  }
-
-  @Test
-  public void get_boolean() {
-    Settings settings = new MapSettings(definitions);
-    assertThat(settings.getBoolean("boolean")).isTrue();
-    assertThat(settings.getBoolean("falseboolean")).isFalse();
-    assertThat(settings.getBoolean("unknown")).isFalse();
-    assertThat(settings.getBoolean("hello")).isFalse();
-  }
-
-  @Test
-  public void shouldCreateByIntrospectingComponent() {
-    Settings settings = new MapSettings();
-    settings.getDefinitions().addComponent(MyComponent.class);
-
-    // property definition has been loaded, ie for default value
-    assertThat(settings.getDefaultValue("foo")).isEqualTo("bar");
-  }
-
-  @Property(key = "foo", name = "Foo", defaultValue = "bar")
-  public static class MyComponent {
-
-  }
-
-  @Test
-  public void getStringLines_no_value() {
-    assertThat(new MapSettings().getStringLines("foo")).hasSize(0);
-  }
-
-  @Test
-  public void getStringLines_single_line() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "the line");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"the line"});
-  }
-
-  @Test
-  public void getStringLines_linux() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "one\ntwo");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
-
-    settings.setProperty("foo", "one\ntwo\n");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
-  }
-
-  @Test
-  public void getStringLines_windows() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "one\r\ntwo");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
-
-    settings.setProperty("foo", "one\r\ntwo\r\n");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
-  }
-
-  @Test
-  public void getStringLines_mix() {
-    Settings settings = new MapSettings();
-    settings.setProperty("foo", "one\r\ntwo\nthree");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two", "three"});
-  }
-
-  @Test
-  public void getKeysStartingWith() {
-    Settings settings = new MapSettings();
-    settings.setProperty("sonar.jdbc.url", "foo");
-    settings.setProperty("sonar.jdbc.username", "bar");
-    settings.setProperty("sonar.security", "admin");
-
-    assertThat(settings.getKeysStartingWith("sonar")).containsOnly("sonar.jdbc.url", "sonar.jdbc.username", "sonar.security");
-    assertThat(settings.getKeysStartingWith("sonar.jdbc")).containsOnly("sonar.jdbc.url", "sonar.jdbc.username");
-    assertThat(settings.getKeysStartingWith("other")).hasSize(0);
-  }
-
-  @Test
-  public void should_fallback_deprecated_key_to_default_value_of_new_key() {
-    Settings settings = new MapSettings(definitions);
-
-    assertThat(settings.getString("newKeyWithDefaultValue")).isEqualTo("default_value");
-    assertThat(settings.getString("oldKeyWithDefaultValue")).isEqualTo("default_value");
-  }
-
-  @Test
-  public void should_fallback_deprecated_key_to_new_key() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("newKey", "value of newKey");
-
-    assertThat(settings.getString("newKey")).isEqualTo("value of newKey");
-    assertThat(settings.getString("oldKey")).isEqualTo("value of newKey");
-  }
-
-  @Test
-  public void should_load_value_of_deprecated_key() {
-    // it's used for example when deprecated settings are set through command-line
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("oldKey", "value of oldKey");
-
-    assertThat(settings.getString("newKey")).isEqualTo("value of oldKey");
-    assertThat(settings.getString("oldKey")).isEqualTo("value of oldKey");
-  }
-
-  @Test
-  public void should_load_values_of_deprecated_key() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("oldKey", "a,b");
-
-    assertThat(settings.getStringArray("newKey")).containsOnly("a", "b");
-    assertThat(settings.getStringArray("oldKey")).containsOnly("a", "b");
-  }
-
-  @Test
-  public void should_support_deprecated_props_with_multi_values() {
-    Settings settings = new MapSettings(definitions);
-    settings.setProperty("new_multi_values", new String[] {" A ", " B "});
-    assertThat(settings.getStringArray("new_multi_values")).isEqualTo(new String[] {"A", "B"});
-    assertThat(settings.getStringArray("old_multi_values")).isEqualTo(new String[] {"A", "B"});
-  }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java
new file mode 100644 (file)
index 0000000..e28a73c
--- /dev/null
@@ -0,0 +1,430 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.api.config.internal;
+
+import java.util.Date;
+import org.assertj.core.data.Offset;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
+import org.sonar.api.utils.DateUtils;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class MapSettingsTest {
+
+  private PropertyDefinitions definitions;
+
+  @Properties({
+    @Property(key = "hello", name = "Hello", defaultValue = "world"),
+    @Property(key = "date", name = "Date", defaultValue = "2010-05-18"),
+    @Property(key = "datetime", name = "DateTime", defaultValue = "2010-05-18T15:50:45+0100"),
+    @Property(key = "boolean", name = "Boolean", defaultValue = "true"),
+    @Property(key = "falseboolean", name = "False Boolean", defaultValue = "false"),
+    @Property(key = "integer", name = "Integer", defaultValue = "12345"),
+    @Property(key = "array", name = "Array", defaultValue = "one,two,three"),
+    @Property(key = "multi_values", name = "Array", defaultValue = "1,2,3", multiValues = true),
+    @Property(key = "sonar.jira", name = "Jira Server", type = PropertyType.PROPERTY_SET, propertySetKey = "jira"),
+    @Property(key = "newKey", name = "New key", deprecatedKey = "oldKey"),
+    @Property(key = "newKeyWithDefaultValue", name = "New key with default value", deprecatedKey = "oldKeyWithDefaultValue", defaultValue = "default_value"),
+    @Property(key = "new_multi_values", name = "New multi values", defaultValue = "1,2,3", multiValues = true, deprecatedKey = "old_multi_values")
+  })
+  private static class Init {
+  }
+
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+
+  @Before
+  public void init_definitions() {
+    definitions = new PropertyDefinitions();
+    definitions.addComponent(Init.class);
+  }
+
+  @Test
+  public void default_values_should_be_loaded_from_definitions() {
+    Settings settings = new MapSettings(definitions);
+    assertThat(settings.getDefaultValue("hello")).isEqualTo("world");
+  }
+
+  @Test
+  public void set_property_int() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", 123);
+    assertThat(settings.getInt("foo")).isEqualTo(123);
+    assertThat(settings.getString("foo")).isEqualTo("123");
+    assertThat(settings.getBoolean("foo")).isFalse();
+  }
+
+  @Test
+  public void default_number_values_are_zero() {
+    Settings settings = new MapSettings();
+    assertThat(settings.getInt("foo")).isEqualTo(0);
+    assertThat(settings.getLong("foo")).isEqualTo(0L);
+  }
+
+  @Test
+  public void getInt_value_must_be_valid() {
+    thrown.expect(NumberFormatException.class);
+
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "not a number");
+    settings.getInt("foo");
+  }
+
+  @Test
+  public void all_values_should_be_trimmed_set_property() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "   FOO ");
+    assertThat(settings.getString("foo")).isEqualTo("FOO");
+  }
+
+  @Test
+  public void test_get_default_value() {
+    Settings settings = new MapSettings(definitions);
+    assertThat(settings.getDefaultValue("unknown")).isNull();
+  }
+
+  @Test
+  public void test_get_string() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("hello", "Russia");
+    assertThat(settings.getString("hello")).isEqualTo("Russia");
+  }
+
+  @Test
+  public void setProperty_date() {
+    Settings settings = new MapSettings();
+    Date date = DateUtils.parseDateTime("2010-05-18T15:50:45+0100");
+    settings.setProperty("aDate", date);
+    settings.setProperty("aDateTime", date, true);
+
+    assertThat(settings.getString("aDate")).isEqualTo("2010-05-18");
+    assertThat(settings.getString("aDateTime")).startsWith("2010-05-18T");
+  }
+
+  @Test
+  public void test_get_date() {
+    Settings settings = new MapSettings(definitions);
+    assertThat(settings.getDate("unknown")).isNull();
+    assertThat(settings.getDate("date").getDate()).isEqualTo(18);
+    assertThat(settings.getDate("date").getMonth()).isEqualTo(4);
+  }
+
+  @Test
+  public void test_get_date_not_found() {
+    Settings settings = new MapSettings(definitions);
+    assertThat(settings.getDate("unknown")).isNull();
+  }
+
+  @Test
+  public void test_get_datetime() {
+    Settings settings = new MapSettings(definitions);
+    assertThat(settings.getDateTime("unknown")).isNull();
+    assertThat(settings.getDateTime("datetime").getDate()).isEqualTo(18);
+    assertThat(settings.getDateTime("datetime").getMonth()).isEqualTo(4);
+    assertThat(settings.getDateTime("datetime").getMinutes()).isEqualTo(50);
+  }
+
+  @Test
+  public void test_get_double() {
+    Settings settings = new MapSettings();
+    settings.setProperty("from_double", 3.14159);
+    settings.setProperty("from_string", "3.14159");
+    assertThat(settings.getDouble("from_double")).isEqualTo(3.14159, Offset.offset(0.00001));
+    assertThat(settings.getDouble("from_string")).isEqualTo(3.14159, Offset.offset(0.00001));
+    assertThat(settings.getDouble("unknown")).isNull();
+  }
+
+  @Test
+  public void test_get_float() {
+    Settings settings = new MapSettings();
+    settings.setProperty("from_float", 3.14159f);
+    settings.setProperty("from_string", "3.14159");
+    assertThat(settings.getDouble("from_float")).isEqualTo(3.14159f, Offset.offset(0.00001));
+    assertThat(settings.getDouble("from_string")).isEqualTo(3.14159f, Offset.offset(0.00001));
+    assertThat(settings.getDouble("unknown")).isNull();
+  }
+
+  @Test
+  public void test_get_bad_float() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "bar");
+
+    thrown.expect(IllegalStateException.class);
+    thrown.expectMessage("The property 'foo' is not a float value");
+    settings.getFloat("foo");
+  }
+
+  @Test
+  public void test_get_bad_double() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "bar");
+
+    thrown.expect(IllegalStateException.class);
+    thrown.expectMessage("The property 'foo' is not a double value");
+    settings.getDouble("foo");
+  }
+
+  @Test
+  public void testSetNullFloat() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", (Float) null);
+    assertThat(settings.getFloat("foo")).isNull();
+  }
+
+  @Test
+  public void testSetNullDouble() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", (Double) null);
+    assertThat(settings.getDouble("foo")).isNull();
+  }
+
+  @Test
+  public void getStringArray() {
+    Settings settings = new MapSettings(definitions);
+    String[] array = settings.getStringArray("array");
+    assertThat(array).isEqualTo(new String[] {"one", "two", "three"});
+  }
+
+  @Test
+  public void setStringArray() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("multi_values", new String[] {"A", "B"});
+    String[] array = settings.getStringArray("multi_values");
+    assertThat(array).isEqualTo(new String[] {"A", "B"});
+  }
+
+  @Test
+  public void setStringArrayTrimValues() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("multi_values", new String[] {" A ", " B "});
+    String[] array = settings.getStringArray("multi_values");
+    assertThat(array).isEqualTo(new String[] {"A", "B"});
+  }
+
+  @Test
+  public void setStringArrayEscapeCommas() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("multi_values", new String[] {"A,B", "C,D"});
+    String[] array = settings.getStringArray("multi_values");
+    assertThat(array).isEqualTo(new String[] {"A,B", "C,D"});
+  }
+
+  @Test
+  public void setStringArrayWithEmptyValues() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("multi_values", new String[] {"A,B", "", "C,D"});
+    String[] array = settings.getStringArray("multi_values");
+    assertThat(array).isEqualTo(new String[] {"A,B", "", "C,D"});
+  }
+
+  @Test
+  public void setStringArrayWithNullValues() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("multi_values", new String[] {"A,B", null, "C,D"});
+    String[] array = settings.getStringArray("multi_values");
+    assertThat(array).isEqualTo(new String[] {"A,B", "", "C,D"});
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void shouldFailToSetArrayValueOnSingleValueProperty() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("array", new String[] {"A", "B", "C"});
+  }
+
+  @Test
+  public void getStringArray_no_value() {
+    Settings settings = new MapSettings();
+    String[] array = settings.getStringArray("array");
+    assertThat(array).isEmpty();
+  }
+
+  @Test
+  public void shouldTrimArray() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "  one,  two, three  ");
+    String[] array = settings.getStringArray("foo");
+    assertThat(array).isEqualTo(new String[] {"one", "two", "three"});
+  }
+
+  @Test
+  public void shouldKeepEmptyValuesWhenSplitting() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "  one,  , two");
+    String[] array = settings.getStringArray("foo");
+    assertThat(array).isEqualTo(new String[] {"one", "", "two"});
+  }
+
+  @Test
+  public void testDefaultValueOfGetString() {
+    Settings settings = new MapSettings(definitions);
+    assertThat(settings.getString("hello")).isEqualTo("world");
+  }
+
+  @Test
+  public void set_property_boolean() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", true);
+    settings.setProperty("bar", false);
+    assertThat(settings.getBoolean("foo")).isTrue();
+    assertThat(settings.getBoolean("bar")).isFalse();
+    assertThat(settings.getString("foo")).isEqualTo("true");
+    assertThat(settings.getString("bar")).isEqualTo("false");
+  }
+
+  @Test
+  public void ignore_case_of_boolean_values() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "true");
+    settings.setProperty("bar", "TRUE");
+    // labels in UI
+    settings.setProperty("baz", "True");
+
+    assertThat(settings.getBoolean("foo")).isTrue();
+    assertThat(settings.getBoolean("bar")).isTrue();
+    assertThat(settings.getBoolean("baz")).isTrue();
+  }
+
+  @Test
+  public void get_boolean() {
+    Settings settings = new MapSettings(definitions);
+    assertThat(settings.getBoolean("boolean")).isTrue();
+    assertThat(settings.getBoolean("falseboolean")).isFalse();
+    assertThat(settings.getBoolean("unknown")).isFalse();
+    assertThat(settings.getBoolean("hello")).isFalse();
+  }
+
+  @Test
+  public void shouldCreateByIntrospectingComponent() {
+    Settings settings = new MapSettings();
+    settings.getDefinitions().addComponent(MyComponent.class);
+
+    // property definition has been loaded, ie for default value
+    assertThat(settings.getDefaultValue("foo")).isEqualTo("bar");
+  }
+
+  @Property(key = "foo", name = "Foo", defaultValue = "bar")
+  public static class MyComponent {
+
+  }
+
+  @Test
+  public void getStringLines_no_value() {
+    assertThat(new MapSettings().getStringLines("foo")).hasSize(0);
+  }
+
+  @Test
+  public void getStringLines_single_line() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "the line");
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"the line"});
+  }
+
+  @Test
+  public void getStringLines_linux() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "one\ntwo");
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
+
+    settings.setProperty("foo", "one\ntwo\n");
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
+  }
+
+  @Test
+  public void getStringLines_windows() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "one\r\ntwo");
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
+
+    settings.setProperty("foo", "one\r\ntwo\r\n");
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
+  }
+
+  @Test
+  public void getStringLines_mix() {
+    Settings settings = new MapSettings();
+    settings.setProperty("foo", "one\r\ntwo\nthree");
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two", "three"});
+  }
+
+  @Test
+  public void getKeysStartingWith() {
+    Settings settings = new MapSettings();
+    settings.setProperty("sonar.jdbc.url", "foo");
+    settings.setProperty("sonar.jdbc.username", "bar");
+    settings.setProperty("sonar.security", "admin");
+
+    assertThat(settings.getKeysStartingWith("sonar")).containsOnly("sonar.jdbc.url", "sonar.jdbc.username", "sonar.security");
+    assertThat(settings.getKeysStartingWith("sonar.jdbc")).containsOnly("sonar.jdbc.url", "sonar.jdbc.username");
+    assertThat(settings.getKeysStartingWith("other")).hasSize(0);
+  }
+
+  @Test
+  public void should_fallback_deprecated_key_to_default_value_of_new_key() {
+    Settings settings = new MapSettings(definitions);
+
+    assertThat(settings.getString("newKeyWithDefaultValue")).isEqualTo("default_value");
+    assertThat(settings.getString("oldKeyWithDefaultValue")).isEqualTo("default_value");
+  }
+
+  @Test
+  public void should_fallback_deprecated_key_to_new_key() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("newKey", "value of newKey");
+
+    assertThat(settings.getString("newKey")).isEqualTo("value of newKey");
+    assertThat(settings.getString("oldKey")).isEqualTo("value of newKey");
+  }
+
+  @Test
+  public void should_load_value_of_deprecated_key() {
+    // it's used for example when deprecated settings are set through command-line
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("oldKey", "value of oldKey");
+
+    assertThat(settings.getString("newKey")).isEqualTo("value of oldKey");
+    assertThat(settings.getString("oldKey")).isEqualTo("value of oldKey");
+  }
+
+  @Test
+  public void should_load_values_of_deprecated_key() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("oldKey", "a,b");
+
+    assertThat(settings.getStringArray("newKey")).containsOnly("a", "b");
+    assertThat(settings.getStringArray("oldKey")).containsOnly("a", "b");
+  }
+
+  @Test
+  public void should_support_deprecated_props_with_multi_values() {
+    Settings settings = new MapSettings(definitions);
+    settings.setProperty("new_multi_values", new String[] {" A ", " B "});
+    assertThat(settings.getStringArray("new_multi_values")).isEqualTo(new String[] {"A", "B"});
+    assertThat(settings.getStringArray("old_multi_values")).isEqualTo(new String[] {"A", "B"});
+  }
+}
index bd98496fdf9854bcf23d97062e80bd31843ba06a..bd03eec7fed46561283952480a9829b9f55125cd 100644 (file)
@@ -21,27 +21,26 @@ package org.sonar.api.scan.filesystem;
 
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class FileExclusionsTest {
   @Test
   public void ignore_inclusion_of_world() {
-    Settings settings = new MapSettings();
+    MapSettings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*");
     settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "**/*");
-    assertThat(new FileExclusions(settings).sourceInclusions()).isEmpty();
-    assertThat(new FileExclusions(settings).testInclusions()).isEmpty();
+    assertThat(new FileExclusions(settings.asConfig()).sourceInclusions()).isEmpty();
+    assertThat(new FileExclusions(settings.asConfig()).testInclusions()).isEmpty();
   }
 
   @Test
   public void load_inclusions() {
-    Settings settings = new MapSettings();
+    MapSettings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Foo.java");
     settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "**/*FooTest.java");
-    FileExclusions moduleExclusions = new FileExclusions(settings);
+    FileExclusions moduleExclusions = new FileExclusions(settings.asConfig());
 
     assertThat(moduleExclusions.sourceInclusions()).containsOnly("**/*Foo.java");
     assertThat(moduleExclusions.testInclusions()).containsOnly("**/*FooTest.java");
@@ -49,10 +48,10 @@ public class FileExclusionsTest {
 
   @Test
   public void load_exclusions() {
-    Settings settings = new MapSettings();
+    MapSettings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*Foo.java");
     settings.setProperty(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY, "**/*FooTest.java");
-    FileExclusions moduleExclusions = new FileExclusions(settings);
+    FileExclusions moduleExclusions = new FileExclusions(settings.asConfig());
 
     assertThat(moduleExclusions.sourceInclusions()).isEmpty();
     assertThat(moduleExclusions.sourceExclusions()).containsOnly("**/*Foo.java");
index 7be87bcc876d1d127309c2e152da3e83cccddf7f..07540030654b860f7c02a6a58b99870c68df1d51 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.batch.bootstrapper;
 
 import com.google.common.base.Throwables;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
index e6c54ec7b33b9d2d8d7cc401388b5012284356fd..08b3d410625bc1bc0dd461b6a0208ada9e4dde6f 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.batch.bootstrapper;
 
 import com.google.common.annotations.VisibleForTesting;
-
 import java.util.HashMap;
 import java.util.Map;
 import javax.annotation.CheckForNull;
index 06cdd32e6072dde9a96ce18d72f63decebc5fb30..40d7cbcd3c7613109bfb3e5fcc11e150a0aaf665 100644 (file)
 package org.sonar.scanner;
 
 import java.util.Date;
+import java.util.Optional;
 import org.picocontainer.Startable;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
+import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.SonarException;
 import org.sonar.api.utils.System2;
 
@@ -33,12 +35,12 @@ import org.sonar.api.utils.System2;
 @ScannerSide
 public class ProjectAnalysisInfo implements Startable {
   private final System2 system2;
-  private Settings settings;
+  private Configuration settings;
 
   private Date analysisDate;
   private String analysisVersion;
 
-  public ProjectAnalysisInfo(Settings settings, System2 system2) {
+  public ProjectAnalysisInfo(Configuration settings, System2 system2) {
     this.settings = settings;
     this.system2 = system2;
   }
@@ -52,23 +54,22 @@ public class ProjectAnalysisInfo implements Startable {
   }
 
   private Date loadAnalysisDate() {
+    Optional<String> value = settings.get(CoreProperties.PROJECT_DATE_PROPERTY);
+    if (!value.isPresent()) {
+      return new Date(system2.now());
+    }
     Date date;
     try {
       // sonar.projectDate may have been specified as a time
-      date = settings.getDateTime(CoreProperties.PROJECT_DATE_PROPERTY);
+      return DateUtils.parseDateTime(value.get());
     } catch (SonarException e) {
       // this is probably just a date
-      date = settings.getDate(CoreProperties.PROJECT_DATE_PROPERTY);
-    }
-    if (date == null) {
-      date = new Date(system2.now());
-      settings.setProperty(CoreProperties.PROJECT_DATE_PROPERTY, date, true);
+      return DateUtils.parseDate(value.get());
     }
-    return date;
   }
 
   private String loadAnalysisVersion() {
-    return settings.getString(CoreProperties.PROJECT_VERSION_PROPERTY);
+    return settings.get(CoreProperties.PROJECT_VERSION_PROPERTY).orElse(null);
   }
 
   @Override
index a43de6ee6991e62b35c262a12eaa566716f21cef..dc4a860533c155c4deaaa8e5ae18ec8ce5182fa4 100644 (file)
  */
 package org.sonar.scanner.analysis;
 
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.picocontainer.PicoContainer;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import org.picocontainer.ComponentLifecycle;
+import org.picocontainer.PicoContainer;
 import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.utils.TempFolder;
 import org.sonar.api.utils.internal.DefaultTempFolder;
 
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
 public class AnalysisTempFolderProvider extends ProviderAdapter implements ComponentLifecycle<TempFolder> {
   static final String TMP_NAME = ".sonartmp";
   private DefaultTempFolder projectTempFolder;
index 359d68547ed86812d2527168a6d8be1b4f1b1ed2..103acf208634a3e566e9bc31756ddfd1b0f71d96 100644 (file)
 package org.sonar.scanner.bootstrap;
 
 import org.picocontainer.injectors.ProviderAdapter;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.home.cache.FileCache;
 import org.sonar.home.cache.FileCacheBuilder;
 
 public class FileCacheProvider extends ProviderAdapter {
   private FileCache cache;
 
-  public FileCache provide(Settings settings) {
+  public FileCache provide(Configuration settings) {
     if (cache == null) {
-      String home = settings.getString("sonar.userHome");
+      String home = settings.get("sonar.userHome").orElse(null);
       cache = new FileCacheBuilder(new Slf4jLogger()).setUserHome(home).build();
     }
     return cache;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java
new file mode 100644 (file)
index 0000000..336d0ce
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.bootstrap;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
+import java.util.Map;
+import javax.annotation.concurrent.Immutable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.batch.AnalysisMode;
+import org.sonar.api.config.Encryption;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.scanner.config.DefaultConfiguration;
+
+@Immutable
+public class GlobalConfiguration extends DefaultConfiguration {
+
+  private static final Logger LOG = LoggerFactory.getLogger(GlobalConfiguration.class);
+
+  private static final String JDBC_SPECIFIC_MESSAGE = "It will be ignored. There is no longer any DB connection to the SQ database.";
+  /**
+   * A map of dropped properties as key and specific message to display for that property
+   * (what will happen, what should the user do, ...) as a value
+   */
+  private static final Map<String, String> DROPPED_PROPERTIES = ImmutableMap.of(
+    "sonar.jdbc.url", JDBC_SPECIFIC_MESSAGE,
+    "sonar.jdbc.username", JDBC_SPECIFIC_MESSAGE,
+    "sonar.jdbc.password", JDBC_SPECIFIC_MESSAGE);
+
+  private final Map<String, String> serverSideSettings;
+
+  public GlobalConfiguration(PropertyDefinitions propertyDefinitions, Encryption encryption, AnalysisMode mode,
+    Map<String, String> settings, Map<String, String> serverSideSettings) {
+    super(propertyDefinitions, encryption, mode, settings);
+    this.serverSideSettings = serverSideSettings;
+
+    get(CoreProperties.PERMANENT_SERVER_ID).ifPresent(v -> LOG.info("Server id: {}", v));
+    new DroppedPropertyChecker(getProperties(), DROPPED_PROPERTIES).checkDroppedProperties();
+  }
+
+  public Map<String, String> getServerSideSettings() {
+    return Collections.unmodifiableMap(serverSideSettings);
+  }
+
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java
new file mode 100644 (file)
index 0000000..26467a6
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.bootstrap;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.scanner.repository.settings.SettingsLoader;
+
+public class GlobalConfigurationProvider extends ProviderAdapter {
+
+  private GlobalConfiguration globalSettings;
+
+  public GlobalConfiguration provide(SettingsLoader loader, GlobalProperties globalProps, PropertyDefinitions propertyDefinitions, GlobalMode mode) {
+    if (globalSettings == null) {
+
+      Map<String, String> serverSideSettings = loader.load(null);
+
+      Map<String, String> settings = new LinkedHashMap<>();
+      settings.putAll(serverSideSettings);
+      settings.putAll(globalProps.properties());
+
+      globalSettings = new GlobalConfiguration(propertyDefinitions, globalProps.getEncryption(), mode, settings, serverSideSettings);
+    }
+    return globalSettings;
+  }
+}
index 55ab768d00f25b477a29ef662cde36ff407dd380..259058a71632f4b9297c5eecf864b1059754fb31 100644 (file)
@@ -85,7 +85,8 @@ public class GlobalContainer extends ComponentContainer {
       new SonarQubeVersion(apiVersion),
       SonarRuntimeImpl.forSonarQube(apiVersion, SonarQubeSide.SCANNER),
       StoragesManager.class,
-      GlobalSettings.class,
+      MutableGlobalSettings.class,
+      new GlobalConfigurationProvider(),
       new ScannerWsClientProvider(),
       DefaultServer.class,
       new GlobalTempFolderProvider(),
index 4dac8f34ec773adebf6b5f8d2d945e91b5f75e55..d03a67b84ed7f75f269a351f618d8c1d61a25f2a 100644 (file)
@@ -19,9 +19,8 @@
  */
 package org.sonar.scanner.bootstrap;
 
-import org.sonar.api.CoreProperties;
-
 import java.util.Map;
+import org.sonar.api.CoreProperties;
 
 /**
  * Immutable batch properties that are not specific to a task (for example
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalSettings.java
deleted file mode 100644 (file)
index 8955281..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.scanner.bootstrap;
-
-import com.google.common.collect.ImmutableMap;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.config.Encryption;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
-import org.sonar.api.utils.MessageException;
-import org.sonar.scanner.repository.settings.SettingsLoader;
-
-public class GlobalSettings extends Settings {
-
-  private static final Logger LOG = LoggerFactory.getLogger(GlobalSettings.class);
-
-  private static final String JDBC_SPECIFIC_MESSAGE = "It will be ignored. There is no longer any DB connection to the SQ database.";
-  /**
-   * A map of dropped properties as key and specific message to display for that property
-   * (what will happen, what should the user do, ...) as a value
-   */
-  private static final Map<String, String> DROPPED_PROPERTIES = ImmutableMap.of(
-    "sonar.jdbc.url", JDBC_SPECIFIC_MESSAGE,
-    "sonar.jdbc.username", JDBC_SPECIFIC_MESSAGE,
-    "sonar.jdbc.password", JDBC_SPECIFIC_MESSAGE);
-
-  private final Map<String, String> serverSideSettings;
-
-  private final GlobalProperties bootstrapProps;
-  private final GlobalMode mode;
-  private final Map<String, String> properties = new HashMap<>();
-
-  public GlobalSettings(GlobalProperties bootstrapProps, PropertyDefinitions propertyDefinitions,
-    SettingsLoader settingsLoader, GlobalMode mode) {
-
-    super(propertyDefinitions, new Encryption(bootstrapProps.property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH)));
-    this.mode = mode;
-    this.bootstrapProps = bootstrapProps;
-    this.serverSideSettings = ImmutableMap.copyOf(settingsLoader.load(null));
-    init();
-    new DroppedPropertyChecker(this.getProperties(), DROPPED_PROPERTIES).checkDroppedProperties();
-  }
-
-  private void init() {
-    addProperties(serverSideSettings);
-    addProperties(bootstrapProps.properties());
-
-    if (hasKey(CoreProperties.PERMANENT_SERVER_ID)) {
-      LOG.info("Server id: " + getString(CoreProperties.PERMANENT_SERVER_ID));
-    }
-  }
-
-  public Map<String, String> getServerSideSettings() {
-    return serverSideSettings;
-  }
-
-  @Override
-  protected Optional<String> get(String key) {
-    if (mode.isIssues() && key.endsWith(".secured") && !key.contains(".license")) {
-      throw MessageException.of("Access to the secured property '" + key
-        + "' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
-    }
-    return Optional.ofNullable(properties.get(key));
-  }
-
-  @Override
-  public Map<String, String> getProperties() {
-    return properties;
-  }
-
-  @Override
-  protected void set(String key, String value) {
-    properties.put(key, value);
-  }
-
-  @Override
-  protected void remove(String key) {
-    properties.remove(key);
-  }
-}
index 35426aebf5fb551ef1b8ee24f0a4b81398130bde..b6fbe2485e167f9b9db620bfd73c90a1861a35ef 100644 (file)
 package org.sonar.scanner.bootstrap;
 
 import com.google.common.collect.Lists;
-import org.sonar.api.batch.ScannerSide;
+import java.util.List;
 import org.sonar.api.ExtensionProvider;
 import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.measures.Metrics;
 
-import java.util.List;
-
 @ScannerSide
 @InstantiationStrategy(InstantiationStrategy.PER_BATCH)
 public class MetricProvider extends ExtensionProvider {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MutableGlobalSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MutableGlobalSettings.java
new file mode 100644 (file)
index 0000000..e31ce43
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.bootstrap;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.sonar.api.batch.AnalysisMode;
+import org.sonar.api.config.Settings;
+import org.sonar.api.utils.MessageException;
+
+/**
+ * @deprecated since 6.5 {@link GlobalConfiguration} used to be mutable, so keep a mutable copy for backward compatibility.
+ */
+@Deprecated
+public class MutableGlobalSettings extends Settings {
+
+  private final AnalysisMode mode;
+  private final Map<String, String> mutableProperties = new HashMap<>();
+
+  public MutableGlobalSettings(GlobalConfiguration globalSettings) {
+    super(globalSettings.getDefinitions(), globalSettings.getEncryption());
+    this.mutableProperties.putAll(globalSettings.getProperties());
+    this.mode = globalSettings.getMode();
+  }
+
+  @Override
+  protected Optional<String> get(String key) {
+    if (mode.isIssues() && key.endsWith(".secured") && !key.contains(".license")) {
+      throw MessageException.of("Access to the secured property '" + key
+        + "' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
+    }
+    return Optional.ofNullable(mutableProperties.get(key));
+  }
+
+  @Override
+  public Map<String, String> getProperties() {
+    return mutableProperties;
+  }
+
+  @Override
+  protected void set(String key, String value) {
+    mutableProperties.put(key, value);
+  }
+
+  @Override
+  protected void remove(String key) {
+    mutableProperties.remove(key);
+  }
+}
index 705b3cc4560bd35582673556f200d48675f15910..70749f70fc0f7850afccb17e09d04ba77597b2e7 100644 (file)
@@ -29,7 +29,6 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.stream.Collectors;
-
 import javax.annotation.Nullable;
 import org.apache.commons.lang.ClassUtils;
 import org.sonar.api.batch.CheckProject;
index 733048345ca0f426e8045383dcbaaceed1d4b868..4fcf68ca9182a9c1ff6360a669e5d313a9191f29 100644 (file)
  */
 package org.sonar.scanner.bootstrap;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import org.apache.commons.io.FileUtils;
 import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.utils.ZipUtils;
 import org.sonar.core.platform.ExplodedPlugin;
-import org.sonar.core.platform.PluginJarExploder;
 import org.sonar.core.platform.PluginInfo;
+import org.sonar.core.platform.PluginJarExploder;
 import org.sonar.home.cache.FileCache;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
 import static org.sonar.core.util.FileUtils.deleteQuietly;
 
 @ScannerSide
index 438bfda8b8c6eb62333a8525b1336ec23628e20a..befc42c1ea08644fa233384c2bc04933a5354f41 100644 (file)
@@ -22,20 +22,17 @@ package org.sonar.scanner.bootstrap;
 import com.google.common.base.Joiner;
 import com.google.common.base.Predicate;
 import com.google.common.base.Splitter;
-
 import java.util.List;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.StreamSupport;
-
 import javax.annotation.Nonnull;
-
-import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
+
 import static com.google.common.collect.Sets.newHashSet;
 
 /**
@@ -53,7 +50,7 @@ public class ScannerPluginPredicate implements Predicate<String> {
   private final Set<String> blacks = newHashSet();
   private final GlobalMode mode;
 
-  public ScannerPluginPredicate(Settings settings, GlobalMode mode) {
+  public ScannerPluginPredicate(Configuration settings, GlobalMode mode) {
     this.mode = mode;
     if (mode.isPreview() || mode.isIssues()) {
       // These default values are not supported by Settings because the class CorePlugin
@@ -92,8 +89,8 @@ public class ScannerPluginPredicate implements Predicate<String> {
     return blacks;
   }
 
-  private static List<String> propertyValues(Settings settings, String key, String defaultValue) {
-    String s = StringUtils.defaultIfEmpty(settings.getString(key), defaultValue);
+  private static List<String> propertyValues(Configuration settings, String key, String defaultValue) {
+    String s = settings.get(key).orElse(defaultValue);
     return StreamSupport.stream(Splitter.on(",").trimResults().omitEmptyStrings().split(s).spliterator(), false)
       .collect(Collectors.toList());
   }
index 2065bb63755d8d424ca73a4b5914532468b0594e..06b6482500c9dfa3a22b0f309082dd6851ea2ba5 100644 (file)
@@ -23,9 +23,7 @@ import com.google.common.base.Preconditions;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.annotation.CheckForNull;
-
 import org.picocontainer.Startable;
 import org.sonar.api.Plugin;
 import org.sonar.api.utils.log.Logger;
index 5de66cf665fc7e7d4e18c13ba14f77bb95f8852e..c6e4d8d77c37f83bc79cfe0ad93d2b8bad18fd51 100644 (file)
  */
 package org.sonar.scanner.bootstrap;
 
-import org.sonar.api.config.Encryption;
-
-import javax.annotation.Nullable;
-
 import java.util.HashMap;
 import java.util.Map;
+import javax.annotation.Nullable;
+import org.sonar.api.config.Encryption;
 
 /**
  * Properties that are coming from bootstrapper.
@@ -51,6 +49,10 @@ public abstract class UserProperties {
     this.properties = decryptedProps;
   }
 
+  public Encryption getEncryption() {
+    return encryption;
+  }
+
   public Map<String, String> properties() {
     return properties;
   }
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/CsvParser.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/CsvParser.java
new file mode 100644 (file)
index 0000000..efdfc5b
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class CsvParser {
+
+  public static String[] parseLine(String line) {
+    List<String> result = new ArrayList<>();
+
+    AtomicInteger i = new AtomicInteger(0);
+    while (true) {
+      String cell = parseNextCell(line, i);
+      if (cell == null)
+        break;
+      result.add(cell);
+    }
+
+    return result.toArray(new String[0]);
+  }
+
+  // returns iterator after delimiter or after end of string
+  private static String parseNextCell(String line, AtomicInteger i) {
+    if (i.get() >= line.length())
+      return null;
+
+    if (line.charAt(i.get()) != '"')
+      return parseNotEscapedCell(line, i);
+    else
+      return parseEscapedCell(line, i);
+  }
+
+  // returns iterator after delimiter or after end of string
+  private static String parseNotEscapedCell(String line, AtomicInteger i) {
+    StringBuilder sb = new StringBuilder();
+    while (true) {
+      if (i.get() >= line.length()) {
+        // return iterator after end of string
+        break;
+      }
+      if (line.charAt(i.get()) == ',') {
+        // return iterator after delimiter
+        i.incrementAndGet();
+        break;
+      }
+      sb.append(line.charAt(i.get()));
+      i.incrementAndGet();
+    }
+    return sb.toString();
+  }
+
+  // returns iterator after delimiter or after end of string
+  private static String parseEscapedCell(String line, AtomicInteger i) {
+    i.incrementAndGet(); // omit first character (quotation mark)
+    StringBuilder sb = new StringBuilder();
+    while (true) {
+      if (i.get() >= line.length()) {
+        break;
+      }
+      if (line.charAt(i.get()) == '"') {
+        i.incrementAndGet(); // we're more interested in the next character
+        if (i.get() >= line.length()) {
+          // quotation mark was closing cell
+          // return iterator after end of string
+          break;
+        }
+        if (line.charAt(i.get()) == ',') {
+          // quotation mark was closing cell
+          // return iterator after delimiter
+          i.incrementAndGet();
+          break;
+        }
+        if (line.charAt(i.get()) == '"') {
+          // it was doubled (escaped) quotation mark
+          // do nothing -- we've already skipped first quotation mark
+        }
+
+      }
+      sb.append(line.charAt(i.get()));
+      i.incrementAndGet();
+    }
+
+    return sb.toString();
+  }
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java
new file mode 100644 (file)
index 0000000..35d9ac9
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.config;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import javax.annotation.concurrent.Immutable;
+import org.apache.commons.lang.ArrayUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.batch.AnalysisMode;
+import org.sonar.api.config.Configuration;
+import org.sonar.api.config.Encryption;
+import org.sonar.api.config.PropertyDefinition;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.utils.MessageException;
+
+import static java.util.Objects.requireNonNull;
+import static org.apache.commons.lang.StringUtils.trim;
+
+@Immutable
+public abstract class DefaultConfiguration implements Configuration {
+
+  private static final Logger LOG = LoggerFactory.getLogger(DefaultConfiguration.class);
+
+  private final PropertyDefinitions definitions;
+  private final Encryption encryption;
+  private final AnalysisMode mode;
+  private final Map<String, String> properties = new HashMap<>();
+
+  public DefaultConfiguration(PropertyDefinitions propertyDefinitions, Encryption encryption, AnalysisMode mode, Map<String, String> props) {
+    this.definitions = requireNonNull(propertyDefinitions);
+    this.encryption = encryption;
+    this.mode = mode;
+    props.forEach((k, v) -> {
+      String validKey = definitions.validKey(k);
+      properties.put(validKey, trim(v));
+    });
+  }
+
+  public AnalysisMode getMode() {
+    return mode;
+  }
+
+  public Encryption getEncryption() {
+    return encryption;
+  }
+
+  public PropertyDefinitions getDefinitions() {
+    return definitions;
+  }
+
+  public Map<String, String> getProperties() {
+    return Collections.unmodifiableMap(properties);
+  }
+
+  @Override
+  public boolean hasKey(String key) {
+    return properties.containsKey(key);
+  }
+
+  @Override
+  public Optional<String> get(String key) {
+    String effectiveKey = definitions.validKey(key);
+    PropertyDefinition def = definitions.get(effectiveKey);
+    if (def != null && def.multiValues()) {
+      LOG.warn("Access to the multi-valued property '{}' should be made using 'getStringArray' method. The SonarQube plugin using this property should be updated.");
+    }
+    return getInternal(effectiveKey);
+  }
+
+  @Override
+  public String[] getStringArray(String key) {
+    String effectiveKey = definitions.validKey(key);
+    PropertyDefinition def = definitions.get(effectiveKey);
+    if (def != null && !def.multiValues()) {
+      LOG.warn("Property '{}' is not declared as multi-valued but was read using 'getStringArray' method. The SonarQube plugin declaring this property should be updated.");
+    }
+    Optional<String> value = getInternal(key);
+    if (value.isPresent()) {
+      return CsvParser.parseLine(value.get());
+    }
+    return ArrayUtils.EMPTY_STRING_ARRAY;
+  }
+
+  private Optional<String> getInternal(String key) {
+    if (mode.isIssues() && key.endsWith(".secured") && !key.contains(".license")) {
+      throw MessageException.of("Access to the secured property '" + key
+        + "' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
+    }
+    Optional<String> value = Optional.ofNullable(properties.get(key));
+    if (!value.isPresent()) {
+      // default values cannot be encrypted, so return value as-is.
+      return Optional.ofNullable(definitions.getDefaultValue(key));
+    }
+    if (encryption.isEncrypted(value.get())) {
+      try {
+        return Optional.of(encryption.decrypt(value.get()));
+      } catch (Exception e) {
+        throw new IllegalStateException("Fail to decrypt the property " + key + ". Please check your secret key.", e);
+      }
+    }
+    return value;
+  }
+
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/package-info.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/package-info.java
new file mode 100644 (file)
index 0000000..f39bb54
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.scanner.config;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index 0b964bb62de560a490759026c301dc960c516037..87a0794c1e5d49050c067c75b61f1d2e151ffefb 100644 (file)
@@ -30,11 +30,10 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputComponent;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.duplications.block.Block;
@@ -67,12 +66,12 @@ public class CpdExecutor {
   private final SonarCpdBlockIndex index;
   private final ReportPublisher publisher;
   private final InputComponentStore componentStore;
-  private final Settings settings;
+  private final Configuration settings;
   private final ProgressReport progressReport;
   private int count;
   private int total;
 
-  public CpdExecutor(Settings settings, SonarCpdBlockIndex index, ReportPublisher publisher, InputComponentStore inputComponentCache) {
+  public CpdExecutor(Configuration settings, SonarCpdBlockIndex index, ReportPublisher publisher, InputComponentStore inputComponentCache) {
     this.settings = settings;
     this.index = index;
     this.publisher = publisher;
@@ -157,12 +156,7 @@ public class CpdExecutor {
    * @return
    */
   int getMinimumTokens(String languageKey) {
-    int minimumTokens = settings.getInt("sonar.cpd." + languageKey + ".minimumTokens");
-    if (minimumTokens == 0) {
-      minimumTokens = 100;
-    }
-
-    return minimumTokens;
+    return settings.getInt("sonar.cpd." + languageKey + ".minimumTokens").orElse(100);
   }
 
   @VisibleForTesting
index 033b8f59855be64d74db5072eeeed75ba1ee903e..f04f407d86e01b15b3dd650b146f1b65624846f3 100644 (file)
@@ -20,9 +20,8 @@
 package org.sonar.scanner.cpd;
 
 import com.google.common.base.Predicate;
-import org.sonar.duplications.index.CloneGroup;
-
 import javax.annotation.Nullable;
+import org.sonar.duplications.index.CloneGroup;
 
 public final class DuplicationPredicates {
 
index c88c32124d251bbebaafc02419a1dc32d48019fb..741f3046bc434b666f4fa8a8cee9b907412f754d 100644 (file)
  */
 package org.sonar.scanner.cpd.deprecated;
 
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.batch.CpdMapping;
-
 import javax.annotation.CheckForNull;
+import org.sonar.api.batch.CpdMapping;
+import org.sonar.api.batch.ScannerSide;
 
 @ScannerSide
 public class CpdMappings {
index 587a88a7f16dee534e79dd096b6391850270bc33..88357968eb82f4e677b096153257fbc300399c07 100644 (file)
@@ -30,7 +30,7 @@ import org.sonar.api.batch.fs.FilePredicates;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.duplications.block.Block;
@@ -43,10 +43,10 @@ public class DefaultCpdBlockIndexer extends CpdBlockIndexer {
 
   private final CpdMappings mappings;
   private final FileSystem fs;
-  private final Settings settings;
+  private final Configuration settings;
   private final SonarCpdBlockIndex index;
 
-  public DefaultCpdBlockIndexer(CpdMappings mappings, FileSystem fs, Settings settings, SonarCpdBlockIndex index) {
+  public DefaultCpdBlockIndexer(CpdMappings mappings, FileSystem fs, Configuration settings, SonarCpdBlockIndex index) {
     this.mappings = mappings;
     this.fs = fs;
     this.settings = settings;
@@ -100,11 +100,7 @@ public class DefaultCpdBlockIndexer extends CpdBlockIndexer {
 
   @VisibleForTesting
   int getBlockSize(String languageKey) {
-    int blockSize = settings.getInt("sonar.cpd." + languageKey + ".minimumLines");
-    if (blockSize == 0) {
-      blockSize = getDefaultBlockSize(languageKey);
-    }
-    return blockSize;
+    return settings.getInt("sonar.cpd." + languageKey + ".minimumLines").orElse(getDefaultBlockSize(languageKey));
   }
 
   @VisibleForTesting
index fc0e105d2c1218cfe616fa70e57786541a92827d..3b10cd613e801b4cd6433aa5f77ede25338c222c 100644 (file)
@@ -31,7 +31,7 @@ import org.sonar.api.batch.fs.FilePredicates;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.duplications.block.Block;
@@ -50,10 +50,10 @@ public class JavaCpdBlockIndexer extends CpdBlockIndexer {
   private static final int BLOCK_SIZE = 10;
 
   private final FileSystem fs;
-  private final Settings settings;
+  private final Configuration settings;
   private final SonarCpdBlockIndex index;
 
-  public JavaCpdBlockIndexer(FileSystem fs, Settings settings, SonarCpdBlockIndex index) {
+  public JavaCpdBlockIndexer(FileSystem fs, Configuration settings, SonarCpdBlockIndex index) {
     this.fs = fs;
     this.settings = settings;
     this.index = index;
index 84c7d92371f9a49636f981c4331c1ae71f75b48f..2a4cdf9eab0215ba105497c9a85c62a1ba76aa58 100644 (file)
@@ -24,11 +24,10 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.duplications.block.Block;
@@ -45,11 +44,11 @@ public class SonarCpdBlockIndex extends AbstractCloneIndex {
   private static final Logger LOG = Loggers.get(SonarCpdBlockIndex.class);
   private final CloneIndex mem = new PackedMemoryCloneIndex();
   private final ReportPublisher publisher;
-  private final Settings settings;
+  private final Configuration settings;
   // Files already tokenized
   private final Set<InputFile> indexedFiles = new HashSet<>();
 
-  public SonarCpdBlockIndex(ReportPublisher publisher, Settings settings) {
+  public SonarCpdBlockIndex(ReportPublisher publisher, Configuration settings) {
     this.publisher = publisher;
     this.settings = settings;
   }
@@ -88,10 +87,10 @@ public class SonarCpdBlockIndex extends AbstractCloneIndex {
     return indexedFiles.contains(inputFile);
   }
 
-  public static boolean isCrossProjectDuplicationEnabled(Settings settings) {
-    return settings.getBoolean(CoreProperties.CPD_CROSS_PROJECT)
+  public static boolean isCrossProjectDuplicationEnabled(Configuration settings) {
+    return settings.getBoolean(CoreProperties.CPD_CROSS_PROJECT).orElse(false)
       // No cross project duplication for branches
-      && StringUtils.isBlank(settings.getString(CoreProperties.PROJECT_BRANCH_PROPERTY));
+      && !settings.get(CoreProperties.PROJECT_BRANCH_PROPERTY).isPresent();
   }
 
   public Collection<Block> getByInputFile(String resourceKey) {
index 40975c8538a03c084474f622537f20dca48e268a..3679fa3fd1ae545da073459f2880f5af448ab138 100644 (file)
@@ -31,7 +31,7 @@ import org.sonar.api.batch.fs.InputModule;
 import org.sonar.api.batch.fs.InputPath;
 import org.sonar.api.batch.rule.ActiveRules;
 import org.sonar.api.batch.sensor.internal.SensorStorage;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.design.Dependency;
 import org.sonar.api.measures.Measure;
 import org.sonar.api.measures.MeasuresFilter;
@@ -46,9 +46,9 @@ public class DeprecatedSensorContext extends DefaultSensorContext implements Sen
   private final DefaultIndex index;
   private final InputModule module;
 
-  public DeprecatedSensorContext(InputModule module, DefaultIndex index, Settings settings, FileSystem fs, ActiveRules activeRules,
+  public DeprecatedSensorContext(InputModule module, DefaultIndex index, Configuration config, org.sonar.api.config.Settings mutableSettings, FileSystem fs, ActiveRules activeRules,
     AnalysisMode analysisMode, SensorStorage sensorStorage, SonarRuntime sonarRuntime) {
-    super(module, settings, fs, activeRules, analysisMode, sensorStorage, sonarRuntime);
+    super(module, config, mutableSettings, fs, activeRules, analysisMode, sensorStorage, sonarRuntime);
     this.index = index;
     this.module = module;
   }
index c4f17972835175afa85b106a0275af494c57fe74..3fe37dcf3c4e42383870014a408abb7b689c21c5 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.scanner.deprecated.perspectives;
 import com.google.common.collect.Maps;
 import java.util.Map;
 import javax.annotation.CheckForNull;
-
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.fs.InputPath;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
index ac2a5b4d5e84e3a441c28c3bbc368fe7ef4f2afd..9237786f4a6d4548b769a7939cdbe3da621cffae 100644 (file)
  */
 package org.sonar.scanner.events;
 
-import org.sonar.api.batch.events.EventHandler;
-
 import java.util.ArrayList;
 import java.util.List;
+import org.sonar.api.batch.events.EventHandler;
 
 /**
  * Dispatches {@link BatchEvent}s. Eases decoupling by allowing objects to interact without having direct dependencies upon one another, and
index a0ae6f4010842d794fe7b0024de4c43bc70abe36..cf0158cb71894dbe22759554531db3196299a317 100644 (file)
@@ -29,8 +29,8 @@ import org.sonar.api.batch.Initializer;
 import org.sonar.api.batch.sensor.Sensor;
 import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.batch.sensor.SensorDescriptor;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.config.Settings;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
@@ -63,9 +63,9 @@ public class GenericCoverageSensor extends Initializer implements Sensor {
   @Deprecated
   static final String OLD_OVERALL_COVERAGE_REPORT_PATHS_PROPERTY_KEY = "sonar.genericcoverage.overallReportPaths";
 
-  private final Settings settings;
+  private final Configuration settings;
 
-  public GenericCoverageSensor(Settings settings) {
+  public GenericCoverageSensor(Configuration settings) {
     this.settings = settings;
   }
 
@@ -95,7 +95,7 @@ public class GenericCoverageSensor extends Initializer implements Sensor {
     loadDeprecated(reportPaths, OLD_IT_COVERAGE_REPORT_PATHS_PROPERTY_KEY);
     loadDeprecated(reportPaths, OLD_OVERALL_COVERAGE_REPORT_PATHS_PROPERTY_KEY);
     if (!reportPaths.isEmpty()) {
-      settings.setProperty(REPORT_PATHS_PROPERTY_KEY, reportPaths.stream().collect(Collectors.joining(",")));
+      // settings.setProperty(REPORT_PATHS_PROPERTY_KEY, reportPaths.stream().collect(Collectors.joining(",")));
     }
   }
 
index 0848af1f9cb3562196ac9135164e8dca47e92655..1690a8a44be44d09ec9876c6d51c4a29b6adb0ac 100644 (file)
@@ -22,9 +22,7 @@ package org.sonar.scanner.index;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.stream.Collectors;
-
 import javax.annotation.CheckForNull;
-
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.fs.InputDir;
 import org.sonar.api.batch.fs.InputFile;
index e1c8531e6b9a7cea470121e148b3c8e6874f6d57..ca0c2cad15e27ba4f5b7170a2562e0984ccc024d 100644 (file)
  */
 package org.sonar.scanner.issue;
 
-import org.sonar.api.rule.RuleKey;
-import org.sonar.batch.bootstrapper.IssueListener;
 import org.sonar.api.batch.rule.Rule;
 import org.sonar.api.batch.rule.Rules;
-
+import org.sonar.api.rule.RuleKey;
+import org.sonar.batch.bootstrapper.IssueListener;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
 
 public class DefaultIssueCallback implements IssueCallback {
index 1895942e71a8f06f52efdedbde807454fd6b21db..d0f01cc432dab88d417c541782fac25c30161a65 100644 (file)
  */
 package org.sonar.scanner.issue;
 
-import org.sonar.api.scan.issue.filter.IssueFilter;
-
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-
 import org.sonar.api.scan.issue.filter.FilterableIssue;
+import org.sonar.api.scan.issue.filter.IssueFilter;
 import org.sonar.api.scan.issue.filter.IssueFilterChain;
 
 public class DefaultIssueFilterChain implements IssueFilterChain {
index 5714296a661df03216ac921f408c549317304e45..6a0c6bcee3bd85a6479d0f209c73f98cd1ffc416 100644 (file)
  */
 package org.sonar.scanner.issue;
 
-import org.sonar.api.issue.Issue;
-import org.sonar.api.issue.ProjectIssues;
-import org.sonar.scanner.issue.tracking.TrackedIssue;
-
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.StreamSupport;
-
 import javax.annotation.Nullable;
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.ProjectIssues;
+import org.sonar.scanner.issue.tracking.TrackedIssue;
 
 /**
  * Expose list of issues for the current project
index daae355a0e955e3985dc2c31a4caa2e716a5ba12..4b45945147e3f99f7cfd5370af61398a2fb54e39 100644 (file)
@@ -24,7 +24,6 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
-
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.issue.IssueComment;
index 9931d75d932ae5d4093a8f69af140cdd4bff4cf0..9b25e4b6a71096738c0e022ea246b3d65fc05176 100644 (file)
  */
 package org.sonar.scanner.issue;
 
-import org.sonar.api.issue.Issue;
-import org.sonar.api.issue.batch.IssueFilter;
-import org.sonar.api.issue.batch.IssueFilterChain;
-
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.batch.IssueFilter;
+import org.sonar.api.issue.batch.IssueFilterChain;
 
 /**
  * @deprecated since 5.3
index dd5165a94322c16ba476b6fe7fc5ee43a78d95b1..2d67ab22c5bcf1320386898fbad4822bafa911b6 100644 (file)
  */
 package org.sonar.scanner.issue;
 
+import java.util.Collection;
 import org.sonar.api.batch.ScannerSide;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
 import org.sonar.scanner.storage.Storage;
 import org.sonar.scanner.storage.Storages;
-import java.util.Collection;
 
 /**
  * Shared issues among all project modules
index bc630a725e1780ebecb0a7455ba60701c9396dda..db9105a3f90df5bf1970c59d2dadf20e4178e39c 100644 (file)
  */
 package org.sonar.scanner.issue;
 
-import org.sonar.api.scan.issue.filter.FilterableIssue;
-
-import org.sonar.api.scan.issue.filter.IssueFilterChain;
-import org.sonar.scanner.ProjectAnalysisInfo;
-import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.issue.Issue;
+import org.sonar.api.scan.issue.filter.FilterableIssue;
 import org.sonar.api.scan.issue.filter.IssueFilter;
+import org.sonar.api.scan.issue.filter.IssueFilterChain;
+import org.sonar.scanner.ProjectAnalysisInfo;
+import org.sonar.scanner.protocol.output.ScannerReport;
 
 @ScannerSide
 public class IssueFilters {
index 958b1e6384389425813be72862f965ff99d58a74..874e4514cf99aa0336237ed0d53d710511431d3a 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.issue;
 
 import com.google.common.base.Strings;
-
 import org.sonar.api.batch.fs.TextRange;
 import org.sonar.api.batch.fs.internal.DefaultInputComponent;
 import org.sonar.api.batch.rule.ActiveRule;
index 5c6e4caf4096704c2fe6878b67f55b756cdc38f8..66efeb194f33ac296d45250f1d3b1c5d61cc7e19 100644 (file)
  */
 package org.sonar.scanner.issue.ignore;
 
-import org.sonar.api.batch.fs.InputComponent;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.scan.issue.filter.FilterableIssue;
-
 import javax.annotation.CheckForNull;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.sonar.api.batch.fs.InputComponent;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.scan.issue.filter.FilterableIssue;
 import org.sonar.api.scan.issue.filter.IssueFilter;
 import org.sonar.api.scan.issue.filter.IssueFilterChain;
 import org.sonar.scanner.issue.ignore.pattern.IssueInclusionPatternInitializer;
index 0c543eab505b73f2a8f02135ba3a1ae977fcb0f1..23c02f54f85936e4fc9af27e540605db5ad984af 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.scanner.issue.ignore;
 
-import org.sonar.api.scan.issue.filter.FilterableIssue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.sonar.api.scan.issue.filter.FilterableIssue;
 import org.sonar.api.scan.issue.filter.IssueFilter;
 import org.sonar.api.scan.issue.filter.IssueFilterChain;
 import org.sonar.scanner.issue.ignore.pattern.IssuePattern;
index b77a921e27f7a0600bce930ef3ef96b79187ed38..9f6be8dd77427909813f9d2779884b896f31c779 100644 (file)
 package org.sonar.scanner.issue.ignore.pattern;
 
 import com.google.common.annotations.VisibleForTesting;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.config.Settings;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.batch.ScannerSide;
+import org.sonar.api.config.Configuration;
 
 import static com.google.common.base.MoreObjects.firstNonNull;
 
 @ScannerSide
 public abstract class AbstractPatternInitializer {
-  private Settings settings;
+  private Configuration settings;
   private List<IssuePattern> multicriteriaPatterns;
 
-  protected AbstractPatternInitializer(Settings settings) {
+  protected AbstractPatternInitializer(Configuration settings) {
     this.settings = settings;
     initPatterns();
   }
 
-  protected Settings getSettings() {
+  protected Configuration getSettings() {
     return settings;
   }
 
@@ -60,11 +59,10 @@ public abstract class AbstractPatternInitializer {
   protected final void initPatterns() {
     // Patterns Multicriteria
     multicriteriaPatterns = new ArrayList<>();
-    String patternConf = StringUtils.defaultIfBlank(settings.getString(getMulticriteriaConfigurationKey()), "");
-    for (String id : StringUtils.split(patternConf, ',')) {
+    for (String id : settings.getStringArray(getMulticriteriaConfigurationKey())) {
       String propPrefix = getMulticriteriaConfigurationKey() + "." + id + ".";
-      String resourceKeyPattern = settings.getString(propPrefix + "resourceKey");
-      String ruleKeyPattern = settings.getString(propPrefix + "ruleKey");
+      String resourceKeyPattern = settings.get(propPrefix + "resourceKey").orElse(null);
+      String ruleKeyPattern = settings.get(propPrefix + "ruleKey").orElse(null);
       String lineRange = "*";
       String[] fields = new String[] {resourceKeyPattern, ruleKeyPattern, lineRange};
       PatternDecoder.checkRegularLineConstraints(StringUtils.join(fields, ","), fields);
index 37d16ef51c52dd3dceb33cb298ee8e9dff842f8e..bbb12afb905fb36b25f7fb9a75bbaf3bdb8d9ae5 100644 (file)
  */
 package org.sonar.scanner.issue.ignore.pattern;
 
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.config.Settings;
-import org.sonar.core.config.IssueExclusionProperties;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.config.Configuration;
+import org.sonar.core.config.IssueExclusionProperties;
 
 import static com.google.common.base.Strings.nullToEmpty;
 
@@ -34,7 +33,7 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer
   private List<BlockIssuePattern> blockPatterns;
   private List<String> allFilePatterns;
 
-  public IssueExclusionPatternInitializer(Settings settings) {
+  public IssueExclusionPatternInitializer(Configuration settings) {
     super(settings);
     loadFileContentPatterns();
   }
@@ -52,11 +51,10 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer
   private final void loadFileContentPatterns() {
     // Patterns Block
     blockPatterns = new ArrayList<>();
-    String patternConf = StringUtils.defaultIfBlank(getSettings().getString(IssueExclusionProperties.PATTERNS_BLOCK_KEY), "");
-    for (String id : StringUtils.split(patternConf, ',')) {
+    for (String id : getSettings().getStringArray(IssueExclusionProperties.PATTERNS_BLOCK_KEY)) {
       String propPrefix = IssueExclusionProperties.PATTERNS_BLOCK_KEY + "." + id + ".";
-      String beginBlockRegexp = getSettings().getString(propPrefix + IssueExclusionProperties.BEGIN_BLOCK_REGEXP);
-      String endBlockRegexp = getSettings().getString(propPrefix + IssueExclusionProperties.END_BLOCK_REGEXP);
+      String beginBlockRegexp = getSettings().get(propPrefix + IssueExclusionProperties.BEGIN_BLOCK_REGEXP).orElse(null);
+      String endBlockRegexp = getSettings().get(propPrefix + IssueExclusionProperties.END_BLOCK_REGEXP).orElse(null);
       String[] fields = new String[] {beginBlockRegexp, endBlockRegexp};
       PatternDecoder.checkDoubleRegexpLineConstraints(StringUtils.join(fields, ","), fields);
       BlockIssuePattern pattern = new BlockIssuePattern(nullToEmpty(beginBlockRegexp), nullToEmpty(endBlockRegexp));
@@ -66,10 +64,9 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer
 
     // Patterns All File
     allFilePatterns = new ArrayList<>();
-    patternConf = StringUtils.defaultIfBlank(getSettings().getString(IssueExclusionProperties.PATTERNS_ALLFILE_KEY), "");
-    for (String id : StringUtils.split(patternConf, ',')) {
+    for (String id : getSettings().getStringArray(IssueExclusionProperties.PATTERNS_ALLFILE_KEY)) {
       String propPrefix = IssueExclusionProperties.PATTERNS_ALLFILE_KEY + "." + id + ".";
-      String allFileRegexp = getSettings().getString(propPrefix + IssueExclusionProperties.FILE_REGEXP);
+      String allFileRegexp = getSettings().get(propPrefix + IssueExclusionProperties.FILE_REGEXP).orElse(null);
       PatternDecoder.checkWholeFileRegexp(allFileRegexp);
       allFilePatterns.add(nullToEmpty(allFileRegexp));
     }
index 7e3992e493c6cc49b657bf7aad817588f735d3c2..2d76c749f57081e79a46eb78dfcbd5b79cc33458 100644 (file)
  */
 package org.sonar.scanner.issue.ignore.pattern;
 
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 
 public class IssueInclusionPatternInitializer extends AbstractPatternInitializer {
 
-  public IssueInclusionPatternInitializer(Settings settings) {
+  public IssueInclusionPatternInitializer(Configuration settings) {
     super(settings);
   }
 
index 9ef0d64c9d49b864fa39d8a13bf40764f44bedcd..4d326f7c1984a009863f2cd3873fec85a861faff 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.issue.ignore.pattern;
 
 import com.google.common.collect.Sets;
-
 import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.util.Set;
index b252484fb7a52b41dd0ec0576f010f020fffd9ff..0f49d4465042c635128e1e83e73dae657e43bb20 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.issue.ignore.pattern;
 
 import com.google.common.base.Preconditions;
-
 import java.util.LinkedHashSet;
 import java.util.Set;
 
index f0ce08b2a19d2e9f4f7a5bf9e965fef0cd7d7d3b..2aa80064276cfb27754a460699042e41507c55df 100644 (file)
  */
 package org.sonar.scanner.issue.ignore.pattern;
 
+import com.google.common.annotations.VisibleForTesting;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
-
 import org.apache.commons.lang.StringUtils;
 
-import com.google.common.annotations.VisibleForTesting;
-
 public class PatternDecoder {
   private static final String LINE_RANGE_REGEXP = "\\[((\\d+|\\d+-\\d+),?)*\\]";
   private static final String CONFIG_FORMAT_ERROR_PREFIX = "Exclusions > Issues : Invalid format. ";
index 2d008410cbe4528ed5a156022749a54ac2bdf313..9afe7ae375be0c85c74119d1814063c55c300144 100644 (file)
  */
 package org.sonar.scanner.issue.ignore.pattern;
 
-import org.sonar.api.rule.RuleKey;
-
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.LinkedHashMultimap;
 import com.google.common.collect.Multimap;
-
 import java.util.Collection;
 import java.util.Set;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
+import org.sonar.api.rule.RuleKey;
 
 public class PatternMatcher {
 
index 30cdeb0c582471dccf4d8a26e19a8db4a03435c8..4bdf149ec05772a12bcc4923cb7161aba111dda8 100644 (file)
@@ -21,9 +21,7 @@ package org.sonar.scanner.issue.ignore.scanner;
 
 import java.util.ArrayList;
 import java.util.List;
-
 import javax.annotation.CheckForNull;
-
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.batch.fs.internal.FileMetadata.CharHandler;
 import org.sonar.scanner.issue.ignore.pattern.BlockIssuePattern;
index 0ad4373665a4a0141665bdb634b6bb668c4f8eac..e0230681382c0b40ef94aadba5eaa5d03678e85f 100644 (file)
@@ -24,7 +24,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.regex.Pattern;
-
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 0f7c9de0aced802755ad67f64de9adb483e8b1c6..01c9140227f77d1efaef819e9b921e87ffc1c22f 100644 (file)
  */
 package org.sonar.scanner.issue.tracking;
 
-import org.sonarqube.ws.client.GetRequest;
-
-import java.io.IOException;
-import java.io.Reader;
-
 import com.google.common.base.Splitter;
 import com.google.common.collect.Iterators;
+import java.io.IOException;
+import java.io.Reader;
 import org.apache.commons.io.IOUtils;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.api.utils.log.Profiler;
 import org.sonar.scanner.bootstrap.ScannerWsClient;
 import org.sonar.scanner.util.ScannerUtils;
+import org.sonarqube.ws.client.GetRequest;
 
 public class DefaultServerLineHashesLoader implements ServerLineHashesLoader {
   private ScannerWsClient wsClient;
index 3ee4ac48da3eb32a6ba1a0ac17fc9df3f219af5a..9f2876275b900d8ec4557ab83c0e210f1f87522b 100644 (file)
  */
 package org.sonar.scanner.issue.tracking;
 
-import org.sonar.core.issue.tracking.Trackable;
-import org.sonar.core.issue.tracking.BlockHashSequence;
-import org.sonar.core.issue.tracking.LineHashSequence;
-
 import java.util.Collection;
 import java.util.List;
-
+import org.sonar.core.issue.tracking.BlockHashSequence;
 import org.sonar.core.issue.tracking.Input;
+import org.sonar.core.issue.tracking.LineHashSequence;
+import org.sonar.core.issue.tracking.Trackable;
 
 public class IssueTrackingInput<T extends Trackable> implements Input<T> {
 
index 3f32e511f78018fad264241b2fc5c6cb82bfdf2e..8dffa1f7015f931798dc5458cfbae02b45d00391 100644 (file)
  */
 package org.sonar.scanner.issue.tracking;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
 import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.fs.internal.DefaultInputComponent;
@@ -31,13 +37,6 @@ import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.report.ReportPublisher;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
 import org.sonar.scanner.util.ProgressReport;
-import javax.annotation.Nullable;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
 
 @ScannerSide
 public class IssueTransition {
index 31bf62f014371f5dd66ce6f6b3fde0199bf9d7b0..b9446d52807b30213128ed9b4460cba9efdabbfb 100644 (file)
@@ -24,7 +24,6 @@ import java.io.Serializable;
 import java.util.Date;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
 import org.sonar.api.rule.RuleKey;
index 0d391526e1fecea42db1dbcbab51c261cd04c7fc..e5f17cbb4431919157f19b2dc5ed8e499a3351b1 100644 (file)
@@ -47,11 +47,11 @@ import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReport.Component;
 import org.sonar.scanner.protocol.output.ScannerReport.Metadata;
 import org.sonar.scanner.protocol.output.ScannerReport.Symbol;
+import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.report.ReportPublisher;
 import org.sonar.scanner.report.ScannerReportUtils;
 import org.sonar.scanner.scan.ProjectScanContainer;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
-import org.sonar.scanner.protocol.output.ScannerReportReader;
 
 import static org.apache.commons.lang.StringUtils.isNotEmpty;
 
index ca1722afad0698ec9ad43035b232adc63788c1ed..b4d5818fc4773b3601ff8f10b8213229a0a4c35f 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.scanner.phases;
 
 import com.google.common.collect.Lists;
+import java.util.Collection;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.batch.Initializer;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
@@ -29,7 +30,6 @@ import org.sonar.api.utils.log.Loggers;
 import org.sonar.api.utils.log.Profiler;
 import org.sonar.scanner.bootstrap.ScannerExtensionDictionnary;
 import org.sonar.scanner.events.EventBus;
-import java.util.Collection;
 
 public class InitializersExecutor {
 
index b231e09f89f98a904f700dbeab3cc0711aa77518..63d3526f659bebd6e0a69ca710ab4f844753985b 100644 (file)
  */
 package org.sonar.scanner.phases;
 
+import java.util.List;
 import org.sonar.api.batch.Sensor;
 import org.sonar.api.batch.events.SensorsPhaseHandler;
 
-import java.util.List;
-
 class SensorsPhaseEvent extends AbstractPhaseEvent<SensorsPhaseHandler>
     implements org.sonar.api.batch.events.SensorsPhaseHandler.SensorsPhaseEvent {
 
index d51903e46460a9b80d14e1460377bf50d6da2640..1848b811c439b346b142437f2e810d178c3a6e51 100644 (file)
@@ -22,13 +22,13 @@ package org.sonar.scanner.postjob;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.StreamSupport;
-
 import javax.annotation.Nullable;
 import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.postjob.PostJobContext;
 import org.sonar.api.batch.postjob.issue.PostJobIssue;
 import org.sonar.api.batch.rule.Severity;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.config.Settings;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.scanner.issue.IssueCache;
@@ -37,13 +37,16 @@ import org.sonar.scanner.scan.filesystem.InputComponentStore;
 
 public class DefaultPostJobContext implements PostJobContext {
 
-  private final Settings settings;
+  private final Configuration config;
   private final IssueCache cache;
   private final AnalysisMode analysisMode;
   private InputComponentStore inputComponentStore;
+  private final Settings mutableSettings;
 
-  public DefaultPostJobContext(Settings settings, IssueCache cache, InputComponentStore inputComponentStore, AnalysisMode analysisMode) {
-    this.settings = settings;
+  public DefaultPostJobContext(Configuration config, Settings mutableSettings, IssueCache cache, InputComponentStore inputComponentStore,
+    AnalysisMode analysisMode) {
+    this.config = config;
+    this.mutableSettings = mutableSettings;
     this.cache = cache;
     this.inputComponentStore = inputComponentStore;
     this.analysisMode = analysisMode;
@@ -51,7 +54,12 @@ public class DefaultPostJobContext implements PostJobContext {
 
   @Override
   public Settings settings() {
-    return settings;
+    return mutableSettings;
+  }
+
+  @Override
+  public Configuration config() {
+    return config;
   }
 
   @Override
index b4d2b94bb1fe2b0b7566b404178a125b573b72e3..4da1aeda04e1351dce45079a7092d237b7952af5 100644 (file)
@@ -37,7 +37,7 @@ import org.sonar.api.utils.System2;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.core.platform.PluginInfo;
-import org.sonar.scanner.bootstrap.GlobalSettings;
+import org.sonar.scanner.bootstrap.GlobalConfiguration;
 import org.sonar.scanner.bootstrap.ScannerPluginRepository;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
 import org.sonar.scanner.repository.ProjectRepositories;
@@ -55,12 +55,12 @@ public class AnalysisContextReportPublisher {
   private final AnalysisMode mode;
   private final System2 system;
   private final ProjectRepositories projectRepos;
-  private final GlobalSettings globalSettings;
+  private final GlobalConfiguration globalSettings;
 
   private ScannerReportWriter writer;
 
   public AnalysisContextReportPublisher(AnalysisMode mode, ScannerPluginRepository pluginRepo, System2 system,
-    ProjectRepositories projectRepos, GlobalSettings globalSettings) {
+    ProjectRepositories projectRepos, GlobalConfiguration globalSettings) {
     this.mode = mode;
     this.pluginRepo = pluginRepo;
     this.system = system;
index 99623384ab3d604b26caeca575d404e2c55d9616..78fa6bea16c0b09e1ffca767d11ab29c192a5ffe 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.scanner.report;
 
 import java.util.Collection;
 import java.util.stream.Collectors;
-
 import javax.annotation.CheckForNull;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
@@ -38,11 +37,11 @@ import org.sonar.api.batch.fs.internal.InputComponentTree;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
 import org.sonar.core.util.CloseableIterator;
 import org.sonar.scanner.protocol.output.ScannerReport;
-import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType;
 import org.sonar.scanner.protocol.output.ScannerReport.ComponentLink;
 import org.sonar.scanner.protocol.output.ScannerReport.ComponentLink.ComponentLinkType;
 import org.sonar.scanner.protocol.output.ScannerReport.Issue;
+import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
 
 /**
index 66ba41ded41c28ddd1eee7c2d3238ac122fb1893..fea8c739fc0a6be9c6d8be3a4d6cc82377ad2ae6 100644 (file)
@@ -23,9 +23,8 @@ import java.util.Map;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
-
 import javax.annotation.Nonnull;
-import org.sonar.api.config.Settings;
+import org.sonar.scanner.config.DefaultConfiguration;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
 import org.sonar.scanner.repository.ContextPropertiesCache;
@@ -35,11 +34,11 @@ import static org.sonar.core.config.WebhookProperties.ANALYSIS_PROPERTY_PREFIX;
 public class ContextPropertiesPublisher implements ReportPublisherStep {
 
   private final ContextPropertiesCache cache;
-  private final Settings settings;
+  private final DefaultConfiguration config;
 
-  public ContextPropertiesPublisher(ContextPropertiesCache cache, Settings settings) {
+  public ContextPropertiesPublisher(ContextPropertiesCache cache, DefaultConfiguration config) {
     this.cache = cache;
-    this.settings = settings;
+    this.config = config;
   }
 
   @Override
@@ -51,7 +50,7 @@ public class ContextPropertiesPublisher implements ReportPublisherStep {
 
     // properties that are automatically included to report so that
     // they can be included to webhook payloads
-    Stream<ScannerReport.ContextProperty> fromSettings = settings.getProperties().entrySet().stream()
+    Stream<ScannerReport.ContextProperty> fromSettings = config.getProperties().entrySet().stream()
       .filter(e -> e.getKey().startsWith(ANALYSIS_PROPERTY_PREFIX))
       .map(transformer);
 
@@ -62,7 +61,7 @@ public class ContextPropertiesPublisher implements ReportPublisherStep {
     private final ScannerReport.ContextProperty.Builder builder = ScannerReport.ContextProperty.newBuilder();
 
     @Override
-    public ScannerReport.ContextProperty apply(@Nonnull  Map.Entry<String, String> input) {
+    public ScannerReport.ContextProperty apply(@Nonnull Map.Entry<String, String> input) {
       return builder.clear().setKey(input.getKey()).setValue(input.getValue()).build();
     }
   }
index 63f0198425921abd80f48a8e78e154799167ce3d..9afa52f2ca82ec7dc62701d35981e10917d400a9 100644 (file)
@@ -23,7 +23,7 @@ import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.scanner.ProjectAnalysisInfo;
 import org.sonar.scanner.cpd.index.SonarCpdBlockIndex;
 import org.sonar.scanner.protocol.output.ScannerReport;
@@ -33,12 +33,12 @@ import org.sonar.scanner.rule.QProfile;
 
 public class MetadataPublisher implements ReportPublisherStep {
 
-  private final Settings settings;
+  private final Configuration settings;
   private final ModuleQProfiles qProfiles;
   private final ProjectAnalysisInfo projectAnalysisInfo;
   private final InputModuleHierarchy moduleHierarchy;
 
-  public MetadataPublisher(ProjectAnalysisInfo projectAnalysisInfo, InputModuleHierarchy moduleHierarchy, Settings settings, ModuleQProfiles qProfiles) {
+  public MetadataPublisher(ProjectAnalysisInfo projectAnalysisInfo, InputModuleHierarchy moduleHierarchy, Configuration settings, ModuleQProfiles qProfiles) {
     this.projectAnalysisInfo = projectAnalysisInfo;
     this.moduleHierarchy = moduleHierarchy;
     this.settings = settings;
@@ -56,10 +56,7 @@ public class MetadataPublisher implements ReportPublisherStep {
       .setCrossProjectDuplicationActivated(SonarCpdBlockIndex.isCrossProjectDuplicationEnabled(settings))
       .setRootComponentRef(rootProject.batchId());
 
-    String organization = settings.getString(CoreProperties.PROJECT_ORGANIZATION_PROPERTY);
-    if (organization != null) {
-      builder.setOrganizationKey(organization);
-    }
+    settings.get(CoreProperties.PROJECT_ORGANIZATION_PROPERTY).ifPresent(builder::setOrganizationKey);
 
     String branch = rootDef.getBranch();
     if (branch != null) {
index bb38c3ea6e0bd3d49eea01227927d7faef63f18c..487c48cd4e5fce6f46926f7289e64ec686cf8e0e 100644 (file)
@@ -38,7 +38,7 @@ import org.picocontainer.Startable;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.platform.Server;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.TempFolder;
@@ -66,7 +66,7 @@ public class ReportPublisher implements Startable {
   public static final String VERBOSE_KEY = "sonar.verbose";
   public static final String METADATA_DUMP_FILENAME = "report-task.txt";
 
-  private final Settings settings;
+  private final Configuration settings;
   private final ScannerWsClient wsClient;
   private final AnalysisContextReportPublisher contextPublisher;
   private final ImmutableProjectReactor projectReactor;
@@ -78,7 +78,7 @@ public class ReportPublisher implements Startable {
   private File reportDir;
   private ScannerReportWriter writer;
 
-  public ReportPublisher(Settings settings, ScannerWsClient wsClient, Server server, AnalysisContextReportPublisher contextPublisher,
+  public ReportPublisher(Configuration settings, ScannerWsClient wsClient, Server server, AnalysisContextReportPublisher contextPublisher,
     ImmutableProjectReactor projectReactor, DefaultAnalysisMode analysisMode, TempFolder temp, ReportPublisherStep[] publishers) {
     this.settings = settings;
     this.wsClient = wsClient;
@@ -135,7 +135,7 @@ public class ReportPublisher implements Startable {
   }
 
   private boolean shouldKeepReport() {
-    return settings.getBoolean(KEEP_REPORT_PROP_KEY) || settings.getBoolean(VERBOSE_KEY);
+    return settings.getBoolean(KEEP_REPORT_PROP_KEY).orElse(false) || settings.getBoolean(VERBOSE_KEY).orElse(false);
   }
 
   private File generateReportFile() {
@@ -169,7 +169,7 @@ public class ReportPublisher implements Startable {
     PostRequest.Part filePart = new PostRequest.Part(MediaTypes.ZIP, report);
     PostRequest post = new PostRequest("api/ce/submit")
       .setMediaType(MediaTypes.PROTOBUF)
-      .setParam("organization", settings.getString(CoreProperties.PROJECT_ORGANIZATION_PROPERTY))
+      .setParam("organization", settings.get(CoreProperties.PROJECT_ORGANIZATION_PROPERTY).orElse(null))
       .setParam("projectKey", projectDefinition.getKey())
       .setParam("projectName", projectDefinition.getOriginalName())
       .setParam("projectBranch", projectDefinition.getBranch())
@@ -202,9 +202,7 @@ public class ReportPublisher implements Startable {
 
       Map<String, String> metadata = new LinkedHashMap<>();
       String effectiveKey = projectReactor.getRoot().getKeyWithBranch();
-      if (settings.hasKey(CoreProperties.PROJECT_ORGANIZATION_PROPERTY)) {
-        metadata.put("organization", settings.getString(CoreProperties.PROJECT_ORGANIZATION_PROPERTY));
-      }
+      settings.get(CoreProperties.PROJECT_ORGANIZATION_PROPERTY).ifPresent(org -> metadata.put("organization", org));
       metadata.put("projectKey", effectiveKey);
       metadata.put("serverUrl", publicUrl);
       metadata.put("serverVersion", server.getVersion());
index b549f34ea678b8a4920ceb658bb918b79fd18a6c..43411c011c0c901789006e7a11fb156dc99d251a 100644 (file)
@@ -23,7 +23,6 @@ import com.google.common.collect.Iterables;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.stream.StreamSupport;
-
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.fs.internal.DefaultInputComponent;
 import org.sonar.api.test.CoverageBlock;
@@ -36,8 +35,8 @@ import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReport.CoverageDetail;
 import org.sonar.scanner.protocol.output.ScannerReport.Test;
 import org.sonar.scanner.protocol.output.ScannerReport.Test.TestStatus;
-import org.sonar.scanner.scan.filesystem.InputComponentStore;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
+import org.sonar.scanner.scan.filesystem.InputComponentStore;
 
 import static java.util.stream.Collectors.toList;
 
index 92fced49ea236ff21682ade8d62a8aab17a68b13..eb86e53237a82515f7be148f9eaf3c8eb6c3bab6 100644 (file)
@@ -29,7 +29,8 @@ import java.util.Optional;
 import java.util.function.BinaryOperator;
 import javax.annotation.Nullable;
 import org.apache.commons.io.IOUtils;
-import org.sonar.api.config.Settings;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.MessageException;
 import org.sonar.scanner.bootstrap.ScannerWsClient;
 import org.sonarqube.ws.QualityProfiles.SearchWsResponse;
@@ -43,10 +44,10 @@ import static org.sonar.scanner.util.ScannerUtils.encodeForUrl;
 public class DefaultQualityProfileLoader implements QualityProfileLoader {
   private static final String WS_URL = "/api/qualityprofiles/search.protobuf";
 
-  private final Settings settings;
+  private final Configuration settings;
   private final ScannerWsClient wsClient;
 
-  public DefaultQualityProfileLoader(Settings settings, ScannerWsClient wsClient) {
+  public DefaultQualityProfileLoader(Configuration settings, ScannerWsClient wsClient) {
     this.settings = settings;
     this.wsClient = wsClient;
   }
@@ -81,7 +82,7 @@ public class DefaultQualityProfileLoader implements QualityProfileLoader {
   }
 
   private Optional<String> getOrganizationKey() {
-    return Optional.ofNullable(settings.getString("sonar.organization"));
+    return settings.get(CoreProperties.PROJECT_ORGANIZATION_PROPERTY);
   }
 
   private Map<String, QualityProfile> call(String url) {
index adb696b079f512eed977c95f196003de3578d9c7..fa52178accd67914e758db2c6744d9e4cb6a34a8 100644 (file)
  */
 package org.sonar.scanner.repository;
 
-import org.sonar.api.utils.log.Profiler;
-import org.sonar.scanner.analysis.DefaultAnalysisMode;
+import org.picocontainer.injectors.ProviderAdapter;
 import org.sonar.api.batch.bootstrap.ProjectKey;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
-import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.utils.log.Profiler;
+import org.sonar.scanner.analysis.DefaultAnalysisMode;
 
 public class ProjectRepositoriesProvider extends ProviderAdapter {
   private static final Logger LOG = Loggers.get(ProjectRepositoriesProvider.class);
index 8e0eba0eb7fb4347602429581f37e844732be3c5..96394c57c419d737b12d4e22bb932f0dacbd1007 100644 (file)
  */
 package org.sonar.scanner.repository;
 
-import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile;
-
-import javax.annotation.Nullable;
-
 import java.util.List;
+import javax.annotation.Nullable;
+import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile;
 
 public interface QualityProfileLoader {
   List<QualityProfile> load(String projectKey, @Nullable String profileName);
index 1850a3b95fc105458e1f0fe30a99b826cfe57982..4af9e6a6e740ef7b1c627868403bc9d2e47aa911 100644 (file)
  */
 package org.sonar.scanner.repository.language;
 
-import org.picocontainer.Startable;
-
-import org.sonar.api.resources.Languages;
-
-import javax.annotation.CheckForNull;
-
 import java.util.ArrayList;
 import java.util.Collection;
+import javax.annotation.CheckForNull;
+import org.picocontainer.Startable;
+import org.sonar.api.resources.Languages;
 
 /**
  * Languages repository using {@link Languages}
index e7bbfa79fc99bfa13f2e3e750b3600b41ebbfa9e..626a3361f8fd8ae1ad333e0c870900f47ab5be1e 100644 (file)
  */
 package org.sonar.scanner.repository.language;
 
-import org.sonar.api.batch.ScannerSide;
-
-import javax.annotation.CheckForNull;
-
 import java.util.Collection;
+import javax.annotation.CheckForNull;
+import org.sonar.api.batch.ScannerSide;
 
 /**
  * Languages repository
index cec04cc2242672d84191da69e85e65e75714b740..4a3d7a3673e451dd25c9837113a74c44197aa1c8 100644 (file)
  */
 package org.sonar.scanner.rule;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
 import org.apache.commons.io.IOUtils;
 import org.sonar.scanner.bootstrap.ScannerWsClient;
+import org.sonarqube.ws.Rules.ListResponse;
 import org.sonarqube.ws.Rules.ListResponse.Rule;
 import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.Rules.ListResponse;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
 
 public class DefaultRulesLoader implements RulesLoader {
   private static final String RULES_SEARCH_URL = "/api/rules/list.protobuf";
index ec541c56c9724d59e611942938f430c0a265c7e0..013e22e352e94a741bb12ec4388d487b1f579d0f 100644 (file)
  */
 package org.sonar.scanner.rule;
 
-import org.sonar.api.utils.DateUtils;
-
-import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile;
-import org.sonar.api.batch.ScannerSide;
-
-import javax.annotation.CheckForNull;
-
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import javax.annotation.CheckForNull;
+import org.sonar.api.batch.ScannerSide;
+import org.sonar.api.utils.DateUtils;
+import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile;
 
 /**
  * Lists the Quality profiles enabled on the current module.
index 3f1dcf705e22b765ebec2910717e961815f39d5a..a38f942b9291baeb3884a583b820d8104ba3ded1 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.rule;
 
 import com.google.common.base.MoreObjects;
-
 import java.util.Date;
 
 public class QProfile {
index 91fbae0a5779dfb3e284bec3ccc39171269b7d7f..b3a309228e1fd3a70a2b3c325f515ccf92f6241a 100644 (file)
@@ -25,7 +25,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.MessageException;
 
 import static org.apache.commons.lang.StringUtils.isNotEmpty;
@@ -35,11 +35,11 @@ public class QProfileVerifier {
 
   private static final Logger LOG = LoggerFactory.getLogger(QProfileVerifier.class);
 
-  private final Settings settings;
+  private final Configuration settings;
   private final FileSystem fs;
   private final ModuleQProfiles profiles;
 
-  public QProfileVerifier(Settings settings, FileSystem fs, ModuleQProfiles profiles) {
+  public QProfileVerifier(Configuration settings, FileSystem fs, ModuleQProfiles profiles) {
     this.settings = settings;
     this.fs = fs;
     this.profiles = profiles;
@@ -51,7 +51,7 @@ public class QProfileVerifier {
 
   @VisibleForTesting
   void execute(Logger logger) {
-    String defaultName = settings.getString(ModuleQProfiles.SONAR_PROFILE_PROP);
+    String defaultName = settings.get(ModuleQProfiles.SONAR_PROFILE_PROP).orElse(null);
     boolean defaultNameUsed = StringUtils.isBlank(defaultName);
     for (String lang : fs.languages()) {
       QProfile profile = profiles.findByLanguage(lang);
index 185b98d76e58a91f233affcd2741a2a920930668..bd3d822bdec8b88de7528a5799064325fda6a729 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.stream.Collectors;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.apache.commons.lang.builder.ReflectionToStringBuilder;
index b5fc765c0ccd4a9ba85593b130673d98df6a9f85..fdf35103ce8393268a2b071db19add6c64cee601 100644 (file)
@@ -26,7 +26,7 @@ import org.apache.commons.lang.StringUtils;
 import org.picocontainer.injectors.ProviderAdapter;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.rule.ActiveRules;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.profiles.RulesProfile;
 import org.sonar.api.rules.ActiveRule;
 import org.sonar.api.rules.Rule;
@@ -39,9 +39,9 @@ public class RulesProfileProvider extends ProviderAdapter {
 
   private RulesProfile singleton = null;
 
-  public RulesProfile provide(ModuleQProfiles qProfiles, ActiveRules activeRules, Settings settings) {
+  public RulesProfile provide(ModuleQProfiles qProfiles, ActiveRules activeRules, Configuration settings) {
     if (singleton == null) {
-      String lang = settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY);
+      String lang = settings.get(CoreProperties.PROJECT_LANGUAGE_PROPERTY).orElse(null);
       if (StringUtils.isNotBlank(lang)) {
         // Backward-compatibility with single-language modules
         singleton = loadSingleLanguageProfile(qProfiles, activeRules, lang);
index 0893c2447cc009fde1535d84a11b8964b229014a..6ef87f1844289726e4f5cd4e79125d21206a7975 100644 (file)
  */
 package org.sonar.scanner.rule;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.profiles.RulesProfile;
@@ -26,11 +30,6 @@ import org.sonar.api.rules.ActiveRule;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.utils.SonarException;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
 /**
  * This wrapper is used to try to preserve backward compatibility for plugins that used to
  * depends on {@link org.sonar.api.profiles.RulesProfile}
index 9fe5a93f633a269b0db08cd3985dd57d296eec18..69fbaa4c19ab5c7009626387e4c4b01ce243968e 100644 (file)
  */
 package org.sonar.scanner.rule;
 
+import java.util.List;
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.batch.rule.Rules;
+import org.sonar.api.batch.rule.internal.NewRule;
+import org.sonar.api.batch.rule.internal.RulesBuilder;
+import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.api.utils.log.Profiler;
-
-import java.util.List;
-
 import org.sonarqube.ws.Rules.ListResponse.Rule;
-import org.picocontainer.injectors.ProviderAdapter;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.batch.rule.internal.RulesBuilder;
-import org.sonar.api.batch.rule.internal.NewRule;
-import org.sonar.api.batch.rule.Rules;
 
 public class RulesProvider extends ProviderAdapter {
   private static final Logger LOG = Loggers.get(RulesProvider.class);
index 5275352b9c530cebf61c74de36d9bb95397d3cd7..ae7f1de06ec2dc33da30ef8516cab455d29d8f04 100644 (file)
  */
 package org.sonar.scanner.scan;
 
+import com.google.common.base.Preconditions;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
 import java.nio.file.Path;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.annotation.CheckForNull;
-
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.fs.InputModule;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
 import org.sonar.api.scan.filesystem.PathResolver;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-
 public class DefaultInputModuleHierarchy implements InputModuleHierarchy {
   private final PathResolver pathResolver = new PathResolver();
   private DefaultInputModule root;
index b7ba4b5cf0bbfc0d6e6e6eb666f02b6112ec9fc6..8305472e8aa4b57e1adc16eaad5cb5a69ec121a6 100644 (file)
@@ -30,9 +30,9 @@ import org.sonar.api.resources.Project;
 import org.sonar.api.scan.filesystem.FileExclusions;
 import org.sonar.core.platform.ComponentContainer;
 import org.sonar.scanner.DefaultFileLinesContextFactory;
-import org.sonar.scanner.bootstrap.ScannerExtensionDictionnary;
 import org.sonar.scanner.bootstrap.ExtensionInstaller;
 import org.sonar.scanner.bootstrap.ExtensionUtils;
+import org.sonar.scanner.bootstrap.ScannerExtensionDictionnary;
 import org.sonar.scanner.deprecated.DeprecatedSensorContext;
 import org.sonar.scanner.deprecated.perspectives.ScannerPerspectives;
 import org.sonar.scanner.events.EventBus;
@@ -97,7 +97,8 @@ public class ModuleScanContainer extends ComponentContainer {
       // still injected by some plugins
       new Project(module.definition()),
       module,
-      ModuleSettings.class);
+      MutableModuleSettings.class,
+      new ModuleSettingsProvider());
 
     if (getComponentByType(AnalysisMode.class).isIssues()) {
       add(IssuesPhaseExecutor.class,
index 28c25f406574cc5c432cdba2919350d42f4a1715..a2a4c0b90b09d15d5fa51f72804503059e83cc62 100644 (file)
  */
 package org.sonar.scanner.scan;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-import java.util.Optional;
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.config.Settings;
-import org.sonar.api.utils.MessageException;
-import org.sonar.scanner.analysis.DefaultAnalysisMode;
-import org.sonar.scanner.bootstrap.GlobalSettings;
-import org.sonar.scanner.report.AnalysisContextReportPublisher;
-import org.sonar.scanner.repository.ProjectRepositories;
+import org.sonar.api.batch.AnalysisMode;
+import org.sonar.api.config.Encryption;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.scanner.config.DefaultConfiguration;
 
-/**
- * @since 2.12
- */
-public class ModuleSettings extends Settings {
-
-  private final ProjectRepositories projectRepos;
-  private final DefaultAnalysisMode analysisMode;
-  private final Map<String, String> properties = new HashMap<>();
-
-  public ModuleSettings(GlobalSettings batchSettings, ProjectDefinition moduleDefinition, ProjectRepositories projectSettingsRepo,
-    DefaultAnalysisMode analysisMode, AnalysisContextReportPublisher contextReportPublisher) {
-    super(batchSettings.getDefinitions(), batchSettings.getEncryption());
-    this.projectRepos = projectSettingsRepo;
-    this.analysisMode = analysisMode;
-
-    init(moduleDefinition, batchSettings);
-    contextReportPublisher.dumpModuleSettings(moduleDefinition);
-  }
-
-  private ModuleSettings init(ProjectDefinition moduleDefinition, GlobalSettings batchSettings) {
-    addProjectProperties(moduleDefinition, batchSettings);
-    addBuildProperties(moduleDefinition);
-    return this;
-  }
-
-  private void addProjectProperties(ProjectDefinition def, GlobalSettings batchSettings) {
-    addProperties(batchSettings.getProperties());
-    do {
-      if (projectRepos.moduleExists(def.getKeyWithBranch())) {
-        addProperties(projectRepos.settings(def.getKeyWithBranch()));
-        break;
-      }
-      def = def.getParent();
-    } while (def != null);
-  }
+public class ModuleSettings extends DefaultConfiguration {
 
-  private void addBuildProperties(ProjectDefinition project) {
-    List<ProjectDefinition> orderedProjects = getTopDownParentProjects(project);
-    for (ProjectDefinition p : orderedProjects) {
-      addProperties(p.properties());
-    }
+  public ModuleSettings(PropertyDefinitions propertyDefinitions, Encryption encryption, AnalysisMode mode, Map<String, String> props) {
+    super(propertyDefinitions, encryption, mode, props);
   }
 
-  /**
-   * From root to given project
-   */
-  static List<ProjectDefinition> getTopDownParentProjects(ProjectDefinition project) {
-    List<ProjectDefinition> result = new ArrayList<>();
-    ProjectDefinition p = project;
-    while (p != null) {
-      result.add(0, p);
-      p = p.getParent();
-    }
-    return result;
-  }
-
-  @Override
-  protected Optional<String> get(String key) {
-    if (analysisMode.isIssues() && key.endsWith(".secured") && !key.contains(".license")) {
-      throw MessageException.of("Access to the secured property '" + key
-        + "' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
-    }
-    return Optional.ofNullable(properties.get(key));
-  }
-
-  @Override
-  protected void set(String key, String value) {
-    properties.put(key, value);
-  }
-
-  @Override
-  protected void remove(String key) {
-    properties.remove(key);
-  }
-
-  @Override
-  public Map<String, String> getProperties() {
-    return properties;
-  }
 }
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettingsProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettingsProvider.java
new file mode 100644 (file)
index 0000000..7fd4d6a
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.scan;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.batch.AnalysisMode;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.scanner.bootstrap.GlobalConfiguration;
+import org.sonar.scanner.report.AnalysisContextReportPublisher;
+import org.sonar.scanner.repository.ProjectRepositories;
+
+public class ModuleSettingsProvider extends ProviderAdapter {
+
+  private ModuleSettings projectSettings;
+
+  public ModuleSettings provide(GlobalConfiguration globalSettings, ProjectDefinition moduleDefinition, ProjectRepositories projectRepos,
+    AnalysisMode analysisMode, AnalysisContextReportPublisher contextReportPublisher) {
+    if (projectSettings == null) {
+
+      Map<String, String> settings = new LinkedHashMap<>();
+      settings.putAll(globalSettings.getProperties());
+      settings.putAll(addServerSidePropertiesIfModuleExists(projectRepos, moduleDefinition));
+      addScannerSideProperties(settings, moduleDefinition);
+      contextReportPublisher.dumpModuleSettings(moduleDefinition);
+
+      projectSettings = new ModuleSettings(globalSettings.getDefinitions(), globalSettings.getEncryption(), analysisMode, settings);
+    }
+    return projectSettings;
+  }
+
+  private Map<String, String> addServerSidePropertiesIfModuleExists(ProjectRepositories projectRepos, ProjectDefinition def) {
+    if (projectRepos.moduleExists(def.getKeyWithBranch())) {
+      return projectRepos.settings(def.getKeyWithBranch());
+    } else {
+      // Module doesn't exist on server. Try to add parent server settings as inheritance.
+      ProjectDefinition parentDef = def.getParent();
+      if (parentDef != null) {
+        return addServerSidePropertiesIfModuleExists(projectRepos, parentDef);
+      }
+      return Collections.emptyMap();
+    }
+  }
+
+  private void addScannerSideProperties(Map<String, String> settings, ProjectDefinition project) {
+    List<ProjectDefinition> orderedProjects = getTopDownParentProjects(project);
+    for (ProjectDefinition p : orderedProjects) {
+      settings.putAll(p.properties());
+    }
+  }
+
+  /**
+   * From root to given project
+   */
+  static List<ProjectDefinition> getTopDownParentProjects(ProjectDefinition project) {
+    List<ProjectDefinition> result = new ArrayList<>();
+    ProjectDefinition p = project;
+    while (p != null) {
+      result.add(0, p);
+      p = p.getParent();
+    }
+    return result;
+  }
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java
new file mode 100644 (file)
index 0000000..8ae1bfb
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.scan;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.config.Settings;
+import org.sonar.api.utils.MessageException;
+import org.sonar.scanner.analysis.DefaultAnalysisMode;
+import org.sonar.scanner.bootstrap.MutableGlobalSettings;
+import org.sonar.scanner.repository.ProjectRepositories;
+
+/**
+ * @deprecated since 6.5 {@link ModuleSettings} used to be mutable, so keep a mutable copy for backward compatibility.
+ */
+@Deprecated
+public class MutableModuleSettings extends Settings {
+
+  private final ProjectRepositories projectRepos;
+  private final DefaultAnalysisMode analysisMode;
+  private final Map<String, String> properties = new HashMap<>();
+
+  public MutableModuleSettings(MutableGlobalSettings batchSettings, ProjectDefinition moduleDefinition, ProjectRepositories projectSettingsRepo,
+    DefaultAnalysisMode analysisMode) {
+    super(batchSettings.getDefinitions(), batchSettings.getEncryption());
+    this.projectRepos = projectSettingsRepo;
+    this.analysisMode = analysisMode;
+
+    init(moduleDefinition, batchSettings);
+  }
+
+  private MutableModuleSettings init(ProjectDefinition moduleDefinition, MutableGlobalSettings batchSettings) {
+    addProjectProperties(moduleDefinition, batchSettings);
+    addBuildProperties(moduleDefinition);
+    return this;
+  }
+
+  private void addProjectProperties(ProjectDefinition def, MutableGlobalSettings batchSettings) {
+    addProperties(batchSettings.getProperties());
+    do {
+      if (projectRepos.moduleExists(def.getKeyWithBranch())) {
+        addProperties(projectRepos.settings(def.getKeyWithBranch()));
+        break;
+      }
+      def = def.getParent();
+    } while (def != null);
+  }
+
+  private void addBuildProperties(ProjectDefinition project) {
+    List<ProjectDefinition> orderedProjects = getTopDownParentProjects(project);
+    for (ProjectDefinition p : orderedProjects) {
+      addProperties(p.properties());
+    }
+  }
+
+  /**
+   * From root to given project
+   */
+  static List<ProjectDefinition> getTopDownParentProjects(ProjectDefinition project) {
+    List<ProjectDefinition> result = new ArrayList<>();
+    ProjectDefinition p = project;
+    while (p != null) {
+      result.add(0, p);
+      p = p.getParent();
+    }
+    return result;
+  }
+
+  @Override
+  protected Optional<String> get(String key) {
+    if (analysisMode.isIssues() && key.endsWith(".secured") && !key.contains(".license")) {
+      throw MessageException.of("Access to the secured property '" + key
+        + "' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
+    }
+    return Optional.ofNullable(properties.get(key));
+  }
+
+  @Override
+  protected void set(String key, String value) {
+    properties.put(key, value);
+  }
+
+  @Override
+  protected void remove(String key) {
+    properties.remove(key);
+  }
+
+  @Override
+  public Map<String, String> getProperties() {
+    return properties;
+  }
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java
new file mode 100644 (file)
index 0000000..8f0fb5e
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.scan;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.config.Settings;
+import org.sonar.api.utils.MessageException;
+import org.sonar.scanner.analysis.DefaultAnalysisMode;
+import org.sonar.scanner.bootstrap.MutableGlobalSettings;
+import org.sonar.scanner.repository.ProjectRepositories;
+
+/**
+ * @deprecated since 6.5 {@link ProjectSettings} used to be mutable, so keep a mutable copy for backward compatibility.
+ */
+@Deprecated
+public class MutableProjectSettings extends Settings {
+
+  private final DefaultAnalysisMode mode;
+  private final Map<String, String> properties = new HashMap<>();
+
+  public MutableProjectSettings(ProjectReactor reactor, MutableGlobalSettings mutableGlobalSettings, ProjectRepositories projectRepositories, DefaultAnalysisMode mode) {
+    super(mutableGlobalSettings.getDefinitions(), mutableGlobalSettings.getEncryption());
+    this.mode = mode;
+    addProperties(mutableGlobalSettings.getProperties());
+    addProperties(projectRepositories.settings(reactor.getRoot().getKeyWithBranch()));
+    addProperties(reactor.getRoot().properties());
+  }
+
+  @Override
+  protected Optional<String> get(String key) {
+    if (mode.isIssues() && key.endsWith(".secured") && !key.contains(".license")) {
+      throw MessageException.of("Access to the secured property '" + key
+        + "' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
+    }
+    return Optional.ofNullable(properties.get(key));
+  }
+
+  @Override
+  protected void set(String key, String value) {
+    properties.put(key, value);
+  }
+
+  @Override
+  protected void remove(String key) {
+    properties.remove(key);
+  }
+
+  @Override
+  public Map<String, String> getProperties() {
+    return properties;
+  }
+}
index a2a321a5c3684751f62f5af2e5a93f086c0dfde2..53ed950330e91b707b14ec036b7d5390dd24a79a 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.scan;
 
 import java.lang.reflect.Method;
-
 import org.sonar.api.batch.bootstrap.ProjectBuilder;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext;
index e1f6e77e384bd39e90bd011dd5791617779b0e77..bddf206cc599d88ab7e0efbf241bfcea5056ab7f 100644 (file)
  */
 package org.sonar.scanner.scan;
 
-import org.sonar.home.cache.DirectoryLock;
-import org.sonar.scanner.bootstrap.Slf4jLogger;
-import org.picocontainer.Startable;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-
 import java.io.IOException;
 import java.nio.channels.OverlappingFileLockException;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import org.picocontainer.Startable;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.home.cache.DirectoryLock;
+import org.sonar.scanner.bootstrap.Slf4jLogger;
 
 public class ProjectLock implements Startable {
   private final DirectoryLock lock;
index 48aae076fa877c94b76e132bb0e4b1237c4958cb..f5f9d0886e7bd2c849bebb96744dc72b312ab89b 100644 (file)
  */
 package org.sonar.scanner.scan;
 
-import org.sonar.api.utils.MessageException;
 import com.google.common.base.Joiner;
-
 import java.util.ArrayList;
 import java.util.List;
-
 import javax.annotation.Nullable;
-
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.config.Settings;
+import org.sonar.api.utils.MessageException;
 import org.sonar.core.component.ComponentKeys;
 import org.sonar.scanner.analysis.DefaultAnalysisMode;
 
index b3a9fb68c21c47b16e508d0c3fd27be5757ba892..9720666b11342588748cf92245e043592c7e94d9 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.scan;
 
 import com.google.common.annotations.VisibleForTesting;
-
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.InstantiationStrategy;
@@ -181,7 +180,8 @@ public class ProjectScanContainer extends ComponentContainer {
       ContextPropertiesCache.class,
       ContextPropertiesPublisher.class,
 
-      ProjectSettings.class,
+      MutableProjectSettings.class,
+      new ProjectSettingsProvider(),
 
       // Report
       ScannerMetrics.class,
index 65eda80b5b0d8bdb617c610095d9c0bc21dcf8f8..a25dc51ad43d96e40a46a6a374842b5242365ce8 100644 (file)
  */
 package org.sonar.scanner.scan;
 
-import java.util.HashMap;
 import java.util.Map;
-import java.util.Optional;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.api.config.Settings;
-import org.sonar.api.utils.MessageException;
-import org.sonar.scanner.analysis.DefaultAnalysisMode;
-import org.sonar.scanner.bootstrap.GlobalSettings;
-import org.sonar.scanner.repository.ProjectRepositories;
+import org.sonar.api.batch.AnalysisMode;
+import org.sonar.api.config.Encryption;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.scanner.config.DefaultConfiguration;
 
-public class ProjectSettings extends Settings {
+public class ProjectSettings extends DefaultConfiguration {
 
-  private final GlobalSettings globalSettings;
-  private final ProjectRepositories projectRepositories;
-  private final DefaultAnalysisMode mode;
-  private final Map<String, String> properties = new HashMap<>();
-
-  public ProjectSettings(ProjectReactor reactor, GlobalSettings globalSettings, ProjectRepositories projectRepositories, DefaultAnalysisMode mode) {
-    super(globalSettings.getDefinitions(), globalSettings.getEncryption());
-    this.mode = mode;
-    this.globalSettings = globalSettings;
-    this.projectRepositories = projectRepositories;
-    init(reactor);
-  }
-
-  private void init(ProjectReactor reactor) {
-    addProperties(globalSettings.getProperties());
-
-    addProperties(projectRepositories.settings(reactor.getRoot().getKeyWithBranch()));
-
-    addProperties(reactor.getRoot().properties());
-  }
-
-  @Override
-  protected Optional<String> get(String key) {
-    if (mode.isIssues() && key.endsWith(".secured") && !key.contains(".license")) {
-      throw MessageException.of("Access to the secured property '" + key
-        + "' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
-    }
-    return Optional.ofNullable(properties.get(key));
-  }
-
-  @Override
-  protected void set(String key, String value) {
-    properties.put(key, value);
+  public ProjectSettings(PropertyDefinitions propertyDefinitions, Encryption encryption, AnalysisMode mode, Map<String, String> props) {
+    super(propertyDefinitions, encryption, mode, props);
   }
 
-  @Override
-  protected void remove(String key) {
-    properties.remove(key);
-  }
-
-  @Override
-  public Map<String, String> getProperties() {
-    return properties;
-  }
 }
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettingsProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettingsProvider.java
new file mode 100644 (file)
index 0000000..ec167a3
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.scan;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.batch.AnalysisMode;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.scanner.bootstrap.GlobalConfiguration;
+import org.sonar.scanner.repository.ProjectRepositories;
+
+public class ProjectSettingsProvider extends ProviderAdapter {
+
+  private ProjectSettings projectSettings;
+
+  public ProjectSettings provide(ProjectReactor reactor, GlobalConfiguration globalSettings, ProjectRepositories projectRepositories, AnalysisMode mode) {
+    if (projectSettings == null) {
+
+      Map<String, String> settings = new LinkedHashMap<>();
+      settings.putAll(globalSettings.getProperties());
+      settings.putAll(projectRepositories.settings(reactor.getRoot().getKeyWithBranch()));
+      settings.putAll(reactor.getRoot().properties());
+
+      projectSettings = new ProjectSettings(globalSettings.getDefinitions(), globalSettings.getEncryption(), mode, settings);
+    }
+    return projectSettings;
+  }
+}
index 98dd1d4d77cf2a9afc70bd69267f36cf35c5c040..607b7bb0397c6c0cf5a43f798f1b010fcb9d804e 100644 (file)
  */
 package org.sonar.scanner.scan;
 
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.core.util.FileUtils;
-import org.sonar.home.cache.DirectoryLock;
-
 import java.io.IOException;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Iterator;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.core.util.FileUtils;
+import org.sonar.home.cache.DirectoryLock;
 
 public class WorkDirectoryCleaner {
   private Path workDir;
index a4142618dbec689f27cf598f10865f119971c0c8..087f8445ad32c2d9a2bf1917bf94095310b94979 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.scanner.scan.filesystem;
 
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Supplier;
-
 import org.sonar.api.batch.fs.InputComponent;
 
 /**
index 6295e44ec62b6aa24b2f84f2a5442fcb52d8eac2..5dd2657521b011c3a5c422c23e70f74d13b4b867 100644 (file)
  */
 package org.sonar.scanner.scan.filesystem;
 
-import static java.nio.charset.StandardCharsets.UTF_16;
-import static java.nio.charset.StandardCharsets.UTF_16LE;
-import static java.nio.charset.StandardCharsets.UTF_16BE;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
 import java.nio.charset.Charset;
 import java.util.Arrays;
-
 import javax.annotation.CheckForNull;
-
 import org.apache.commons.io.ByteOrderMark;
 import org.sonar.scanner.scan.filesystem.CharsetValidation.Result;
 import org.sonar.scanner.scan.filesystem.CharsetValidation.Validation;
 
+import static java.nio.charset.StandardCharsets.UTF_16;
+import static java.nio.charset.StandardCharsets.UTF_16BE;
+import static java.nio.charset.StandardCharsets.UTF_16LE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 public class ByteCharsetDetector {
   // these needs to be sorted by longer first!
   private static final ByteOrderMark[] boms = {ByteOrderMark.UTF_8, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE,
index a2eb629c1a7a8a70c5df39ab343ad58ce27ea8b2..e579f5c47f22fd78553682b4a07a47c722b37c35 100644 (file)
@@ -26,9 +26,7 @@ import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Arrays;
-
 import javax.annotation.CheckForNull;
-
 import org.apache.commons.io.ByteOrderMark;
 import org.apache.commons.io.IOUtils;
 
index 43a52aa4de24b3c2a5b485089e0d337f6cbb5ab3..e01e5202401a8c364adb141fef0536a6207247af 100644 (file)
@@ -28,7 +28,7 @@ import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.fs.internal.DefaultFileSystem;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.MessageException;
 import org.sonar.scanner.analysis.DefaultAnalysisMode;
 import org.sonar.scanner.repository.ProjectRepositories;
@@ -40,7 +40,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem {
 
   private String moduleKey;
   private FileIndexer indexer;
-  private Settings settings;
+  private Configuration settings;
 
   private List<File> sourceDirsOrFiles = new ArrayList<>();
   private List<File> testDirsOrFiles = new ArrayList<>();
@@ -48,7 +48,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem {
   private Charset charset = null;
 
   public DefaultModuleFileSystem(ModuleInputComponentStore moduleInputFileCache, DefaultInputModule module,
-    Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, DefaultAnalysisMode mode,
+    Configuration settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, DefaultAnalysisMode mode,
     ProjectRepositories projectRepositories) {
     super(initializer.baseDir(), moduleInputFileCache);
     setFields(module, settings, indexer, initializer, mode, projectRepositories);
@@ -56,14 +56,14 @@ public class DefaultModuleFileSystem extends DefaultFileSystem {
 
   @VisibleForTesting
   public DefaultModuleFileSystem(DefaultInputModule module,
-    Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, DefaultAnalysisMode mode,
+    Configuration settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, DefaultAnalysisMode mode,
     ProjectRepositories projectRepositories) {
     super(initializer.baseDir().toPath());
     setFields(module, settings, indexer, initializer, mode, projectRepositories);
   }
 
   private void setFields(DefaultInputModule module,
-    Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, DefaultAnalysisMode mode,
+    Configuration settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, DefaultAnalysisMode mode,
     ProjectRepositories projectRepositories) {
     this.moduleKey = module.key();
     this.settings = settings;
@@ -97,7 +97,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem {
   @Override
   public Charset encoding() {
     if (charset == null) {
-      String encoding = settings.getString(CoreProperties.ENCODING_PROPERTY);
+      String encoding = settings.get(CoreProperties.ENCODING_PROPERTY).orElse(null);
       if (StringUtils.isNotEmpty(encoding)) {
         charset = Charset.forName(StringUtils.trim(encoding));
       } else {
index dad23ab9a19e8ae90ff1a8a4da8a98a296deaac3..dd8a32e91e587dad442dad1c1dfc57bd2de6a2f8 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.scanner.scan.filesystem;
 
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.FileSystemLoopException;
@@ -40,24 +41,21 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.fs.IndexedFile;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.batch.fs.InputFileFilter;
 import org.sonar.api.batch.fs.internal.DefaultInputDir;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.scan.filesystem.PathResolver;
-import org.sonar.api.batch.fs.InputFileFilter;
 import org.sonar.api.utils.MessageException;
 import org.sonar.scanner.scan.DefaultComponentTree;
 import org.sonar.scanner.util.ProgressReport;
 
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
 /**
  * Index input files into {@link InputComponentStore}.
  */
index 8441b252ba629c69697bc3df4fade1ad2e505c2b..c44e24f4942fbf442055d8311ac7ae38b6e81d3a 100644 (file)
@@ -21,16 +21,14 @@ package org.sonar.scanner.scan.filesystem;
 
 import java.nio.charset.Charset;
 import java.nio.file.Path;
-
 import javax.annotation.CheckForNull;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultIndexedFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.scan.filesystem.PathResolver;
 
 public class InputFileBuilder {
@@ -45,14 +43,14 @@ public class InputFileBuilder {
   private final boolean preloadMetadata;
 
   public InputFileBuilder(DefaultInputModule module, PathResolver pathResolver, LanguageDetection langDetection, MetadataGenerator metadataGenerator,
-    BatchIdGenerator idGenerator, Settings settings) {
+    BatchIdGenerator idGenerator, Configuration settings) {
     this.moduleKey = module.key();
     this.moduleBaseDir = module.definition().getBaseDir().toPath();
     this.pathResolver = pathResolver;
     this.langDetection = langDetection;
     this.metadataGenerator = metadataGenerator;
     this.idGenerator = idGenerator;
-    this.preloadMetadata = settings.getBoolean(PRELOAD_FILE_METADATA_KEY);
+    this.preloadMetadata = settings.getBoolean(PRELOAD_FILE_METADATA_KEY).orElse(false);
   }
 
   @CheckForNull
index 404d50e98aa893829002b4d47781eb1becbe10db..828a8403655572096ff1906327b59417bf57ac76 100644 (file)
@@ -33,7 +33,7 @@ import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.fs.internal.DefaultIndexedFile;
 import org.sonar.api.batch.fs.internal.PathPattern;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.MessageException;
 import org.sonar.scanner.repository.language.Language;
 import org.sonar.scanner.repository.language.LanguagesRepository;
@@ -53,7 +53,7 @@ public class LanguageDetection {
   private final List<String> languagesToConsider = new ArrayList<>();
   private final String forcedLanguage;
 
-  public LanguageDetection(Settings settings, LanguagesRepository languages) {
+  public LanguageDetection(Configuration settings, LanguagesRepository languages) {
     for (Language language : languages.all()) {
       String[] filePatterns = settings.getStringArray(getFileLangPatternPropKey(language.key()));
       PathPattern[] pathPatterns = PathPattern.create(filePatterns);
@@ -73,7 +73,7 @@ public class LanguageDetection {
       }
     }
 
-    forcedLanguage = StringUtils.defaultIfBlank(settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY), null);
+    forcedLanguage = StringUtils.defaultIfBlank(settings.get(CoreProperties.PROJECT_LANGUAGE_PROPERTY).orElse(null), null);
     // First try with lang patterns
     if (forcedLanguage != null) {
       if (!patternsByLanguage.containsKey(forcedLanguage)) {
index 6c408522a09dd39890824863e4dcea1fb191eb88..f0bfe220d08ec6338b45cde8018b14d975c7f2f6 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.scanner.scan.filesystem;
 
+import com.google.common.annotations.VisibleForTesting;
 import java.io.InputStream;
 import java.nio.charset.Charset;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.fs.InputFile.Type;
@@ -31,8 +31,6 @@ import org.sonar.api.batch.fs.internal.FileMetadata;
 import org.sonar.api.batch.fs.internal.Metadata;
 import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader;
 
-import com.google.common.annotations.VisibleForTesting;
-
 class MetadataGenerator {
   private static final Logger LOG = LoggerFactory.getLogger(MetadataGenerator.class);
   @VisibleForTesting
index bf5206be7ad4bc0f87188daad7e04ff539d828bf..629a25161aa143c4de5a34108fbf9771f59d096a 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.scan.filesystem;
 
 import java.util.function.Predicate;
-
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 5c7c1c3d0552169dcf7543d27b3ce6796aee1ebd..f8c8b143853531b3956ff9e9dd5ebd3e54ee1a5c 100644 (file)
@@ -25,8 +25,8 @@ import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.measure.MetricFinder;
 import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
 import org.sonar.scanner.storage.Storage;
-import org.sonar.scanner.storage.Storages;
 import org.sonar.scanner.storage.Storage.Entry;
+import org.sonar.scanner.storage.Storages;
 
 /**
  * Cache of all measures. This cache is shared amongst all project modules.
index 37898424cd0828940c75661aaf5b1e2801d11cad..fcb9dcac21bb64f055b606ef79e36c26049376ea 100644 (file)
@@ -24,7 +24,7 @@ import org.apache.commons.lang.StringUtils;
 import org.sonar.api.Properties;
 import org.sonar.api.Property;
 import org.sonar.api.PropertyType;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
@@ -45,12 +45,12 @@ public class ConsoleReport implements Reporter {
   public static final String CONSOLE_REPORT_ENABLED_KEY = "sonar.issuesReport.console.enable";
   private static final int LEFT_PAD = 10;
 
-  private Settings settings;
+  private Configuration settings;
   private IssueCache issueCache;
   private InputComponentStore componentStore;
 
   @VisibleForTesting
-  public ConsoleReport(Settings settings, IssueCache issueCache, InputComponentStore componentStore) {
+  public ConsoleReport(Configuration settings, IssueCache issueCache, InputComponentStore componentStore) {
     this.settings = settings;
     this.issueCache = issueCache;
     this.componentStore = componentStore;
@@ -97,7 +97,7 @@ public class ConsoleReport implements Reporter {
 
   @Override
   public void execute() {
-    if (settings.getBoolean(CONSOLE_REPORT_ENABLED_KEY)) {
+    if (settings.getBoolean(CONSOLE_REPORT_ENABLED_KEY).orElse(false)) {
       LOG.warn("Console report is deprecated. Use SonarLint CLI to have local reports of issues");
       Report r = new Report();
       r.setNoFile(!componentStore.allFilesToPublish().iterator().hasNext());
index 4be0a7171088393f39bfe758e036e919e4b865d6..c3cd07a90fbf507711ffc6e88f8427da38271eaa 100644 (file)
@@ -38,7 +38,8 @@ import org.sonar.api.Properties;
 import org.sonar.api.Property;
 import org.sonar.api.PropertyType;
 import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
+import org.sonar.api.utils.MessageException;
 
 @Properties({
   @Property(key = HtmlReport.HTML_REPORT_ENABLED_KEY, defaultValue = "false", name = "Enable HTML report", description = "Set this to true to generate an HTML report",
@@ -59,13 +60,13 @@ public class HtmlReport implements Reporter {
   public static final String HTML_REPORT_NAME_DEFAULT = "issues-report";
   public static final String HTML_REPORT_LIGHTMODE_ONLY = "sonar.issuesReport.lightModeOnly";
 
-  private final Settings settings;
+  private final Configuration settings;
   private final FileSystem fs;
   private final IssuesReportBuilder builder;
   private final SourceProvider sourceProvider;
   private final RuleNameProvider ruleNameProvider;
 
-  public HtmlReport(Settings settings, FileSystem fs, IssuesReportBuilder builder, SourceProvider sourceProvider, RuleNameProvider ruleNameProvider) {
+  public HtmlReport(Configuration settings, FileSystem fs, IssuesReportBuilder builder, SourceProvider sourceProvider, RuleNameProvider ruleNameProvider) {
     this.settings = settings;
     this.fs = fs;
     this.builder = builder;
@@ -75,7 +76,7 @@ public class HtmlReport implements Reporter {
 
   @Override
   public void execute() {
-    if (settings.getBoolean(HTML_REPORT_ENABLED_KEY)) {
+    if (settings.getBoolean(HTML_REPORT_ENABLED_KEY).orElse(false)) {
       LOG.warn("HTML report is deprecated. Use SonarLint CLI to have local reports of issues");
       IssuesReport report = builder.buildReport();
       print(report);
@@ -84,7 +85,7 @@ public class HtmlReport implements Reporter {
 
   public void print(IssuesReport report) {
     File reportFileDir = getReportFileDir();
-    String reportName = settings.getString(HTML_REPORT_NAME_KEY);
+    String reportName = settings.get(HTML_REPORT_NAME_KEY).orElseThrow(() -> MessageException.of("Missing report name. Please set property '" + HTML_REPORT_NAME_KEY + "'"));
     if (!isLightModeOnly()) {
       File reportFile = new File(reportFileDir, reportName + ".html");
       LOG.debug("Generating HTML Report to: " + reportFile.getAbsolutePath());
@@ -103,7 +104,8 @@ public class HtmlReport implements Reporter {
   }
 
   private File getReportFileDir() {
-    String reportFileDirStr = settings.getString(HTML_REPORT_LOCATION_KEY);
+    String reportFileDirStr = settings.get(HTML_REPORT_LOCATION_KEY)
+      .orElseThrow(() -> MessageException.of("Missing report location. Please set property '" + HTML_REPORT_LOCATION_KEY + "'"));
     File reportFileDir = new File(reportFileDirStr);
     if (!reportFileDir.isAbsolute()) {
       reportFileDir = new File(fs.workDir(), reportFileDirStr);
@@ -174,6 +176,6 @@ public class HtmlReport implements Reporter {
   }
 
   public boolean isLightModeOnly() {
-    return settings.getBoolean(HTML_REPORT_LIGHTMODE_ONLY);
+    return settings.getBoolean(HTML_REPORT_LIGHTMODE_ONLY).orElse(false);
   }
 }
index 45224ef7dab32a90f2ca875f074d06b357727ec3..11143b41e718834699ba0c6ce32768e1d01de2af 100644 (file)
@@ -24,7 +24,6 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
-
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.rule.Rule;
 import org.sonar.api.rules.RulePriority;
index c7079a019ce00c071e4f874912c75ad67be520d6..1b821a22e7b6ca744df2a76d9c619e32f34e2f6e 100644 (file)
@@ -46,7 +46,7 @@ import org.sonar.api.batch.fs.internal.InputComponentTree;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
 import org.sonar.api.batch.rule.Rule;
 import org.sonar.api.batch.rule.Rules;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.platform.Server;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.text.JsonWriter;
@@ -65,7 +65,7 @@ public class JSONReport implements Reporter {
 
   static final String SONAR_REPORT_EXPORT_PATH = "sonar.report.export.path";
   private static final Logger LOG = LoggerFactory.getLogger(JSONReport.class);
-  private final Settings settings;
+  private final Configuration settings;
   private final FileSystem fileSystem;
   private final Server server;
   private final Rules rules;
@@ -75,7 +75,7 @@ public class JSONReport implements Reporter {
   private final InputModuleHierarchy moduleHierarchy;
   private final InputComponentTree inputComponentTree;
 
-  public JSONReport(InputModuleHierarchy moduleHierarchy, Settings settings, FileSystem fileSystem, Server server, Rules rules, IssueCache issueCache,
+  public JSONReport(InputModuleHierarchy moduleHierarchy, Configuration settings, FileSystem fileSystem, Server server, Rules rules, IssueCache issueCache,
     DefaultInputModule rootModule, InputComponentStore componentStore, InputComponentTree inputComponentTree) {
     this.moduleHierarchy = moduleHierarchy;
     this.settings = settings;
@@ -90,10 +90,7 @@ public class JSONReport implements Reporter {
 
   @Override
   public void execute() {
-    String exportPath = settings.getString(SONAR_REPORT_EXPORT_PATH);
-    if (exportPath != null) {
-      exportResults(exportPath);
-    }
+    settings.get(SONAR_REPORT_EXPORT_PATH).ifPresent(this::exportResults);
   }
 
   private void exportResults(String exportPath) {
index 3783e4d1f814212fb40ca3d27e91d4ce000c2f45..2af99f07bb9b91116eb777ce781fd4b9c479a9ea 100644 (file)
  */
 package org.sonar.scanner.scan.report;
 
-import org.sonar.api.batch.rule.Rule;
-
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.commons.lang.builder.ToStringBuilder;
+import org.sonar.api.batch.rule.Rule;
 import org.sonar.api.rules.RulePriority;
 
 /**
index d7402233f714da1bacc3667f893505fbaa50948b..c3c93bfb461bf8dbd32f7688f456760793e4cb17 100644 (file)
@@ -27,7 +27,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.annotation.Nullable;
-
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.fs.InputDir;
 import org.sonar.api.batch.fs.InputFile;
index 2ffcabdbaf2d057441206287bec59ceb219daa93..eaaf9b00b0e1d0f1949fdc1bc6638ee5634048b8 100644 (file)
  */
 package org.sonar.scanner.scan.report;
 
-import org.sonar.api.batch.rule.Rule;
-
-import org.sonar.api.batch.rule.Rules;
+import javax.annotation.CheckForNull;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.sonar.api.batch.ScannerSide;
+import org.sonar.api.batch.rule.Rule;
+import org.sonar.api.batch.rule.Rules;
 import org.sonar.api.rule.RuleKey;
 
-import javax.annotation.CheckForNull;
-
 @ScannerSide
 public class RuleNameProvider {
   private Rules rules;
index 8b3231fbf41c81b395d2dbe32ce7a87b22dea954..528a372eb5211fcc5078460c651882b20bc0c838 100644 (file)
@@ -19,9 +19,8 @@
  */
 package org.sonar.scanner.scan.report;
 
-import org.sonar.api.batch.rule.Rule;
-
 import org.apache.commons.lang.builder.ToStringBuilder;
+import org.sonar.api.batch.rule.Rule;
 
 public final class RuleReport {
   private final ReportRuleKey reportRuleKey;
index 3d81b49d2501aacbdec9fc3e7330e0d91648d29f..5311b80733086855913ddd952fd7e1a9bc5581bd 100644 (file)
@@ -36,8 +36,8 @@ import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReport.Changesets.Builder;
-import org.sonar.scanner.util.ProgressReport;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
+import org.sonar.scanner.util.ProgressReport;
 
 class DefaultBlameOutput implements BlameOutput {
 
index 883d82072254025d94d5b0cc2bcd52c14884de15..68c75b647a6a80ad7036f4693056259fcbae2afb 100644 (file)
@@ -29,10 +29,10 @@ import org.sonar.api.Properties;
 import org.sonar.api.Property;
 import org.sonar.api.PropertyType;
 import org.sonar.api.batch.AnalysisMode;
-import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.scm.ScmProvider;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.scanner.scan.ImmutableProjectReactor;
@@ -57,13 +57,13 @@ public final class ScmConfiguration implements Startable {
   public static final String FORCE_RELOAD_KEY = "sonar.scm.forceReloadAll";
 
   private final ImmutableProjectReactor projectReactor;
-  private final Settings settings;
+  private final Configuration settings;
   private final Map<String, ScmProvider> providerPerKey = new LinkedHashMap<>();
   private final AnalysisMode analysisMode;
 
   private ScmProvider provider;
 
-  public ScmConfiguration(ImmutableProjectReactor projectReactor, AnalysisMode analysisMode, Settings settings, ScmProvider... providers) {
+  public ScmConfiguration(ImmutableProjectReactor projectReactor, AnalysisMode analysisMode, Configuration settings, ScmProvider... providers) {
     this.projectReactor = projectReactor;
     this.analysisMode = analysisMode;
     this.settings = settings;
@@ -72,7 +72,7 @@ public final class ScmConfiguration implements Startable {
     }
   }
 
-  public ScmConfiguration(ImmutableProjectReactor projectReactor, AnalysisMode analysisMode, Settings settings) {
+  public ScmConfiguration(ImmutableProjectReactor projectReactor, AnalysisMode analysisMode, Configuration settings) {
     this(projectReactor, analysisMode, settings, new ScmProvider[0]);
   }
 
@@ -86,8 +86,7 @@ public final class ScmConfiguration implements Startable {
       return;
     }
     if (settings.hasKey(CoreProperties.SCM_PROVIDER_KEY)) {
-      String forcedProviderKey = settings.getString(CoreProperties.SCM_PROVIDER_KEY);
-      setProviderIfSupported(forcedProviderKey);
+      settings.get(CoreProperties.SCM_PROVIDER_KEY).ifPresent(this::setProviderIfSupported);
     } else {
       autodetection();
       if (this.provider == null) {
@@ -110,16 +109,14 @@ public final class ScmConfiguration implements Startable {
   }
 
   private void considerOldScmUrl() {
-    if (settings.hasKey(CoreProperties.LINKS_SOURCES_DEV)) {
-      String url = settings.getString(CoreProperties.LINKS_SOURCES_DEV);
+    settings.get(CoreProperties.LINKS_SOURCES_DEV).ifPresent(url -> {
       if (StringUtils.startsWith(url, "scm:")) {
         String[] split = url.split(":");
         if (split.length > 1) {
           setProviderIfSupported(split[1]);
         }
       }
-    }
-
+    });
   }
 
   private void autodetection() {
@@ -140,11 +137,11 @@ public final class ScmConfiguration implements Startable {
   }
 
   public boolean isDisabled() {
-    return settings.getBoolean(CoreProperties.SCM_DISABLED_KEY);
+    return settings.getBoolean(CoreProperties.SCM_DISABLED_KEY).orElse(false);
   }
 
   public boolean forceReloadAll() {
-    return settings.getBoolean(FORCE_RELOAD_KEY);
+    return settings.getBoolean(FORCE_RELOAD_KEY).orElse(false);
   }
 
   @Override
index a0d6e89338caa16776559ea11679c66cc61f292b..28d8a400b618aa848adc92ece7499ef7b13dbb83 100644 (file)
@@ -32,9 +32,9 @@ import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.scanner.protocol.output.ScannerReport;
+import org.sonar.scanner.protocol.output.ScannerReport.Changesets.Builder;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
 import org.sonar.scanner.report.ReportPublisher;
-import org.sonar.scanner.protocol.output.ScannerReport.Changesets.Builder;
 import org.sonar.scanner.repository.FileData;
 import org.sonar.scanner.repository.ProjectRepositories;
 import org.sonar.scanner.scan.filesystem.DefaultModuleFileSystem;
index 3a300a7196eebfa06adcfb8f31f403112bbc63ab..9467d96829a18159e318453e79e5576321a99b67 100644 (file)
@@ -42,6 +42,7 @@ import org.sonar.api.batch.sensor.measure.NewMeasure;
 import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
 import org.sonar.api.batch.sensor.symbol.NewSymbolTable;
 import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.config.Settings;
 import org.sonar.api.utils.Version;
 import org.sonar.scanner.sensor.noop.NoOpNewAnalysisError;
@@ -56,18 +57,21 @@ public class DefaultSensorContext implements SensorContext {
   private static final NoOpNewCpdTokens NO_OP_NEW_CPD_TOKENS = new NoOpNewCpdTokens();
   private static final NoOpNewAnalysisError NO_OP_NEW_ANALYSIS_ERROR = new NoOpNewAnalysisError();
 
-  private final Settings settings;
+  private final Settings mutableSettings;
   private final FileSystem fs;
   private final ActiveRules activeRules;
   private final SensorStorage sensorStorage;
   private final AnalysisMode analysisMode;
   private final InputModule module;
   private final SonarRuntime sonarRuntime;
+  private final Configuration config;
 
-  public DefaultSensorContext(InputModule module, Settings settings, FileSystem fs, ActiveRules activeRules, AnalysisMode analysisMode, SensorStorage sensorStorage,
+  public DefaultSensorContext(InputModule module, Configuration config, Settings mutableSettings, FileSystem fs, ActiveRules activeRules,
+    AnalysisMode analysisMode, SensorStorage sensorStorage,
     SonarRuntime sonarRuntime) {
     this.module = module;
-    this.settings = settings;
+    this.config = config;
+    this.mutableSettings = mutableSettings;
     this.fs = fs;
     this.activeRules = activeRules;
     this.analysisMode = analysisMode;
@@ -77,7 +81,12 @@ public class DefaultSensorContext implements SensorContext {
 
   @Override
   public Settings settings() {
-    return settings;
+    return mutableSettings;
+  }
+
+  @Override
+  public Configuration config() {
+    return config;
   }
 
   @Override
@@ -141,7 +150,7 @@ public class DefaultSensorContext implements SensorContext {
     if (analysisMode.isIssues()) {
       return NO_OP_NEW_CPD_TOKENS;
     }
-    return new DefaultCpdTokens(settings, sensorStorage);
+    return new DefaultCpdTokens(config, sensorStorage);
   }
 
   @Override
index 096732cc304a0573321f173119dc619aca6854c4..ac966c2a855da33d15b7c70ee731ce3a5ee93a9b 100644 (file)
@@ -45,7 +45,7 @@ import org.sonar.api.batch.sensor.issue.Issue;
 import org.sonar.api.batch.sensor.measure.Measure;
 import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
 import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.api.utils.log.Logger;
@@ -146,7 +146,7 @@ public class DefaultSensorStorage implements SensorStorage {
   private final MeasureCache measureCache;
   private final SonarCpdBlockIndex index;
   private final ContextPropertiesCache contextPropertiesCache;
-  private final Settings settings;
+  private final Configuration settings;
   private final ScannerMetrics scannerMetrics;
   private final Map<Metric<?>, Metric<?>> deprecatedCoverageMetricMapping = new HashMap<>();
   private final Set<Metric<?>> coverageMetrics = new HashSet<>();
@@ -154,7 +154,7 @@ public class DefaultSensorStorage implements SensorStorage {
   private Set<String> alreadyLogged = new HashSet<>();
 
   public DefaultSensorStorage(MetricFinder metricFinder, ModuleIssues moduleIssues,
-    Settings settings,
+    Configuration settings,
     CoverageExclusions coverageExclusions, ReportPublisher reportPublisher,
     MeasureCache measureCache, SonarCpdBlockIndex index,
     ContextPropertiesCache contextPropertiesCache, ScannerMetrics scannerMetrics) {
@@ -221,7 +221,7 @@ public class DefaultSensorStorage implements SensorStorage {
     if (component.isFile()) {
       ((DefaultInputFile) component).setPublish(true);
     }
-    
+
     if (isDeprecatedMetric(measure.metric().key())) {
       logOnce(measure.metric().key(), "Metric '{}' is deprecated. Provided value is ignored.", measure.metric().key());
       return;
@@ -452,11 +452,7 @@ public class DefaultSensorStorage implements SensorStorage {
 
   @VisibleForTesting
   int getBlockSize(String languageKey) {
-    int blockSize = settings.getInt("sonar.cpd." + languageKey + ".minimumLines");
-    if (blockSize == 0) {
-      blockSize = DefaultCpdBlockIndexer.getDefaultBlockSize(languageKey);
-    }
-    return blockSize;
+    return settings.getInt("sonar.cpd." + languageKey + ".minimumLines").orElse(DefaultCpdBlockIndexer.getDefaultBlockSize(languageKey));
   }
 
   @Override
index 68f38565d239779f5f3f09da5c8f5cc5c8893bdb..8f8907dbb9a5ee2b30686b2d03063e2f71265b14 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.api.batch.fs.FilePredicate;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.rule.ActiveRules;
 import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 
 @ScannerSide
 public class SensorOptimizer {
@@ -35,12 +35,12 @@ public class SensorOptimizer {
 
   private final FileSystem fs;
   private final ActiveRules activeRules;
-  private final Settings settings;
+  private final Configuration config;
 
-  public SensorOptimizer(FileSystem fs, ActiveRules activeRules, Settings settings) {
+  public SensorOptimizer(FileSystem fs, ActiveRules activeRules, Configuration config) {
     this.fs = fs;
     this.activeRules = activeRules;
-    this.settings = settings;
+    this.config = config;
   }
 
   /**
@@ -65,7 +65,7 @@ public class SensorOptimizer {
   private boolean settingsCondition(DefaultSensorDescriptor descriptor) {
     if (!descriptor.properties().isEmpty()) {
       for (String propertyKey : descriptor.properties()) {
-        if (!settings.hasKey(propertyKey)) {
+        if (!config.hasKey(propertyKey)) {
           return false;
         }
       }
index d909dfe81bf11a2ee38649da41e4f978adea6e68..490f067d7644ace4ffbf6fc7d9d395297fcbb080 100644 (file)
@@ -29,17 +29,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.utils.WildcardPattern;
 
 public class CoverageExclusions implements Startable {
 
   private static final Logger LOG = LoggerFactory.getLogger(CoverageExclusions.class);
 
-  private final Settings settings;
+  private final Configuration settings;
   private Collection<WildcardPattern> exclusionPatterns;
 
-  public CoverageExclusions(Settings settings) {
+  public CoverageExclusions(Configuration settings) {
     this.settings = settings;
   }
 
index 446fbd4089b5d7cf8f105c26936440fb23936fbe..47f10cabe8f19398bb53258333b12fc81f03a086 100644 (file)
  */
 package org.sonar.scanner.source;
 
+import com.google.common.collect.Sets;
 import java.util.Map;
 import java.util.Set;
 import java.util.function.Function;
 import java.util.stream.StreamSupport;
-
 import org.sonar.api.batch.Phase;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
@@ -41,8 +41,6 @@ import org.sonar.core.util.stream.MoreCollectors;
 import org.sonar.scanner.scan.measure.MeasureCache;
 import org.sonar.scanner.sensor.coverage.CoverageExclusions;
 
-import com.google.common.collect.Sets;
-
 @Phase(name = Phase.Name.POST)
 public final class ZeroCoverageSensor implements Sensor {
 
index 776e76f3e855cce8895b6fba0bf85ad5b5dff15d..ca307cfa8acf0f7d18f7fd1c50e0cbd9397cbc0e 100644 (file)
@@ -27,7 +27,6 @@ import com.persistit.Volume;
 import com.persistit.encoding.CoderManager;
 import com.persistit.encoding.ValueCoder;
 import com.persistit.exception.PersistitException;
-
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
index 3591d7788da2afc03aeb31a475ddee9a6e3e13d1..477bd4d2d836ad6bf8cde72aae107fdcb9a456f1 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Map;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.InstantiationStrategy;
-import org.sonar.api.config.EmailSettings;
 import org.sonar.api.task.Task;
 import org.sonar.api.task.TaskDefinition;
 import org.sonar.api.utils.MessageException;
@@ -55,7 +54,6 @@ public class TaskContainer extends ComponentContainer {
 
   private void addCoreComponents() {
     add(new TaskProperties(taskProperties, getParent().getComponentByType(GlobalProperties.class).property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH)));
-    add(EmailSettings.class);
   }
 
   private void addTaskExtensions() {
index 0b19a508fc9aa8ad4d98e27c25c05d07d1b11457..a674649b6ba18df72f47b86679957641aff2d08c 100644 (file)
@@ -24,8 +24,8 @@ import com.google.common.collect.Maps;
 import java.util.Collection;
 import java.util.Map;
 import java.util.SortedMap;
-import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.task.Task;
 import org.sonar.api.task.TaskDefinition;
 
index 5709fd8d33f049a45768dd4f02ff0bb2d5fb20f1..fd0f6842150d92bcee539f417ace498af6a3829d 100644 (file)
@@ -20,9 +20,6 @@
 package org.sonar.batch.bootstrapper;
 
 import org.junit.Test;
-import org.sonar.batch.bootstrapper.Batch;
-import org.sonar.batch.bootstrapper.EnvironmentInformation;
-import org.sonar.batch.bootstrapper.LogOutput;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertNotNull;
index 45e5aef44aa9750af015722d64683277d6f4c9e8..a5a53519833ceff729beb99054b84ee2fc2100ee 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.batch.bootstrapper;
 
 import org.junit.Test;
-import org.sonar.batch.bootstrapper.EnvironmentInformation;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index bdd9ec58f96a0de82d49dfd1d41f3230291acdb0..3baa1d2c240bc0aab01005482677729cc21882a1 100644 (file)
@@ -23,8 +23,6 @@ import ch.qos.logback.classic.Level;
 import ch.qos.logback.classic.spi.ILoggingEvent;
 import org.junit.Before;
 import org.junit.Test;
-import org.sonar.batch.bootstrapper.LogCallbackAppender;
-import org.sonar.batch.bootstrapper.LogOutput;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.reset;
index 71ce99fca72af2ad048a9b2277c647587d722dc8..0e0cdb0f3f52ec4a9becf412ec0f9efbcab30cf5 100644 (file)
  */
 package org.sonar.scanner;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
 import java.time.LocalDate;
 import java.time.ZoneId;
 import java.util.Date;
-
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
 public class ProjectAnalysisInfoTest {
   @Test
   public void testSimpleDate() {
-    Settings settings = new MapSettings();
+    MapSettings settings = new MapSettings();
     settings.appendProperty(CoreProperties.PROJECT_DATE_PROPERTY, "2017-01-01");
     settings.appendProperty(CoreProperties.PROJECT_VERSION_PROPERTY, "version");
     System2 system = mock(System2.class);
-    ProjectAnalysisInfo info = new ProjectAnalysisInfo(settings, system);
+    ProjectAnalysisInfo info = new ProjectAnalysisInfo(settings.asConfig(), system);
     info.start();
     LocalDate date = LocalDate.of(2017, 1, 1);
 
index 88b2c7d05eb4e4b35be05dd76375555cc7d8d550..694830ad91812cdc4e000306de29e39e46ef2de4 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.scanner;
 
+import java.io.InputStream;
+import java.io.Reader;
 import org.apache.commons.lang.StringUtils;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
@@ -26,9 +28,6 @@ import org.sonar.scanner.bootstrap.ScannerWsClient;
 import org.sonarqube.ws.client.WsRequest;
 import org.sonarqube.ws.client.WsResponse;
 
-import java.io.InputStream;
-import java.io.Reader;
-
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.argThat;
 import static org.mockito.Mockito.mock;
index c7ff83095777de11b1a030df8c9119505bd1d531..60a8f7140bba60d12b8f5ed2663ec898b973d8cd 100644 (file)
  */
 package org.sonar.scanner.analysis;
 
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-
-import org.sonar.api.batch.bootstrap.ProjectReactor;
+import java.io.File;
+import java.io.IOException;
 import org.junit.Before;
-import org.sonar.api.utils.TempFolder;
-import org.sonar.scanner.analysis.AnalysisTempFolderProvider;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.utils.TempFolder;
 
-import java.io.File;
-import java.io.IOException;
-
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.mock;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class AnalysisTempFolderProviderTest {
 
index 095da114e938e1cce115cc37837918fe12c963d2..b7544e1f0ce87174e1cbe1d6eb2c1533df4a46ce 100644 (file)
  */
 package org.sonar.scanner.analysis;
 
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
+import java.util.HashMap;
+import java.util.Map;
 import javax.annotation.Nullable;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.sonar.api.CoreProperties;
-import org.sonar.scanner.analysis.AnalysisProperties;
-import org.sonar.scanner.analysis.DefaultAnalysisMode;
 import org.sonar.scanner.bootstrap.GlobalProperties;
-import java.util.HashMap;
-import java.util.Map;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 8126f43c29ab05f01f45e0ea70aa17a25d11a252..e4d9168a2880980682f89087fce830699b5ed741 100644 (file)
@@ -24,7 +24,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
-import org.sonar.scanner.bootstrap.DroppedPropertyChecker;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 2c867b61bce86ad549ad08994c3ba315fa9bf5d2..8b2baaf57e16eb9a0c231565881d6befc3cfe412 100644 (file)
@@ -26,7 +26,6 @@ import org.sonar.api.batch.InstantiationStrategy;
 import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.ce.ComputeEngineSide;
 import org.sonar.api.server.ServerSide;
-import org.sonar.scanner.bootstrap.ExtensionUtils;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 06bde834a69507445207d34e4561ccd7522df5fd..f86ef04f4a291c201ef1a4b9a4c80173dec8d239 100644 (file)
@@ -24,8 +24,7 @@ import java.io.IOException;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.home.cache.FileCache;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -37,7 +36,7 @@ public class FileCacheProviderTest {
   @Test
   public void provide() {
     FileCacheProvider provider = new FileCacheProvider();
-    FileCache cache = provider.provide(new MapSettings());
+    FileCache cache = provider.provide(new MapSettings().asConfig());
 
     assertThat(cache).isNotNull();
     assertThat(cache.getDir()).isNotNull().exists();
@@ -46,9 +45,9 @@ public class FileCacheProviderTest {
   @Test
   public void keep_singleton_instance() {
     FileCacheProvider provider = new FileCacheProvider();
-    Settings settings = new MapSettings();
-    FileCache cache1 = provider.provide(settings);
-    FileCache cache2 = provider.provide(settings);
+    MapSettings settings = new MapSettings();
+    FileCache cache1 = provider.provide(settings.asConfig());
+    FileCache cache2 = provider.provide(settings.asConfig());
 
     assertThat(cache1).isSameAs(cache2);
   }
@@ -56,10 +55,10 @@ public class FileCacheProviderTest {
   @Test
   public void honor_sonarUserHome() throws IOException {
     FileCacheProvider provider = new FileCacheProvider();
-    Settings settings = new MapSettings();
+    MapSettings settings = new MapSettings();
     File f = temp.newFolder();
     settings.appendProperty("sonar.userHome", f.getAbsolutePath());
-    FileCache cache = provider.provide(settings);
+    FileCache cache = provider.provide(settings.asConfig());
 
     assertThat(cache.getDir()).isEqualTo(new File(f, "cache"));
   }
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java
new file mode 100644 (file)
index 0000000..0ee71d9
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.bootstrap;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.scanner.repository.settings.SettingsLoader;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class GlobalConfigurationProviderTest {
+
+  public static final String SOME_VALUE = "some_value";
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+  @Rule
+  public LogTester logTester = new LogTester();
+
+  SettingsLoader settingsLoader;
+  GlobalProperties bootstrapProps;
+
+  private GlobalMode mode;
+
+  @Before
+  public void prepare() {
+    settingsLoader = mock(SettingsLoader.class);
+    bootstrapProps = new GlobalProperties(Collections.<String, String>emptyMap());
+    mode = mock(GlobalMode.class);
+  }
+
+  @Test
+  public void should_load_global_settings() {
+    when(settingsLoader.load(null)).thenReturn(ImmutableMap.of("sonar.cpd.cross", "true"));
+
+    GlobalConfiguration globalConfig = new GlobalConfigurationProvider().provide(settingsLoader, bootstrapProps, new PropertyDefinitions(), mode);
+
+    assertThat(globalConfig.get("sonar.cpd.cross")).hasValue("true");
+  }
+
+  @Test
+  public void should_log_warn_msg_for_each_jdbc_property_if_present() {
+    when(settingsLoader.load(null)).thenReturn(ImmutableMap.of("sonar.jdbc.url", SOME_VALUE,
+      "sonar.jdbc.username", SOME_VALUE,
+      "sonar.jdbc.password", SOME_VALUE));
+
+    new GlobalConfigurationProvider().provide(settingsLoader, bootstrapProps, new PropertyDefinitions(), mode);
+
+    assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly(
+      "Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.",
+      "Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.",
+      "Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.");
+  }
+}
index 7333a7071446d111ed0675ef091691fac0ee6e5e..26e8d1e912fa2bebd693551386ad036ea7098bf5 100644 (file)
@@ -31,7 +31,6 @@ import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.BatchSide;
 import org.sonar.api.utils.TempFolder;
 import org.sonar.core.util.UuidFactory;
-import org.sonar.scanner.bootstrap.GlobalContainer;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 4bbab8408f7e1e3f1d8fa0788d012499178d33d6..fed2ba5aa92c10b1ecd9133d7d0787d32c3fd579 100644 (file)
  */
 package org.sonar.scanner.bootstrap;
 
+import java.util.HashMap;
+import java.util.Map;
 import org.junit.Rule;
+import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.CoreProperties;
-import org.sonar.scanner.bootstrap.GlobalMode;
-import org.sonar.scanner.bootstrap.GlobalProperties;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index d6f544b1a6ca25c3de99ccd9d05b6ed5fa4b06a6..d459e7303b66bd4946854d499e43217d9f8c7d90 100644 (file)
@@ -20,9 +20,8 @@
 package org.sonar.scanner.bootstrap;
 
 import com.google.common.collect.Maps;
-import org.junit.Test;
-import org.sonar.scanner.bootstrap.GlobalProperties;
 import java.util.Map;
+import org.junit.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.entry;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalSettingsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalSettingsTest.java
deleted file mode 100644 (file)
index 7d9bf07..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.scanner.bootstrap;
-
-import com.google.common.collect.ImmutableMap;
-import java.util.Collections;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
-import org.sonar.scanner.repository.settings.SettingsLoader;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class GlobalSettingsTest {
-
-  public static final String SOME_VALUE = "some_value";
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-  @Rule
-  public LogTester logTester = new LogTester();
-
-  SettingsLoader settingsLoader;
-  GlobalProperties bootstrapProps;
-
-  private GlobalMode mode;
-
-  @Before
-  public void prepare() {
-    settingsLoader = mock(SettingsLoader.class);
-    bootstrapProps = new GlobalProperties(Collections.<String, String>emptyMap());
-    mode = mock(GlobalMode.class);
-  }
-
-  @Test
-  public void should_load_global_settings() {
-    when(settingsLoader.load(null)).thenReturn(ImmutableMap.of("sonar.cpd.cross", "true"));
-
-    GlobalSettings batchSettings = new GlobalSettings(bootstrapProps, new PropertyDefinitions(), settingsLoader, mode);
-
-    assertThat(batchSettings.getBoolean("sonar.cpd.cross")).isTrue();
-  }
-
-  @Test
-  public void should_log_warn_msg_for_each_jdbc_property_if_present() {
-    when(settingsLoader.load(null)).thenReturn(ImmutableMap.of("sonar.jdbc.url", SOME_VALUE,
-      "sonar.jdbc.username", SOME_VALUE,
-      "sonar.jdbc.password", SOME_VALUE));
-
-    new GlobalSettings(bootstrapProps, new PropertyDefinitions(), settingsLoader, mode);
-
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly(
-      "Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.",
-      "Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.",
-      "Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.");
-  }
-}
index 23218bf7092c14e9d772943d768a6dd944def794..5585545241b545b18bb5f77ca6eacd5de1f7e270 100644 (file)
  */
 package org.sonar.scanner.bootstrap;
 
-import org.sonar.api.utils.System2;
-import org.apache.commons.io.FileUtils;
-import org.sonar.api.utils.TempFolder;
-import org.sonar.scanner.bootstrap.GlobalProperties;
-import org.sonar.scanner.bootstrap.GlobalTempFolderProvider;
 import com.google.common.collect.ImmutableMap;
-import org.sonar.api.CoreProperties;
-
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
@@ -34,13 +27,17 @@ import java.nio.file.attribute.BasicFileAttributeView;
 import java.nio.file.attribute.FileTime;
 import java.util.Collections;
 import java.util.concurrent.TimeUnit;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.assertj.core.api.Assertions.assertThat;
+import org.apache.commons.io.FileUtils;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.utils.System2;
+import org.sonar.api.utils.TempFolder;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class GlobalTempFolderProviderTest {
   @Rule
index 2babecd6585ab6a2e4c926d0b3fb1bc0cd457c95..88555e6775b36b8a33bd3f90f090984b4d2b9118 100644 (file)
  */
 package org.sonar.scanner.bootstrap;
 
+import java.util.Arrays;
+import java.util.List;
 import org.junit.Test;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.measures.Metrics;
-import org.sonar.scanner.bootstrap.MetricProvider;
-import java.util.Arrays;
-import java.util.List;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index f5f7f20f684bbaa931be92602393f8f839fd4029..3f799a748158c7c79a1865a30f16a913dd998c79 100644 (file)
@@ -30,8 +30,6 @@ import org.sonar.core.platform.ExplodedPlugin;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.home.cache.FileCache;
 import org.sonar.home.cache.FileCacheBuilder;
-import org.sonar.scanner.bootstrap.ScannerPluginJarExploder;
-import org.sonar.scanner.bootstrap.Slf4jLogger;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index fbc7ee0f4ea7543803a53e3e2946eb288d226859..6ae96de59e849f0c97de393b84032ae351bf2095 100644 (file)
@@ -21,8 +21,7 @@ package org.sonar.scanner.bootstrap;
 
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -30,12 +29,12 @@ import static org.mockito.Mockito.when;
 
 public class ScannerPluginPredicateTest {
 
-  Settings settings = new MapSettings();
-  GlobalMode mode = mock(GlobalMode.class);
+  private MapSettings settings = new MapSettings();
+  private GlobalMode mode = mock(GlobalMode.class);
 
   @Test
   public void accept_if_no_inclusions_nor_exclusions() {
-    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings, mode);
+    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings.asConfig(), mode);
     assertThat(predicate.getWhites()).isEmpty();
     assertThat(predicate.getBlacks()).isEmpty();
     assertThat(predicate.apply("pmd")).isTrue();
@@ -45,7 +44,7 @@ public class ScannerPluginPredicateTest {
   @Test
   public void exclude_buildbreaker_in_preview_mode() {
     when(mode.isPreview()).thenReturn(true);
-    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings, mode);
+    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings.asConfig(), mode);
     assertThat(predicate.apply("buildbreaker")).isFalse();
   }
 
@@ -55,7 +54,7 @@ public class ScannerPluginPredicateTest {
     settings
       .setProperty(CoreProperties.PREVIEW_INCLUDE_PLUGINS, "checkstyle,pmd,findbugs")
       .setProperty(CoreProperties.PREVIEW_EXCLUDE_PLUGINS, "cobertura,pmd");
-    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings, mode);
+    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings.asConfig(), mode);
     assertThat(predicate.apply("pmd")).isTrue();
   }
 
@@ -65,7 +64,7 @@ public class ScannerPluginPredicateTest {
     settings
       .setProperty(CoreProperties.PREVIEW_INCLUDE_PLUGINS, "checkstyle,pmd,findbugs")
       .setProperty(CoreProperties.PREVIEW_EXCLUDE_PLUGINS, "cobertura");
-    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings, mode);
+    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings.asConfig(), mode);
     assertThat(predicate.apply("checkstyle")).isTrue();
     assertThat(predicate.apply("pmd")).isTrue();
     assertThat(predicate.apply("cobertura")).isFalse();
@@ -77,7 +76,7 @@ public class ScannerPluginPredicateTest {
     settings
       .setProperty(CoreProperties.PREVIEW_INCLUDE_PLUGINS, "checkstyle,pmd,findbugs")
       .setProperty(CoreProperties.PREVIEW_EXCLUDE_PLUGINS, "cobertura");
-    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings, mode);
+    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings.asConfig(), mode);
     assertThat(predicate.apply("checkstyle")).isTrue();
     assertThat(predicate.apply("pmd")).isTrue();
     assertThat(predicate.apply("cobertura")).isFalse();
@@ -87,7 +86,7 @@ public class ScannerPluginPredicateTest {
   public void test_exclusions_without_any_inclusions() {
     when(mode.isPreview()).thenReturn(true);
     settings.setProperty(CoreProperties.PREVIEW_EXCLUDE_PLUGINS, "checkstyle,pmd,findbugs");
-    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings, mode);
+    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings.asConfig(), mode);
     assertThat(predicate.apply("checkstyle")).isFalse();
     assertThat(predicate.apply("pmd")).isFalse();
     assertThat(predicate.apply("cobertura")).isTrue();
@@ -98,7 +97,7 @@ public class ScannerPluginPredicateTest {
     settings
       .setProperty(CoreProperties.PREVIEW_INCLUDE_PLUGINS, "checkstyle, pmd, findbugs")
       .setProperty(CoreProperties.PREVIEW_EXCLUDE_PLUGINS, "cobertura, pmd");
-    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings, mode);
+    ScannerPluginPredicate predicate = new ScannerPluginPredicate(settings.asConfig(), mode);
     assertThat(predicate.apply("pmd")).isTrue();
   }
 
index 9750e7cec60dabd208790b900ffb0cc9ae1f2b46..967c5c8f351ee0e791c77d661fc02ff151ca1a3c 100644 (file)
@@ -24,8 +24,6 @@ import org.junit.Test;
 import org.sonar.api.Plugin;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.core.platform.PluginLoader;
-import org.sonar.scanner.bootstrap.ScannerPluginRepository;
-import org.sonar.scanner.bootstrap.PluginInstaller;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
index 465200012bfc551de24d8fb09282b493e0a1f186..e885192a59ff79cf54045db0f24e63e5d29d21fd 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.cpd;
 
 import org.junit.Test;
-import org.sonar.scanner.cpd.CpdComponents;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 708f5ac97bc8fbba091a3954d341582570f478a3..e46702cb90e8ea644cf569c676a60b8e343a5e86 100644 (file)
@@ -33,8 +33,7 @@ import org.junit.rules.TemporaryFolder;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.scan.filesystem.PathResolver;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
@@ -56,11 +55,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public class CpdExecutorTest {
-  private CpdExecutor executor;
-  private Settings settings;
-  private SonarCpdBlockIndex index;
-  private ReportPublisher publisher;
-
   @Rule
   public LogTester logTester = new LogTester();
 
@@ -70,6 +64,10 @@ public class CpdExecutorTest {
   @Rule
   public ExpectedException thrown = ExpectedException.none();
 
+  private CpdExecutor executor;
+  private MapSettings settings;
+  private SonarCpdBlockIndex index;
+  private ReportPublisher publisher;
   private ScannerReportReader reader;
   private DefaultInputFile batchComponent1;
   private DefaultInputFile batchComponent2;
@@ -85,9 +83,9 @@ public class CpdExecutorTest {
     settings = new MapSettings();
     publisher = mock(ReportPublisher.class);
     when(publisher.getWriter()).thenReturn(new ScannerReportWriter(outputDir));
-    index = new SonarCpdBlockIndex(publisher, settings);
+    index = new SonarCpdBlockIndex(publisher, settings.asConfig());
     componentStore = new InputComponentStore(new PathResolver());
-    executor = new CpdExecutor(settings, index, publisher, componentStore);
+    executor = new CpdExecutor(settings.asConfig(), index, publisher, componentStore);
     reader = new ScannerReportReader(outputDir);
 
     componentStore.put(TestInputFileBuilder.newDefaultInputModule("foo", baseDir));
index d02dff618534cf2b51ce5e8ae4144274065f0b1f..6b961772daad0658348bd7f16564b0796b1a259d 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.scanner.cpd;
 import com.google.common.base.Predicate;
 import org.junit.Test;
 import org.sonar.duplications.index.CloneGroup;
-import org.sonar.scanner.cpd.DuplicationPredicates;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 616a7c66e7a37e922d7170ac21a00408b6ad1f27..6446aa1822fae16f83ed0b082bc8595e102f68ff 100644 (file)
@@ -22,8 +22,7 @@ package org.sonar.scanner.cpd.deprecated;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -31,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 public class DefaultCpdBlockIndexerTest {
 
   private DefaultCpdBlockIndexer engine;
-  private Settings settings;
+  private MapSettings settings;
 
   @Rule
   public LogTester logTester = new LogTester();
@@ -39,7 +38,7 @@ public class DefaultCpdBlockIndexerTest {
   @Before
   public void init() {
     settings = new MapSettings();
-    engine = new DefaultCpdBlockIndexer(null, null, settings, null);
+    engine = new DefaultCpdBlockIndexer(null, null, settings.asConfig(), null);
   }
 
   @Test
index 325bb08789b1811c13f94274155710622b8e2de9..4952e1cab2d37ddd379c373980ad6cfd8dde541d 100644 (file)
@@ -37,8 +37,7 @@ import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultFileSystem;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.duplications.block.Block;
 import org.sonar.scanner.cpd.index.SonarCpdBlockIndex;
 
@@ -57,7 +56,7 @@ public class JavaCpdBlockIndexerTest {
   @Captor
   private ArgumentCaptor<List<Block>> blockCaptor;
 
-  private Settings settings;
+  private MapSettings settings;
   private JavaCpdBlockIndexer engine;
   private InputFile file;
 
@@ -79,12 +78,12 @@ public class JavaCpdBlockIndexerTest {
     FileUtils.copyURLToFile(this.getClass().getResource("ManyStatements.java"), ioFile);
 
     settings = new MapSettings();
-    engine = new JavaCpdBlockIndexer(fs, settings, index);
+    engine = new JavaCpdBlockIndexer(fs, settings.asConfig(), index);
   }
 
   @Test
   public void languageSupported() {
-    JavaCpdBlockIndexer engine = new JavaCpdBlockIndexer(mock(FileSystem.class), new MapSettings(), index);
+    JavaCpdBlockIndexer engine = new JavaCpdBlockIndexer(mock(FileSystem.class), new MapSettings().asConfig(), index);
     assertThat(engine.isLanguageSupported(JAVA)).isTrue();
     assertThat(engine.isLanguageSupported("php")).isFalse();
   }
index 7c714e0231ea4061f30a05fb4e02a97249d5325d..7385e3af1e617da9618ff43a99be307ab8ed8f2f 100644 (file)
@@ -20,8 +20,6 @@
 package org.sonar.scanner.events;
 
 import org.junit.Test;
-import org.sonar.scanner.events.BatchStepEvent;
-import org.sonar.scanner.events.BatchStepHandler;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index 1ccae4fe949a149513c069147d7319be0d42b790..4608be2638fc57d694cb65fc8cbcc24eda889e83 100644 (file)
@@ -21,8 +21,6 @@ package org.sonar.scanner.events;
 
 import org.junit.Test;
 import org.sonar.api.batch.events.EventHandler;
-import org.sonar.scanner.events.BatchEvent;
-import org.sonar.scanner.events.EventBus;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
index 4bae1ec3135420ca7511b3fd1f7a5d226a54a05b..a23a5d6499f8a20dd76781fd92f5734e5e8959af 100644 (file)
@@ -21,9 +21,9 @@ package org.sonar.scanner.genericcoverage;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 
index 99af4485fe1e24a2d004e0873b275770febfd3ae..356db75b3e63e796ce6a3f8d12d010484286a0f3 100644 (file)
@@ -26,9 +26,9 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.batch.sensor.internal.SensorContextTester;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.scanner.deprecated.test.TestPlanBuilder;
index b9a3d19fd110a5bb5cb095415253898ea2594ba3..72b5b501d4fb5ea905b0bac8838ab791d7e4adec 100644 (file)
  */
 package org.sonar.scanner.index;
 
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
 import org.junit.After;
-
-import org.junit.Before;
 import org.junit.AfterClass;
+import org.junit.Before;
 import org.junit.BeforeClass;
-import com.google.common.collect.ImmutableMap;
+import org.junit.ClassRule;
+import org.junit.rules.TemporaryFolder;
 import org.sonar.api.CoreProperties;
 import org.sonar.scanner.bootstrap.GlobalProperties;
 import org.sonar.scanner.bootstrap.GlobalTempFolderProvider;
 import org.sonar.scanner.storage.Storages;
 import org.sonar.scanner.storage.StoragesManager;
-import java.util.Map;
-
-import org.junit.ClassRule;
-import org.junit.rules.TemporaryFolder;
 
 public abstract class AbstractCachesTest {
   @ClassRule
index 1ddf03b28edead0d8417d30a6ebf029b61d8cea2..d82bb5d20b113b1d5510e64439f52c4baef57eb8 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.scanner.index;
 
 import java.io.IOException;
 import java.util.Collections;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
index 9553dfaa6597a5638aa1cf35bcb02791d0fb1ef6..24c36cda115dc399e274db4ad42f08c4ce4c9157 100644 (file)
@@ -24,7 +24,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.scanner.ProjectAnalysisInfo;
-import org.sonar.scanner.issue.DefaultFilterableIssue;
 import org.sonar.scanner.protocol.Constants.Severity;
 import org.sonar.scanner.protocol.output.ScannerReport.Issue;
 import org.sonar.scanner.protocol.output.ScannerReport.TextRange;
index c6c7f1b7aec5bee11ae3738e31fbde4ef2725e46..c5f606f77394e8735c53167b11a55acb724785a7 100644 (file)
  */
 package org.sonar.scanner.issue;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
+import com.google.common.collect.ImmutableList;
+import java.util.LinkedList;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.sonar.api.batch.rule.Rule;
+import org.sonar.api.batch.rule.Rules;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.batch.bootstrapper.IssueListener;
 import org.sonar.batch.bootstrapper.IssueListener.Issue;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Mock;
-import org.sonar.api.batch.rule.Rules;
-import org.sonar.scanner.issue.DefaultIssueCallback;
-import org.sonar.scanner.issue.IssueCache;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
-import org.junit.Before;
-import com.google.common.collect.ImmutableList;
-
-import java.util.LinkedList;
-import java.util.List;
 
-import static org.mockito.Matchers.any;
 import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Test;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class DefaultIssueCallbackTest {
   @Mock
index d91fa2ed0e43ef0639ca676a8b0e82f2a8cfb5c1..b712077289639052df87759dee0784e64357a63a 100644 (file)
  */
 package org.sonar.scanner.issue;
 
-import org.sonar.api.scan.issue.filter.FilterableIssue;
-
 import org.junit.Test;
+import org.sonar.api.scan.issue.filter.FilterableIssue;
 import org.sonar.api.scan.issue.filter.IssueFilter;
 import org.sonar.api.scan.issue.filter.IssueFilterChain;
-import org.sonar.scanner.issue.DefaultIssueFilterChain;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
index 0a2b6be76ffe55288a1649df7920845669c0fab2..9ecef3b1f2197dc7013ac48aa1244ef7f661b7f9 100644 (file)
 package org.sonar.scanner.issue;
 
 import com.google.common.collect.Lists;
+import java.util.Arrays;
+import java.util.List;
 import org.junit.Test;
 import org.sonar.api.issue.Issue;
-import org.sonar.core.issue.DefaultIssue;
-import org.sonar.scanner.issue.DefaultProjectIssues;
-import org.sonar.scanner.issue.IssueCache;
-import org.sonar.scanner.issue.tracking.TrackedIssue;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.Severity;
-
-import java.util.Arrays;
-import java.util.List;
+import org.sonar.core.issue.DefaultIssue;
+import org.sonar.scanner.issue.tracking.TrackedIssue;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index abe6fcf2deeb788af6eeae91a666b718e26aedd1..19585cbab0866817e9e9c3316de27730c5af538a 100644 (file)
@@ -25,7 +25,6 @@ import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.scanner.ProjectAnalysisInfo;
-import org.sonar.scanner.issue.DeprecatedIssueAdapterForFilter;
 import org.sonar.scanner.protocol.Constants.Severity;
 import org.sonar.scanner.protocol.output.ScannerReport.TextRange;
 
index 4297d6e3a4d15246cc39aaaf4af772ff088679eb..41908eed508dfd9afd763493b0297aa4f336748b 100644 (file)
@@ -23,7 +23,6 @@ import org.junit.Test;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.issue.batch.IssueFilter;
 import org.sonar.api.issue.batch.IssueFilterChain;
-import org.sonar.scanner.issue.DeprecatedIssueFilterChain;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
index c180e8e1da60b84d86f25d58080872549aeecb8d..8bbdee15b5961dc3e41d0a0202915fbdbebe37bf 100644 (file)
@@ -33,8 +33,6 @@ import org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.utils.MessageException;
-import org.sonar.scanner.issue.IssueFilters;
-import org.sonar.scanner.issue.ModuleIssues;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.report.ReportPublisher;
 
index 8d7fdead7178e70da5f610bbb53b8cab65c66511..5b7396c959c84d7c3e52ed64b6447463a040e3f2 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Date;
 import org.junit.Test;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.scanner.issue.TrackedIssueAdapter;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
 
 import static org.assertj.core.api.Assertions.assertThat;
index d3089b298fa56e4966aab2ec13ad1237b81efe3d..a0aae458ed906910b280b7f1db23fc988c11f7d7 100644 (file)
  */
 package org.sonar.scanner.issue.ignore;
 
-import org.sonar.api.scan.issue.filter.FilterableIssue;
-
 import com.google.common.collect.ImmutableList;
 import org.junit.Before;
 import org.junit.Test;
-import org.sonar.api.scan.issue.filter.IssueFilterChain;
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.rule.RuleKey;
+import org.sonar.api.scan.issue.filter.FilterableIssue;
+import org.sonar.api.scan.issue.filter.IssueFilterChain;
 import org.sonar.api.utils.WildcardPattern;
-import org.sonar.scanner.issue.ignore.EnforceIssuesFilter;
 import org.sonar.scanner.issue.ignore.pattern.IssueInclusionPatternInitializer;
 import org.sonar.scanner.issue.ignore.pattern.IssuePattern;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
index ccf1ed016c6de63d0597e3c247c72f368ae19d47..5dc8a09e51135ce292ec1b08e6d545fc33040146 100644 (file)
  */
 package org.sonar.scanner.issue.ignore;
 
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.scan.issue.filter.FilterableIssue;
-
 import org.junit.Before;
 import org.junit.Test;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.api.scan.issue.filter.FilterableIssue;
 import org.sonar.api.scan.issue.filter.IssueFilterChain;
-import org.sonar.scanner.issue.ignore.IgnoreIssuesFilter;
 import org.sonar.scanner.issue.ignore.pattern.IssuePattern;
 import org.sonar.scanner.issue.ignore.pattern.PatternMatcher;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public class IgnoreIssuesFilterTest {
index 7fadd593235e7aa23d017e9ae5592ae403fc8717..3a8e6ca8b3c91a0edacbce5c9ec4ab559d03bf4d 100644 (file)
@@ -22,15 +22,14 @@ package org.sonar.scanner.issue.ignore.pattern;
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.core.config.IssueExclusionProperties;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class IssueExclusionPatternInitializerTest {
   private IssueExclusionPatternInitializer patternsInitializer;
-  private Settings settings;
+  private MapSettings settings;
 
   @Before
   public void init() {
@@ -39,7 +38,7 @@ public class IssueExclusionPatternInitializerTest {
 
   @Test
   public void testNoConfiguration() {
-    patternsInitializer = new IssueExclusionPatternInitializer(settings);
+    patternsInitializer = new IssueExclusionPatternInitializer(settings.asConfig());
     assertThat(patternsInitializer.hasConfiguredPatterns()).isFalse();
     assertThat(patternsInitializer.getMulticriteriaPatterns().size()).isEqualTo(0);
   }
@@ -49,7 +48,7 @@ public class IssueExclusionPatternInitializerTest {
     settings.setProperty("sonar.issue.ignore" + ".multicriteria", "1");
     settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "resourceKey", "");
     settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "ruleKey", "*");
-    patternsInitializer = new IssueExclusionPatternInitializer(settings);
+    patternsInitializer = new IssueExclusionPatternInitializer(settings.asConfig());
   }
 
   @Test(expected = IllegalStateException.class)
@@ -57,7 +56,7 @@ public class IssueExclusionPatternInitializerTest {
     settings.setProperty("sonar.issue.ignore" + ".multicriteria", "1");
     settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "resourceKey", "*");
     settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "ruleKey", "");
-    patternsInitializer = new IssueExclusionPatternInitializer(settings);
+    patternsInitializer = new IssueExclusionPatternInitializer(settings.asConfig());
   }
 
   @Test
@@ -69,7 +68,7 @@ public class IssueExclusionPatternInitializerTest {
     settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".2." + IssueExclusionProperties.END_BLOCK_REGEXP, "// FOO-ON");
     settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".3." + IssueExclusionProperties.BEGIN_BLOCK_REGEXP, "// IGNORE-TO-EOF");
     settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".3." + IssueExclusionProperties.END_BLOCK_REGEXP, "");
-    patternsInitializer = new IssueExclusionPatternInitializer(settings);
+    patternsInitializer = new IssueExclusionPatternInitializer(settings.asConfig());
 
     assertThat(patternsInitializer.hasConfiguredPatterns()).isTrue();
     assertThat(patternsInitializer.hasFileContentPattern()).isTrue();
@@ -84,7 +83,7 @@ public class IssueExclusionPatternInitializerTest {
     settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY, "1");
     settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionProperties.BEGIN_BLOCK_REGEXP, "");
     settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionProperties.END_BLOCK_REGEXP, "// SONAR-ON");
-    patternsInitializer = new IssueExclusionPatternInitializer(settings);
+    patternsInitializer = new IssueExclusionPatternInitializer(settings.asConfig());
   }
 
   @Test
@@ -92,7 +91,7 @@ public class IssueExclusionPatternInitializerTest {
     settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY, "1,2");
     settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY + ".1." + IssueExclusionProperties.FILE_REGEXP, "@SONAR-IGNORE-ALL");
     settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY + ".2." + IssueExclusionProperties.FILE_REGEXP, "//FOO-IGNORE-ALL");
-    patternsInitializer = new IssueExclusionPatternInitializer(settings);
+    patternsInitializer = new IssueExclusionPatternInitializer(settings.asConfig());
 
     assertThat(patternsInitializer.hasConfiguredPatterns()).isTrue();
     assertThat(patternsInitializer.hasFileContentPattern()).isTrue();
@@ -106,6 +105,6 @@ public class IssueExclusionPatternInitializerTest {
   public void shouldLogInvalidAllFilePattern() {
     settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY, "1");
     settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY + ".1." + IssueExclusionProperties.FILE_REGEXP, "");
-    patternsInitializer = new IssueExclusionPatternInitializer(settings);
+    patternsInitializer = new IssueExclusionPatternInitializer(settings.asConfig());
   }
 }
index 6feecb2863747240726243657f33e0ea0f3aa3c6..a8522146039870f68100ee5ab0cadc2d47b1ea04 100644 (file)
@@ -22,8 +22,7 @@ package org.sonar.scanner.issue.ignore.pattern;
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.core.config.IssueExclusionProperties;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -31,12 +30,12 @@ import static org.assertj.core.api.Assertions.assertThat;
 public class IssueInclusionPatternInitializerTest {
 
   private IssueInclusionPatternInitializer patternsInitializer;
-  private Settings settings;
+  private MapSettings settings;
 
   @Before
   public void init() {
     settings = new MapSettings(new PropertyDefinitions(IssueExclusionProperties.all()));
-    patternsInitializer = new IssueInclusionPatternInitializer(settings);
+    patternsInitializer = new IssueInclusionPatternInitializer(settings.asConfig());
   }
 
   @Test
index d6c6f778b5357a324bc5bce7d9f7251c1ed516a7..a20dcd7c81a61a07573fb6517b0678e536c99ef0 100644 (file)
  */
 package org.sonar.scanner.issue.ignore.pattern;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
 import org.junit.Test;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rules.Rule;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
 public class IssuePatternTest {
 
   @Test
index 0d610f1ffeb68c995d442a673cf89687bc70fe6d..45a2a5f74afd692c0d004f98f19a080ed3f3ee17 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.issue.ignore.pattern;
 
 import org.junit.Test;
-import org.sonar.scanner.issue.ignore.pattern.LineRange;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index f4ca8b9c745750f2f69ba6202d1de05c4274391e..3d4bfa3ab846548af3f14c93ab92b3a85c54ec45 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.issue.ignore.pattern;
 
 import org.junit.Test;
-import org.sonar.scanner.issue.ignore.pattern.PatternDecoder;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index ea9cdb5606c6a01b5373efc7aed3906641bbd82e..a474e349f2ac50644c8a33782751d6bc662af537 100644 (file)
  */
 package org.sonar.scanner.issue.ignore.pattern;
 
-import org.sonar.scanner.issue.ignore.pattern.IssuePattern;
-import org.sonar.scanner.issue.ignore.pattern.LineRange;
-import org.sonar.scanner.issue.ignore.pattern.PatternMatcher;
 import com.google.common.collect.Sets;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.rules.Rule;
-
 import java.util.Collections;
 import java.util.Set;
-
 import javax.annotation.Nullable;
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.rules.Rule;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 638e504b6ce6a962756b6162eeb81d2ff00d538a..2e15da1999c1e5523dc05a8e73e1c659f503cd12 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.scanner.issue.ignore.scanner;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
-
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
index e3a322e69384cf78c971296e250ee9ba3fa30560..f90c384bcb61a11257f055ff3a9d3f328f601d12 100644 (file)
 package org.sonar.scanner.issue.ignore.scanner;
 
 import com.google.common.io.Resources;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.sonar.api.batch.fs.internal.FileMetadata;
-import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer;
-import org.sonar.scanner.issue.ignore.pattern.LineRange;
-import org.sonar.scanner.issue.ignore.pattern.PatternMatcher;
-import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsRegexpScanner;
-import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader.DoubleRegexpMatcher;
-
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.nio.file.Files;
@@ -42,6 +31,15 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.regex.Pattern;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.sonar.api.batch.fs.internal.FileMetadata;
+import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer;
+import org.sonar.scanner.issue.ignore.pattern.LineRange;
+import org.sonar.scanner.issue.ignore.pattern.PatternMatcher;
+import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader.DoubleRegexpMatcher;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.mockito.Mockito.times;
index 67f5076556b27e93c261f14bbe7554c461c99a27..2efd24dc7db02ef764f197f5eeb60d8e4f2dbfa5 100644 (file)
@@ -20,8 +20,6 @@
 package org.sonar.scanner.issue.tracking;
 
 import org.junit.Test;
-import org.sonar.scanner.issue.tracking.FileHashes;
-import org.sonar.scanner.issue.tracking.RollingFileHashes;
 
 import static org.apache.commons.codec.digest.DigestUtils.md5Hex;
 import static org.assertj.core.api.Assertions.assertThat;
index b0465a5ce40415bc52b569145a2ad65fe6b46609..0cf540f0b7af27b8193c6449008b9d8fea57ca65 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.scanner.issue.tracking;
 import java.io.File;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
-
 import org.apache.commons.io.FileUtils;
 import org.junit.Before;
 import org.junit.Rule;
index 7fc7146c62266621bf5853f490a60e6c4eedf9ef..cd24905d49345b64bf53569f2d7663ac3ce98444 100644 (file)
  */
 package org.sonar.scanner.issue.tracking;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import org.junit.Test;
-import org.sonar.scanner.issue.tracking.FileHashes;
-import org.sonar.scanner.issue.tracking.TrackedIssue;
+
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class TrackedIssueTest {
   @Test
index 5f980c04ade6dd248dbb47ef7595dae09326c1e3..443f4cb09fb6e135d11c0289ea466c63eab1f867 100644 (file)
  */
 package org.sonar.scanner.mediumtest;
 
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.stream.Collectors;
-
 import org.sonar.batch.bootstrapper.LogOutput;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.HashMultimap;
 
 public class LogOutputRecorder implements LogOutput {
   private final Multimap<String, String> recordedByLevel = HashMultimap.create();
index f7860cd3db0a7ff594f29ebb7ef231015db1e6b2..e369aefeb05094843c8bd35ee35edd6c8d4fc8c7 100644 (file)
 package org.sonar.scanner.mediumtest.fs;
 
 import com.google.common.collect.ImmutableMap;
-
+import java.io.File;
+import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Random;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.junit.After;
@@ -46,9 +46,6 @@ import org.sonar.scanner.mediumtest.TaskResult;
 import org.sonar.xoo.XooPlugin;
 import org.sonar.xoo.rule.XooRulesDefinition;
 
-import java.io.File;
-import java.io.IOException;
-
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class FileSystemMediumTest {
index 52a99d7408a6126b63bfb715e6fc2d7feaa02327..721e4a7af6b52735ce18a29ab252334e5f2894ce 100644 (file)
  */
 package org.sonar.scanner.mediumtest.fs;
 
-import org.junit.rules.ExpectedException;
-
+import java.io.File;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.filefilter.FileFilterUtils;
-import java.io.File;
-
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Test;
 import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.mediumtest.issuesmode.IssueModeAndReportsMediumTest;
index 3b9c0bc4dfe51dfed9292decf67f9811d120d875..ea16deec3cc51c103ec3d9030ea104d35d8e7a6f 100644 (file)
@@ -31,11 +31,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.batch.bootstrap.ProjectBuilder;
@@ -48,6 +43,9 @@ import org.sonar.xoo.rule.XooRulesDefinition;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.tuple;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
 
 public class ProjectBuilderMediumTest {
 
index 96bf0996b82b9bfe28227b03c1e1e61e844f42f7..7eb43a3b100b01244a4ae5ac4ff7e0af74ab1edd 100644 (file)
  */
 package org.sonar.scanner.mediumtest.issues;
 
-import org.junit.rules.TemporaryFolder;
+import com.google.common.collect.ImmutableMap;
+import java.io.File;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import org.apache.commons.io.FileUtils;
 import org.junit.After;
 import org.junit.Before;
-import com.google.common.collect.ImmutableMap;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 import org.sonar.api.CoreProperties;
 import org.sonar.batch.bootstrapper.IssueListener;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.mediumtest.TaskResult;
 import org.sonar.xoo.XooPlugin;
 import org.sonar.xoo.rule.XooRulesDefinition;
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-import java.io.File;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 2379b4e081ada68648df73d7ff0e53351760053d..84434b7f8cb6879267c02f3c0e4afb6b26606491 100644 (file)
  */
 package org.sonar.scanner.mediumtest.issuesmode;
 
-import org.apache.commons.io.filefilter.FileFilterUtils;
-import org.apache.commons.io.FileUtils;
-import org.sonar.xoo.rule.XooRulesDefinition;
 import com.google.common.collect.ImmutableMap;
+import java.io.File;
+import java.util.Date;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.FileFilterUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -30,13 +31,11 @@ import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.utils.log.LogTester;
-import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
+import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.mediumtest.TaskResult;
 import org.sonar.xoo.XooPlugin;
-
-import java.io.File;
-import java.util.Date;
+import org.sonar.xoo.rule.XooRulesDefinition;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index d53074e04631ab1d239f01b46b21615053262032..6eb4283c0cf305925d72657c67415d556ae86b8e 100644 (file)
@@ -40,8 +40,8 @@ import org.sonar.api.CoreProperties;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.batch.bootstrapper.IssueListener;
-import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
+import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.mediumtest.TaskResult;
 import org.sonar.scanner.protocol.Constants.Severity;
 import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue;
index 8fcf882a5e0b18cca05c4771f3ef11bde1e0430e..4a81c797e21225056b68034c55cd00c595179ac2 100644 (file)
  */
 package org.sonar.scanner.mediumtest.issuesmode;
 
+import com.google.common.collect.ImmutableMap;
+import java.io.File;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.filefilter.FileFilterUtils;
-
-import java.io.File;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.google.common.collect.ImmutableMap;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -39,6 +35,8 @@ import org.sonar.scanner.mediumtest.TaskResult;
 import org.sonar.xoo.XooPlugin;
 import org.sonar.xoo.rule.XooRulesDefinition;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 public class NoPreviousAnalysisTest {
   @Rule
   public TemporaryFolder temp = new TemporaryFolder();
index dafd2fedfb27d21217dea3773c36aeeea656eccc..c0043f1ef24d1ddb52d2f95c1d77edb5775090e6 100644 (file)
@@ -49,10 +49,10 @@ import org.junit.runners.Parameterized.Parameters;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.fs.internal.FileMetadata;
 import org.sonar.api.utils.log.LogTester;
-import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
-import org.sonar.scanner.mediumtest.TaskResult;
+import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.mediumtest.ScannerMediumTester.TaskBuilder;
+import org.sonar.scanner.mediumtest.TaskResult;
 import org.sonar.scanner.protocol.Constants.Severity;
 import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue;
 import org.sonar.scanner.repository.FileData;
index bea4f44073558a0f74395eb18610bb1309224cf9..dc411eb2e088d67f000aefc683d00751daba04b5 100644 (file)
@@ -24,7 +24,6 @@ import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.nio.charset.StandardCharsets;
-
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.io.FileUtils;
 import org.assertj.core.util.Files;
@@ -40,9 +39,9 @@ import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.mediumtest.ScannerMediumTester.TaskBuilder;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReport.Changesets.Changeset;
-import org.sonar.scanner.repository.FileData;
 import org.sonar.scanner.protocol.output.ScannerReport.Component;
 import org.sonar.scanner.protocol.output.ScannerReportReader;
+import org.sonar.scanner.repository.FileData;
 import org.sonar.xoo.XooPlugin;
 import org.sonar.xoo.rule.XooRulesDefinition;
 
index 8ed5309684ab4080abcc2e8d38b93de93851cb84..a949587caa11a6a4052c2862395a93cc6ac02196 100644 (file)
  */
 package org.sonar.scanner.mediumtest.tests;
 
-import org.hamcrest.Description;
-
-import org.hamcrest.TypeSafeMatcher;
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
 import com.google.common.collect.ImmutableMap;
+import java.io.File;
+import java.io.IOException;
 import org.apache.commons.io.FileUtils;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.mediumtest.TaskResult;
 import org.sonar.xoo.XooPlugin;
 
-import java.io.File;
-import java.io.IOException;
-
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class CoveragePerTestMediumTest {
index 06f9bff6afe6b28ce0c009f8b953e162fbcadbeb..488d9694763991421b1242e8cf8c7cee608c64ce 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.scanner.phases;
 
+import java.util.Arrays;
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.batch.PostJob;
@@ -27,14 +28,12 @@ import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.resources.Project;
 import org.sonar.scanner.bootstrap.ScannerExtensionDictionnary;
 import org.sonar.scanner.events.EventBus;
-import org.sonar.scanner.phases.PostJobsExecutor;
-import java.util.Arrays;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.any;
 
 public class PostJobsExecutorTest {
   PostJobsExecutor executor;
index b7431b1ac7d73c894ff3214fe8e18d3575c18135..5afcb9ee1f5a16628443f407180a7008078f7bbc 100644 (file)
@@ -21,7 +21,9 @@ package org.sonar.scanner.phases;
 
 import java.io.IOException;
 import java.util.Collections;
-import org.junit.*;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.batch.Sensor;
 import org.sonar.api.batch.SensorContext;
@@ -33,7 +35,10 @@ import org.sonar.scanner.events.EventBus;
 import org.sonar.scanner.sensor.SensorStrategy;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class SensorsExecutorTest {
   @Rule
index 47a0922847187e03048f089033d1be5d3a8c44ea..2af9a10feabe09ed195cd0ee2752799d70a56867 100644 (file)
@@ -22,8 +22,8 @@ package org.sonar.scanner.platform;
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.SonarQubeSide;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.internal.SonarRuntimeImpl;
 import org.sonar.api.utils.Version;
 import org.sonar.scanner.bootstrap.ScannerWsClient;
index 64a87b2295d508fa3215156c13c9354fc04bf4ac..47ceca948880a80cd1eeb794e7b0f310bed92bd9 100644 (file)
@@ -29,8 +29,7 @@ import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.postjob.issue.PostJobIssue;
 import org.sonar.api.batch.rule.Severity;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.scan.filesystem.PathResolver;
 import org.sonar.scanner.issue.IssueCache;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
@@ -48,7 +47,7 @@ public class DefaultPostJobContextTest {
   private IssueCache issueCache;
   private InputComponentStore componentStore;
   private DefaultPostJobContext context;
-  private Settings settings;
+  private MapSettings settings;
   private AnalysisMode analysisMode;
 
   @Before
@@ -57,7 +56,7 @@ public class DefaultPostJobContextTest {
     componentStore = new InputComponentStore(new PathResolver());
     settings = new MapSettings();
     analysisMode = mock(AnalysisMode.class);
-    context = new DefaultPostJobContext(settings, issueCache, componentStore, analysisMode);
+    context = new DefaultPostJobContext(settings.asConfig(), settings, issueCache, componentStore, analysisMode);
   }
 
   @Test
index b23fdc402c596af4f0f6ac55a027f456257d786b..85f62407d343254917da0c308c1c808497f06398 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 68804f5891eb5c7ca95f3d238092de1673b502b5..a3d55dfa855518e4a34a47ffc586bbc113a36e67 100644 (file)
  */
 package org.sonar.scanner.profiling;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
+import com.google.common.collect.Maps;
 import java.util.List;
 import java.util.Map;
-
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -49,7 +47,7 @@ import org.sonar.api.utils.System2;
 import org.sonar.scanner.bootstrap.GlobalProperties;
 import org.sonar.scanner.events.BatchStepEvent;
 
-import com.google.common.collect.Maps;
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class PhasesSumUpTimeProfilerTest {
 
index 6af4cda0881bd3c3b93ff25ffb6a4c51eb93511f..b7d8a0d6328527c1a84e329271d06698434979f6 100644 (file)
@@ -34,7 +34,6 @@ import org.sonar.scanner.protocol.Constants;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
-import org.sonar.scanner.report.ActiveRulesPublisher;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index cce73c7dc8d69263332cd17a8206d0a434bbea7a..3c65a91b5988bddee1c1495e4d6d80ae63015b70 100644 (file)
@@ -35,7 +35,7 @@ import org.sonar.api.utils.System2;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.core.platform.PluginInfo;
-import org.sonar.scanner.bootstrap.GlobalSettings;
+import org.sonar.scanner.bootstrap.GlobalConfiguration;
 import org.sonar.scanner.bootstrap.ScannerPluginRepository;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
 import org.sonar.scanner.repository.ProjectRepositories;
@@ -64,7 +64,7 @@ public class AnalysisContextReportPublisherTest {
   private AnalysisMode analysisMode = mock(AnalysisMode.class);
   private System2 system2;
   private ProjectRepositories projectRepos;
-  private GlobalSettings globalSettings;
+  private GlobalConfiguration globalSettings;
 
   @Before
   public void prepare() throws Exception {
@@ -72,7 +72,7 @@ public class AnalysisContextReportPublisherTest {
     system2 = mock(System2.class);
     when(system2.properties()).thenReturn(new Properties());
     projectRepos = mock(ProjectRepositories.class);
-    globalSettings = mock(GlobalSettings.class);
+    globalSettings = mock(GlobalConfiguration.class);
     publisher = new AnalysisContextReportPublisher(analysisMode, pluginRepo, system2, projectRepos, globalSettings);
   }
 
index 60a85ab6d22bcec0855fdc1fec812410f718c135..2f1a13d1d949473e12c71d355447195a0486032b 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.scanner.report;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
-
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -41,10 +40,9 @@ import org.sonar.scanner.protocol.output.FileStructure;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReport.Component;
 import org.sonar.scanner.protocol.output.ScannerReport.ComponentLink.ComponentLinkType;
-import org.sonar.scanner.report.ComponentsPublisher;
-import org.sonar.scanner.scan.DefaultComponentTree;
 import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
+import org.sonar.scanner.scan.DefaultComponentTree;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index 4760295a4c9af5c460c7a174b7a9c4398bc983f5..a767182c6a73cb4c08d9bcc84e592b286b7443b3 100644 (file)
@@ -21,14 +21,16 @@ package org.sonar.scanner.report;
 
 import com.google.common.collect.Lists;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import org.hamcrest.Description;
 import org.hamcrest.TypeSafeMatcher;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.scanner.config.DefaultConfiguration;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
 import org.sonar.scanner.repository.ContextPropertiesCache;
@@ -37,6 +39,7 @@ import static java.util.Collections.emptyList;
 import static org.mockito.Matchers.argThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public class ContextPropertiesPublisherTest {
   @Rule
@@ -44,8 +47,14 @@ public class ContextPropertiesPublisherTest {
 
   private ScannerReportWriter writer = mock(ScannerReportWriter.class);
   private ContextPropertiesCache cache = new ContextPropertiesCache();
-  private Settings settings = new MapSettings();
-  private ContextPropertiesPublisher underTest = new ContextPropertiesPublisher(cache, settings);
+  private DefaultConfiguration config = mock(DefaultConfiguration.class);
+  private Map<String, String> props = new HashMap<>();
+  private ContextPropertiesPublisher underTest = new ContextPropertiesPublisher(cache, config);
+
+  @Before
+  public void prepareMock() {
+    when(config.getProperties()).thenReturn(props);
+  }
 
   @Test
   public void publish_writes_properties_to_report() {
@@ -69,9 +78,9 @@ public class ContextPropertiesPublisherTest {
 
   @Test
   public void publish_settings_prefixed_with_sonar_analysis_for_webhooks() {
-    settings.setProperty("foo", "should not be exported");
-    settings.setProperty("sonar.analysis.revision", "ab45b3");
-    settings.setProperty("sonar.analysis.build.number", "B123");
+    props.put("foo", "should not be exported");
+    props.put("sonar.analysis.revision", "ab45b3");
+    props.put("sonar.analysis.build.number", "B123");
 
     underTest.publish(writer);
 
index a8e0795f18cc3c3ca209e68abf8714f0828cb764..e59cbd47ee48ec2ae3bf5e4106a1e706cd76b92b 100644 (file)
@@ -27,11 +27,10 @@ import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.scanner.ProjectAnalysisInfo;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReportReader;
@@ -53,7 +52,7 @@ public class MetadataPublisherTest {
   private ProjectDefinition projectDef;
   private DefaultInputModule rootModule;
   private MetadataPublisher underTest;
-  private Settings settings;
+  private MapSettings settings;
   private ModuleQProfiles qProfiles;
   private ProjectAnalysisInfo projectAnalysisInfo;
   private InputModuleHierarchy inputModuleHierarchy;
@@ -68,7 +67,7 @@ public class MetadataPublisherTest {
     when(inputModuleHierarchy.root()).thenReturn(rootModule);
     settings = new MapSettings();
     qProfiles = mock(ModuleQProfiles.class);
-    underTest = new MetadataPublisher(projectAnalysisInfo, inputModuleHierarchy, settings, qProfiles);
+    underTest = new MetadataPublisher(projectAnalysisInfo, inputModuleHierarchy, settings.asConfig(), qProfiles);
   }
 
   @Test
index a47550ba72156a4ecd1013816be2e8b69a34d0a6..7b93925349ebe8691ed9a721d7c9a67ed562dfbc 100644 (file)
@@ -34,9 +34,8 @@ import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.platform.Server;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.TempFolder;
@@ -71,7 +70,7 @@ public class ReportPublisherTest {
   public ExpectedException exception = ExpectedException.none();
 
   DefaultAnalysisMode mode = mock(DefaultAnalysisMode.class);
-  Settings settings = new MapSettings(new PropertyDefinitions(CorePropertyDefinitions.all()));
+  MapSettings settings = new MapSettings(new PropertyDefinitions(CorePropertyDefinitions.all()));
   ScannerWsClient wsClient;
   Server server = mock(Server.class);
   ImmutableProjectReactor reactor = mock(ImmutableProjectReactor.class);
@@ -89,7 +88,7 @@ public class ReportPublisherTest {
 
   @Test
   public void log_and_dump_information_about_report_uploading() throws IOException {
-    ReportPublisher underTest = new ReportPublisher(settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
+    ReportPublisher underTest = new ReportPublisher(settings.asConfig(), wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
     settings.setProperty(CoreProperties.PROJECT_ORGANIZATION_PROPERTY, "MyOrg");
 
     underTest.logSuccess("TASK-123");
@@ -112,7 +111,7 @@ public class ReportPublisherTest {
 
   @Test
   public void parse_upload_error_message() throws IOException {
-    ReportPublisher underTest = new ReportPublisher(settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
+    ReportPublisher underTest = new ReportPublisher(settings.asConfig(), wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
     HttpException ex = new HttpException("url", 404, "{\"errors\":[{\"msg\":\"Organization with key 'MyOrg' does not exist\"}]}");
     WsResponse response = mock(WsResponse.class);
     when(response.failIfNotSuccessful()).thenThrow(ex);
@@ -126,7 +125,7 @@ public class ReportPublisherTest {
   @Test
   public void log_public_url_if_defined() throws IOException {
     when(server.getPublicRootUrl()).thenReturn("https://publicserver/sonarqube");
-    ReportPublisher underTest = new ReportPublisher(settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
+    ReportPublisher underTest = new ReportPublisher(settings.asConfig(), wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
 
     underTest.logSuccess("TASK-123");
 
@@ -147,7 +146,7 @@ public class ReportPublisherTest {
   @Test
   public void fail_if_public_url_malformed() throws IOException {
     when(server.getPublicRootUrl()).thenReturn("invalid");
-    ReportPublisher underTest = new ReportPublisher(settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
+    ReportPublisher underTest = new ReportPublisher(settings.asConfig(), wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
 
     exception.expect(MessageException.class);
     exception.expectMessage("Failed to parse public URL set in SonarQube server: invalid");
@@ -156,7 +155,7 @@ public class ReportPublisherTest {
 
   @Test
   public void log_but_not_dump_information_when_report_is_not_uploaded() {
-    ReportPublisher underTest = new ReportPublisher(settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
+    ReportPublisher underTest = new ReportPublisher(settings.asConfig(), wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
 
     underTest.logSuccess(/* report not uploaded, no server task */null);
 
@@ -173,7 +172,7 @@ public class ReportPublisherTest {
     settings.setProperty("sonar.batch.keepReport", true);
     Path reportDir = temp.getRoot().toPath().resolve("batch-report");
     Files.createDirectory(reportDir);
-    ReportPublisher underTest = new ReportPublisher(settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
+    ReportPublisher underTest = new ReportPublisher(settings.asConfig(), wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
 
     underTest.start();
     underTest.stop();
@@ -184,7 +183,7 @@ public class ReportPublisherTest {
   public void should_delete_report_by_default() throws IOException {
     Path reportDir = temp.getRoot().toPath().resolve("batch-report");
     Files.createDirectory(reportDir);
-    ReportPublisher job = new ReportPublisher(settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
+    ReportPublisher job = new ReportPublisher(settings.asConfig(), wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
 
     job.start();
     job.stop();
@@ -193,7 +192,7 @@ public class ReportPublisherTest {
 
   @Test
   public void test_ws_parameters() throws Exception {
-    ReportPublisher underTest = new ReportPublisher(settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
+    ReportPublisher underTest = new ReportPublisher(settings.asConfig(), wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
 
     settings.setProperty(CoreProperties.PROJECT_ORGANIZATION_PROPERTY, "MyOrg");
 
index 7a2982e77f1962cc08b871196f1f4ae8a71a8282..c02c6d05a40b22dad97b2cdf8b0aac944e583ee6 100644 (file)
@@ -26,8 +26,7 @@ import java.io.InputStream;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.MessageException;
 import org.sonar.scanner.WsTestUtil;
 import org.sonar.scanner.bootstrap.ScannerWsClient;
@@ -42,8 +41,8 @@ public class DefaultQualityProfileLoaderTest {
   public ExpectedException exception = ExpectedException.none();
 
   private ScannerWsClient wsClient = mock(ScannerWsClient.class);
-  private Settings settings = new MapSettings();
-  private DefaultQualityProfileLoader underTest = new DefaultQualityProfileLoader(settings, wsClient);
+  private MapSettings settings = new MapSettings();
+  private DefaultQualityProfileLoader underTest = new DefaultQualityProfileLoader(settings.asConfig(), wsClient);
 
   @Test
   public void load_gets_profiles_for_specified_project_and_profile_name() throws IOException {
index c49c76423fa93f941e158d13bb1de899e7ebfb8d..2db06e5ad6805fef9f60d1ab419bb422e2a9d872 100644 (file)
  */
 package org.sonar.scanner.repository;
 
-import java.util.Date;
-import com.google.common.collect.Table;
 import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.Table;
+import java.util.Date;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.sonar.api.batch.bootstrap.ProjectKey;
 import org.sonar.scanner.analysis.DefaultAnalysisMode;
-import org.sonar.scanner.repository.FileData;
-import org.sonar.scanner.repository.ProjectRepositories;
-import org.sonar.scanner.repository.ProjectRepositoriesLoader;
-import org.sonar.scanner.repository.ProjectRepositoriesProvider;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Matchers.eq;
index a36abe70f4a31f8baa6d19b9e3bcf0338448b304..aaea7dde87770610c4f650c8304d90730f5c149b 100644 (file)
@@ -31,9 +31,6 @@ import org.sonar.api.batch.bootstrap.ProjectKey;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.scanner.analysis.AnalysisProperties;
-import org.sonar.scanner.repository.ProjectRepositories;
-import org.sonar.scanner.repository.QualityProfileLoader;
-import org.sonar.scanner.repository.QualityProfileProvider;
 import org.sonar.scanner.rule.ModuleQProfiles;
 import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile;
 
index 18a6fa9ec78d2829115088a801a364c357f27442..d6ff0c61f3e59cc3d74b1187568fd0b1ae0e2c77 100644 (file)
@@ -28,10 +28,6 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.sonar.api.batch.rule.ActiveRules;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.scanner.rule.ActiveRulesProvider;
-import org.sonar.scanner.rule.DefaultActiveRulesLoader;
-import org.sonar.scanner.rule.LoadedActiveRule;
-import org.sonar.scanner.rule.ModuleQProfiles;
 import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile;
 
 import static org.assertj.core.api.Assertions.assertThat;
index c605cf7a54d8ba65f4ecf3085b5139f6e38e5aad..a21efc17c55bdca5fc402b54c64dee2628266e7e 100644 (file)
@@ -20,7 +20,8 @@
 package org.sonar.scanner.rule;
 
 import org.junit.Test;
-import static org.assertj.core.api.Assertions.*;
+
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class QProfileTest {
   @Test
index bfb438c3fb6abb51bf8063fcaec76f2623a9914f..f68303521a5d7a928f9f2d3756e6cd581d6f6d27 100644 (file)
@@ -27,8 +27,7 @@ import org.junit.rules.TemporaryFolder;
 import org.slf4j.Logger;
 import org.sonar.api.batch.fs.internal.DefaultFileSystem;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.MessageException;
 
 import static org.mockito.Mockito.mock;
@@ -45,7 +44,7 @@ public class QProfileVerifierTest {
 
   private DefaultFileSystem fs;
   private ModuleQProfiles profiles;
-  private Settings settings = new MapSettings();
+  private MapSettings settings = new MapSettings();
 
   @Before
   public void before() throws Exception {
@@ -62,7 +61,7 @@ public class QProfileVerifierTest {
     fs.add(new TestInputFileBuilder("foo", "src/Bar.java").setLanguage("java").build());
     fs.add(new TestInputFileBuilder("foo", "src/Baz.cbl").setLanguage("cobol").build());
 
-    QProfileVerifier profileLogger = new QProfileVerifier(settings, fs, profiles);
+    QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), fs, profiles);
     Logger logger = mock(Logger.class);
     profileLogger.execute(logger);
 
@@ -76,7 +75,7 @@ public class QProfileVerifierTest {
 
     settings.setProperty("sonar.profile", "Unknown");
 
-    QProfileVerifier profileLogger = new QProfileVerifier(settings, fs, profiles);
+    QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), fs, profiles);
 
     thrown.expect(MessageException.class);
     thrown.expectMessage("sonar.profile was set to 'Unknown' but didn't match any profile for any language. Please check your configuration.");
@@ -88,7 +87,7 @@ public class QProfileVerifierTest {
   public void should_not_fail_if_no_language_on_project() {
     settings.setProperty("sonar.profile", "Unknown");
 
-    QProfileVerifier profileLogger = new QProfileVerifier(settings, fs, profiles);
+    QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), fs, profiles);
 
     profileLogger.execute();
 
@@ -100,7 +99,7 @@ public class QProfileVerifierTest {
 
     settings.setProperty("sonar.profile", "My Java profile");
 
-    QProfileVerifier profileLogger = new QProfileVerifier(settings, fs, profiles);
+    QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), fs, profiles);
 
     profileLogger.execute();
   }
index 371335095085edafcc495349c9700fc458ef4b63..097a1caf4b875fc410f42e1167a210df2c6cfb2d 100644 (file)
  */
 package org.sonar.scanner.rule;
 
-import org.sonar.api.batch.rule.internal.RulesBuilder;
-
-import org.sonar.api.batch.rule.Rules;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.sonar.api.batch.rule.Rules;
+import org.sonar.api.batch.rule.internal.RulesBuilder;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rules.RuleQuery;
-import org.sonar.scanner.rule.RuleFinderCompatibility;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 029f784717778a1335f6c371ddaaa866ae960bd2..8dff3fadef3250dc787334f6b254df47baec2b1c 100644 (file)
@@ -22,8 +22,7 @@ package org.sonar.scanner.rule;
 import java.util.Arrays;
 import org.junit.Test;
 import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.profiles.RulesProfile;
 import org.sonar.api.rule.RuleKey;
 
@@ -34,16 +33,16 @@ import static org.mockito.Mockito.when;
 
 public class RulesProfileProviderTest {
 
-  ModuleQProfiles qProfiles = mock(ModuleQProfiles.class);
-  Settings settings = new MapSettings();
-  RulesProfileProvider provider = new RulesProfileProvider();
+  private ModuleQProfiles qProfiles = mock(ModuleQProfiles.class);
+  private MapSettings settings = new MapSettings();
+  private RulesProfileProvider provider = new RulesProfileProvider();
 
   @Test
   public void merge_profiles() {
     QProfile qProfile = new QProfile().setKey("java-sw").setName("Sonar way").setLanguage("java");
     when(qProfiles.findAll()).thenReturn(Arrays.asList(qProfile));
 
-    RulesProfile profile = provider.provide(qProfiles, new ActiveRulesBuilder().build(), settings);
+    RulesProfile profile = provider.provide(qProfiles, new ActiveRulesBuilder().build(), settings.asConfig());
 
     // merge of all profiles
     assertThat(profile).isNotNull().isInstanceOf(RulesProfileWrapper.class);
@@ -65,7 +64,7 @@ public class RulesProfileProviderTest {
     QProfile qProfile = new QProfile().setKey("java-sw").setName("Sonar way").setLanguage("java");
     when(qProfiles.findByLanguage("java")).thenReturn(qProfile);
 
-    RulesProfile profile = provider.provide(qProfiles, new ActiveRulesBuilder().build(), settings);
+    RulesProfile profile = provider.provide(qProfiles, new ActiveRulesBuilder().build(), settings.asConfig());
 
     // no merge, directly the old hibernate profile
     assertThat(profile).isNotNull();
@@ -80,7 +79,7 @@ public class RulesProfileProviderTest {
     ActiveRulesBuilder activeRulesBuilder = new ActiveRulesBuilder();
     activeRulesBuilder.create(RuleKey.of("java", "S001")).setTemplateRuleKey("T001").setLanguage("java").activate();
 
-    RulesProfile profile = provider.provide(qProfiles, activeRulesBuilder.build(), settings);
+    RulesProfile profile = provider.provide(qProfiles, activeRulesBuilder.build(), settings.asConfig());
 
     assertThat(profile.getActiveRule("java", "S001").getRule().getTemplate().getKey()).isEqualTo("T001");
   }
index 38272dc68e791bda7773fec660fc8a4a01fb7b3e..918471d8e971c32463e4b47b9dca9b41e4bc5c4f 100644 (file)
 package org.sonar.scanner.rule;
 
 import com.google.common.collect.Lists;
+import org.junit.Test;
 import org.sonar.api.batch.rule.Rules;
-import org.sonar.scanner.rule.RulesLoader;
-import org.sonar.scanner.rule.RulesProvider;
+import org.sonarqube.ws.Rules.ListResponse.Rule;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.mock;
-import org.sonarqube.ws.Rules.ListResponse.Rule;
-import org.junit.Test;
+import static org.mockito.Mockito.when;
 
 public class RulesProviderTest {
   @Test
index 538a4b5087937e14a9dc0b9ffdec650059f1cfa6..e60b3303d4028060786b83ddf4b623beed3764bd 100644 (file)
  */
 package org.sonar.scanner.scan;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.batch.fs.internal.DefaultInputComponent;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 public class DefaultComponentTreeTest {
   private DefaultComponentTree tree;
 
index 4febcb225fecb7b15c197efb819749a9f66b933a..be0f77730389a939abad38bc378f46408fe5eadd 100644 (file)
  */
 package org.sonar.scanner.scan;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 public class DefaultInputModuleHierarchyTest {
   private DefaultInputModuleHierarchy moduleHierarchy;
 
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleSettingsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleSettingsTest.java
deleted file mode 100644 (file)
index 4b2b371..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.scanner.scan;
-
-import com.google.common.collect.HashBasedTable;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableTable;
-import com.google.common.collect.Table;
-import java.util.List;
-import java.util.Map;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.utils.MessageException;
-import org.sonar.scanner.analysis.DefaultAnalysisMode;
-import org.sonar.scanner.bootstrap.GlobalMode;
-import org.sonar.scanner.bootstrap.GlobalProperties;
-import org.sonar.scanner.bootstrap.GlobalSettings;
-import org.sonar.scanner.report.AnalysisContextReportPublisher;
-import org.sonar.scanner.repository.FileData;
-import org.sonar.scanner.repository.ProjectRepositories;
-import org.sonar.scanner.repository.settings.SettingsLoader;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ModuleSettingsTest {
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  private DefaultAnalysisMode mode;
-
-  @Before
-  public void before() {
-    mode = mock(DefaultAnalysisMode.class);
-  }
-
-  private ProjectRepositories createSettings(String module, Map<String, String> settingsMap) {
-    Table<String, String, FileData> fileData = ImmutableTable.of();
-    Table<String, String, String> settings = HashBasedTable.create();
-
-    for (Map.Entry<String, String> e : settingsMap.entrySet()) {
-      settings.put(module, e.getKey(), e.getValue());
-    }
-    return new ProjectRepositories(settings, fileData, null);
-  }
-
-  @Test
-  public void testOrderedProjects() {
-    ProjectDefinition grandParent = ProjectDefinition.create();
-    ProjectDefinition parent = ProjectDefinition.create();
-    ProjectDefinition child = ProjectDefinition.create();
-    grandParent.addSubProject(parent);
-    parent.addSubProject(child);
-
-    List<ProjectDefinition> hierarchy = ModuleSettings.getTopDownParentProjects(child);
-    assertThat(hierarchy.get(0)).isEqualTo(grandParent);
-    assertThat(hierarchy.get(1)).isEqualTo(parent);
-    assertThat(hierarchy.get(2)).isEqualTo(child);
-  }
-
-  @Test
-  public void test_loading_of_module_settings() {
-    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of(
-      "overridding", "batch",
-      "on-batch", "true"));
-
-    ProjectRepositories projRepos = createSettings("struts-core", ImmutableMap.of("on-module", "true", "overridding", "module"));
-
-    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
-
-    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projRepos, mode, mock(AnalysisContextReportPublisher.class));
-
-    assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
-    assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
-    assertThat(moduleSettings.getString("on-module")).isEqualTo("true");
-  }
-
-  // SONAR-6386
-  @Test
-  public void test_loading_of_parent_module_settings_for_new_module() {
-    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of(
-      "overridding", "batch",
-      "on-batch", "true"));
-
-    ProjectRepositories projRepos = createSettings("struts", ImmutableMap.of("on-module", "true", "overridding", "module"));
-
-    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
-    ProjectDefinition.create().setKey("struts").addSubProject(module);
-
-    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projRepos, mode, mock(AnalysisContextReportPublisher.class));
-
-    assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
-    assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
-    assertThat(moduleSettings.getString("on-module")).isEqualTo("true");
-  }
-
-  @Test
-  public void should_not_fail_when_accessing_secured_properties() {
-    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of(
-      "sonar.foo.secured", "bar"));
-
-    ProjectRepositories projSettingsRepo = createSettings("struts-core", ImmutableMap.of("sonar.foo.license.secured", "bar2"));
-
-    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
-
-    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projSettingsRepo, mode, mock(AnalysisContextReportPublisher.class));
-
-    assertThat(moduleSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
-    assertThat(moduleSettings.getString("sonar.foo.secured")).isEqualTo("bar");
-  }
-
-  @Test
-  public void should_fail_when_accessing_secured_properties_in_issues() {
-    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of(
-      "sonar.foo.secured", "bar"));
-
-    ProjectRepositories projSettingsRepo = createSettings("struts-core", ImmutableMap.of("sonar.foo.license.secured", "bar2"));
-
-    when(mode.isIssues()).thenReturn(true);
-
-    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
-
-    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projSettingsRepo, mode, mock(AnalysisContextReportPublisher.class));
-
-    assertThat(moduleSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
-
-    thrown.expect(MessageException.class);
-    thrown
-      .expectMessage(
-        "Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
-    moduleSettings.getString("sonar.foo.secured");
-  }
-
-  private GlobalSettings newGlobalSettings(Map<String, String> props) {
-    GlobalProperties globalProps = new GlobalProperties(props);
-    return new GlobalSettings(globalProps, new PropertyDefinitions(),
-      mock(SettingsLoader.class), new GlobalMode(globalProps));
-  }
-}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableModuleSettingsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableModuleSettingsTest.java
new file mode 100644 (file)
index 0000000..f1a150d
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.scan;
+
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableTable;
+import com.google.common.collect.Table;
+import java.util.List;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.utils.MessageException;
+import org.sonar.scanner.analysis.DefaultAnalysisMode;
+import org.sonar.scanner.bootstrap.GlobalConfiguration;
+import org.sonar.scanner.bootstrap.GlobalConfigurationProvider;
+import org.sonar.scanner.bootstrap.GlobalMode;
+import org.sonar.scanner.bootstrap.GlobalProperties;
+import org.sonar.scanner.bootstrap.MutableGlobalSettings;
+import org.sonar.scanner.repository.FileData;
+import org.sonar.scanner.repository.ProjectRepositories;
+import org.sonar.scanner.repository.settings.SettingsLoader;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class MutableModuleSettingsTest {
+
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+
+  private DefaultAnalysisMode mode;
+
+  @Before
+  public void before() {
+    mode = mock(DefaultAnalysisMode.class);
+  }
+
+  private ProjectRepositories createSettings(String module, Map<String, String> settingsMap) {
+    Table<String, String, FileData> fileData = ImmutableTable.of();
+    Table<String, String, String> settings = HashBasedTable.create();
+
+    for (Map.Entry<String, String> e : settingsMap.entrySet()) {
+      settings.put(module, e.getKey(), e.getValue());
+    }
+    return new ProjectRepositories(settings, fileData, null);
+  }
+
+  @Test
+  public void testOrderedProjects() {
+    ProjectDefinition grandParent = ProjectDefinition.create();
+    ProjectDefinition parent = ProjectDefinition.create();
+    ProjectDefinition child = ProjectDefinition.create();
+    grandParent.addSubProject(parent);
+    parent.addSubProject(child);
+
+    List<ProjectDefinition> hierarchy = MutableModuleSettings.getTopDownParentProjects(child);
+    assertThat(hierarchy.get(0)).isEqualTo(grandParent);
+    assertThat(hierarchy.get(1)).isEqualTo(parent);
+    assertThat(hierarchy.get(2)).isEqualTo(child);
+  }
+
+  @Test
+  public void test_loading_of_module_settings() {
+    GlobalConfiguration globalSettings = newGlobalSettings(ImmutableMap.of(
+      "overridding", "batch",
+      "on-batch", "true"));
+
+    ProjectRepositories projRepos = createSettings("struts-core", ImmutableMap.of("on-module", "true", "overridding", "module"));
+
+    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
+
+    MutableModuleSettings moduleSettings = new MutableModuleSettings(new MutableGlobalSettings(globalSettings), module, projRepos, mode);
+
+    assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
+    assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
+    assertThat(moduleSettings.getString("on-module")).isEqualTo("true");
+  }
+
+  // SONAR-6386
+  @Test
+  public void test_loading_of_parent_module_settings_for_new_module() {
+    GlobalConfiguration globalSettings = newGlobalSettings(ImmutableMap.of(
+      "overridding", "batch",
+      "on-batch", "true"));
+
+    ProjectRepositories projRepos = createSettings("struts", ImmutableMap.of("on-module", "true", "overridding", "module"));
+
+    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
+    ProjectDefinition.create().setKey("struts").addSubProject(module);
+
+    MutableModuleSettings moduleSettings = new MutableModuleSettings(new MutableGlobalSettings(globalSettings), module, projRepos, mode);
+
+    assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
+    assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
+    assertThat(moduleSettings.getString("on-module")).isEqualTo("true");
+  }
+
+  @Test
+  public void should_not_fail_when_accessing_secured_properties() {
+    GlobalConfiguration globalSettings = newGlobalSettings(ImmutableMap.of("sonar.foo.secured", "bar"));
+
+    ProjectRepositories projSettingsRepo = createSettings("struts-core", ImmutableMap.of("sonar.foo.license.secured", "bar2"));
+
+    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
+
+    MutableModuleSettings moduleSettings = new MutableModuleSettings(new MutableGlobalSettings(globalSettings), module, projSettingsRepo, mode);
+
+    assertThat(moduleSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
+    assertThat(moduleSettings.getString("sonar.foo.secured")).isEqualTo("bar");
+  }
+
+  @Test
+  public void should_fail_when_accessing_secured_properties_in_issues() {
+    GlobalConfiguration globalSettings = newGlobalSettings(ImmutableMap.of(
+      "sonar.foo.secured", "bar"));
+
+    ProjectRepositories projSettingsRepo = createSettings("struts-core", ImmutableMap.of("sonar.foo.license.secured", "bar2"));
+
+    when(mode.isIssues()).thenReturn(true);
+
+    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
+
+    MutableModuleSettings moduleSettings = new MutableModuleSettings(new MutableGlobalSettings(globalSettings), module, projSettingsRepo, mode);
+
+    assertThat(moduleSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
+
+    thrown.expect(MessageException.class);
+    thrown
+      .expectMessage(
+        "Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
+    moduleSettings.getString("sonar.foo.secured");
+  }
+
+  private GlobalConfiguration newGlobalSettings(Map<String, String> props) {
+    GlobalProperties globalProps = new GlobalProperties(props);
+    return new GlobalConfigurationProvider().provide(mock(SettingsLoader.class), globalProps, new PropertyDefinitions(),
+      new GlobalMode(globalProps));
+  }
+}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableProjectSettingsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableProjectSettingsTest.java
new file mode 100644 (file)
index 0000000..0087e27
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.scanner.scan;
+
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.ImmutableTable;
+import com.google.common.collect.Table;
+import java.util.Collections;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.utils.MessageException;
+import org.sonar.api.utils.log.LogTester;
+import org.sonar.scanner.analysis.DefaultAnalysisMode;
+import org.sonar.scanner.bootstrap.GlobalConfiguration;
+import org.sonar.scanner.bootstrap.GlobalConfigurationProvider;
+import org.sonar.scanner.bootstrap.GlobalMode;
+import org.sonar.scanner.bootstrap.GlobalProperties;
+import org.sonar.scanner.bootstrap.MutableGlobalSettings;
+import org.sonar.scanner.repository.FileData;
+import org.sonar.scanner.repository.ProjectRepositories;
+import org.sonar.scanner.repository.settings.SettingsLoader;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class MutableProjectSettingsTest {
+
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+  @Rule
+  public LogTester logTester = new LogTester();
+
+  private ProjectRepositories projectRef;
+  private ProjectDefinition project;
+  private GlobalConfiguration bootstrapProps;
+  private Table<String, String, FileData> emptyFileData;
+  private Table<String, String, String> emptySettings;
+
+  private GlobalMode globalMode;
+  private DefaultAnalysisMode mode;
+
+  @Before
+  public void prepare() {
+    emptyFileData = ImmutableTable.of();
+    emptySettings = ImmutableTable.of();
+    project = ProjectDefinition.create().setKey("struts");
+    globalMode = mock(GlobalMode.class);
+    mode = mock(DefaultAnalysisMode.class);
+    bootstrapProps = new GlobalConfigurationProvider().provide(mock(SettingsLoader.class), new GlobalProperties(Collections.<String, String>emptyMap()), new PropertyDefinitions(),
+      globalMode);
+  }
+
+  @Test
+  public void should_load_project_props() {
+    project.setProperty("project.prop", "project");
+
+    projectRef = new ProjectRepositories(emptySettings, emptyFileData, null);
+    MutableProjectSettings batchSettings = new MutableProjectSettings(new ProjectReactor(project), new MutableGlobalSettings(bootstrapProps), projectRef, mode);
+
+    assertThat(batchSettings.getString("project.prop")).isEqualTo("project");
+  }
+
+  @Test
+  public void should_load_project_root_settings() {
+    Table<String, String, String> settings = HashBasedTable.create();
+    settings.put("struts", "sonar.cpd.cross", "true");
+    settings.put("struts", "sonar.java.coveragePlugin", "jacoco");
+
+    projectRef = new ProjectRepositories(settings, emptyFileData, null);
+    MutableProjectSettings batchSettings = new MutableProjectSettings(new ProjectReactor(project), new MutableGlobalSettings(bootstrapProps), projectRef, mode);
+    assertThat(batchSettings.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
+  }
+
+  @Test
+  public void should_load_project_root_settings_on_branch() {
+    project.setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "mybranch");
+
+    Table<String, String, String> settings = HashBasedTable.create();
+    settings.put("struts:mybranch", "sonar.cpd.cross", "true");
+    settings.put("struts:mybranch", "sonar.java.coveragePlugin", "jacoco");
+
+    projectRef = new ProjectRepositories(settings, emptyFileData, null);
+
+    MutableProjectSettings batchSettings = new MutableProjectSettings(new ProjectReactor(project), new MutableGlobalSettings(bootstrapProps), projectRef, mode);
+
+    assertThat(batchSettings.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
+  }
+
+  @Test
+  public void should_not_fail_when_accessing_secured_properties() {
+    Table<String, String, String> settings = HashBasedTable.create();
+    settings.put("struts", "sonar.foo.secured", "bar");
+    settings.put("struts", "sonar.foo.license.secured", "bar2");
+
+    projectRef = new ProjectRepositories(settings, emptyFileData, null);
+    MutableProjectSettings batchSettings = new MutableProjectSettings(new ProjectReactor(project), new MutableGlobalSettings(bootstrapProps), projectRef, mode);
+
+    assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
+    assertThat(batchSettings.getString("sonar.foo.secured")).isEqualTo("bar");
+  }
+
+  @Test
+  public void should_fail_when_accessing_secured_properties_in_issues_mode() {
+    Table<String, String, String> settings = HashBasedTable.create();
+    settings.put("struts", "sonar.foo.secured", "bar");
+    settings.put("struts", "sonar.foo.license.secured", "bar2");
+
+    when(mode.isIssues()).thenReturn(true);
+
+    projectRef = new ProjectRepositories(settings, emptyFileData, null);
+    MutableProjectSettings batchSettings = new MutableProjectSettings(new ProjectReactor(project), new MutableGlobalSettings(bootstrapProps), projectRef, mode);
+
+    assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
+    thrown.expect(MessageException.class);
+    thrown
+      .expectMessage(
+        "Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
+    batchSettings.getString("sonar.foo.secured");
+  }
+
+}
index aaea18a974fb4ddea236f260389eeb5a3b1b876f..a76ced58419885f6d5f48dab96c515fcfce11d76 100644 (file)
  */
 package org.sonar.scanner.scan;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -32,6 +28,10 @@ import org.sonar.api.batch.bootstrap.ProjectBuilder.Context;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.utils.MessageException;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
 public class ProjectBuildersExecutorTest {
   private ProjectReactor reactor;
 
index b206d1b0508a7a27d33b8ca46214a9cdffc45844..cd628bbe8f48b6907a1acb9214d578bf53a5c8b3 100644 (file)
  */
 package org.sonar.scanner.scan;
 
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.home.cache.DirectoryLock;
-import org.sonar.scanner.scan.ProjectLock;
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TemporaryFolder;
 
 public class ProjectLockTest {
   @Rule
index 737db71b599d41167bdd4e5364c54ed243720479..9f7833fbc7590788a23fa57ac0fce5fa60c2c531 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.MessageException;
 import org.sonar.scanner.analysis.DefaultAnalysisMode;
 
index 05a0d06f4cd91589b854204ecd077a22ee2afc8a..0d2c247e3e84180820d07d7fcb481663fa1d1045 100644 (file)
@@ -24,7 +24,6 @@ import org.sonar.api.BatchExtension;
 import org.sonar.api.ServerExtension;
 import org.sonar.api.batch.InstantiationStrategy;
 import org.sonar.api.task.TaskExtension;
-import org.sonar.scanner.scan.ProjectScanContainer;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectSettingsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectSettingsTest.java
deleted file mode 100644 (file)
index e0d687a..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.scanner.scan;
-
-import com.google.common.collect.HashBasedTable;
-import com.google.common.collect.ImmutableTable;
-import com.google.common.collect.Table;
-import java.util.Collections;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.scanner.analysis.DefaultAnalysisMode;
-import org.sonar.scanner.bootstrap.GlobalMode;
-import org.sonar.scanner.bootstrap.GlobalProperties;
-import org.sonar.scanner.bootstrap.GlobalSettings;
-import org.sonar.scanner.repository.FileData;
-import org.sonar.scanner.repository.ProjectRepositories;
-import org.sonar.scanner.repository.settings.SettingsLoader;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ProjectSettingsTest {
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-  @Rule
-  public LogTester logTester = new LogTester();
-
-  private ProjectRepositories projectRef;
-  private ProjectDefinition project;
-  private GlobalSettings bootstrapProps;
-  private Table<String, String, FileData> emptyFileData;
-  private Table<String, String, String> emptySettings;
-
-  private GlobalMode globalMode;
-  private DefaultAnalysisMode mode;
-
-  @Before
-  public void prepare() {
-    emptyFileData = ImmutableTable.of();
-    emptySettings = ImmutableTable.of();
-    project = ProjectDefinition.create().setKey("struts");
-    globalMode = mock(GlobalMode.class);
-    mode = mock(DefaultAnalysisMode.class);
-    bootstrapProps = new GlobalSettings(new GlobalProperties(Collections.<String, String>emptyMap()), new PropertyDefinitions(), mock(SettingsLoader.class), globalMode);
-  }
-
-  @Test
-  public void should_load_project_props() {
-    project.setProperty("project.prop", "project");
-
-    projectRef = new ProjectRepositories(emptySettings, emptyFileData, null);
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
-
-    assertThat(batchSettings.getString("project.prop")).isEqualTo("project");
-  }
-
-  @Test
-  public void should_load_project_root_settings() {
-    Table<String, String, String> settings = HashBasedTable.create();
-    settings.put("struts", "sonar.cpd.cross", "true");
-    settings.put("struts", "sonar.java.coveragePlugin", "jacoco");
-
-    projectRef = new ProjectRepositories(settings, emptyFileData, null);
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
-    assertThat(batchSettings.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
-  }
-
-  @Test
-  public void should_load_project_root_settings_on_branch() {
-    project.setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "mybranch");
-
-    Table<String, String, String> settings = HashBasedTable.create();
-    settings.put("struts:mybranch", "sonar.cpd.cross", "true");
-    settings.put("struts:mybranch", "sonar.java.coveragePlugin", "jacoco");
-
-    projectRef = new ProjectRepositories(settings, emptyFileData, null);
-
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
-
-    assertThat(batchSettings.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
-  }
-
-  @Test
-  public void should_not_fail_when_accessing_secured_properties() {
-    Table<String, String, String> settings = HashBasedTable.create();
-    settings.put("struts", "sonar.foo.secured", "bar");
-    settings.put("struts", "sonar.foo.license.secured", "bar2");
-
-    projectRef = new ProjectRepositories(settings, emptyFileData, null);
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
-
-    assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
-    assertThat(batchSettings.getString("sonar.foo.secured")).isEqualTo("bar");
-  }
-
-  @Test
-  public void should_fail_when_accessing_secured_properties_in_issues_mode() {
-    Table<String, String, String> settings = HashBasedTable.create();
-    settings.put("struts", "sonar.foo.secured", "bar");
-    settings.put("struts", "sonar.foo.license.secured", "bar2");
-
-    when(mode.isIssues()).thenReturn(true);
-
-    projectRef = new ProjectRepositories(settings, emptyFileData, null);
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
-
-    assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
-    thrown.expect(MessageException.class);
-    thrown
-      .expectMessage(
-        "Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
-    batchSettings.getString("sonar.foo.secured");
-  }
-
-}
index c53512cbd1922f9b88db8daa2705c26292a2425e..58b4acc282329557ff1cdbef72b55c3864ebefd6 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.scanner.scan;
 
+import java.io.File;
+import java.io.IOException;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -26,9 +28,6 @@ import org.junit.rules.TemporaryFolder;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.home.cache.DirectoryLock;
-import org.sonar.scanner.scan.WorkDirectoryCleaner;
-import java.io.File;
-import java.io.IOException;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index 230ddbee1ec986c5663b52755dd8fc1c21795d0f..d0522adac02ac2413813d55251a66b9a9ed1be4b 100644 (file)
@@ -23,7 +23,6 @@ import org.junit.Test;
 import org.sonar.api.batch.fs.FilePredicate;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
-import org.sonar.scanner.scan.filesystem.AdditionalFilePredicates;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index ff3f3feb7113caf9080ae78dc3f1a121a0954090..911fcc7c7fa06fec7428e466f932db7168ef3677 100644 (file)
  */
 package org.sonar.scanner.scan.filesystem;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.nio.charset.Charset;
@@ -33,13 +26,19 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-
 import org.apache.commons.io.ByteOrderMark;
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.scanner.scan.filesystem.CharsetValidation.Result;
 import org.sonar.scanner.scan.filesystem.CharsetValidation.Validation;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 public class ByteCharsetDetectorTest {
   private CharsetValidation validation;
   private ByteCharsetDetector charsets;
index aeb38ee79939454076462511765988307e1add6b..0da6349119bcfb1170399bc5c320122e25a63119 100644 (file)
  */
 package org.sonar.scanner.scan.filesystem;
 
-import static java.nio.charset.StandardCharsets.US_ASCII;
-import static java.nio.charset.StandardCharsets.UTF_16;
-import static java.nio.charset.StandardCharsets.UTF_16BE;
-import static java.nio.charset.StandardCharsets.UTF_16LE;
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.assertj.core.api.Assertions.assertThat;
-
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
@@ -35,7 +28,6 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.List;
 import java.util.Random;
-
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.junit.Rule;
@@ -43,6 +35,13 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static java.nio.charset.StandardCharsets.UTF_16;
+import static java.nio.charset.StandardCharsets.UTF_16BE;
+import static java.nio.charset.StandardCharsets.UTF_16LE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.assertj.core.api.Assertions.assertThat;
+
 public class CharsetDetectorTest {
   @Rule
   public TemporaryFolder temp = new TemporaryFolder();
index 269bb6eef3ae0366388e71c6a678821e625cddbe..9956a6aa25d905b15fd33057406c336bc062d6a6 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.scanner.scan.filesystem;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.nio.ByteBuffer;
@@ -35,12 +33,13 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.List;
-
 import org.apache.commons.lang.StringUtils;
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.scanner.scan.filesystem.CharsetValidation.Validation;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 public class CharsetValidationTest {
   private CharsetValidation charsets;
 
index 20a528ac7a83c168cc2dc3d58fd7fdd0269a1d25..9815f2de7f22d4b9de89b376f2cc14da55c1554d 100644 (file)
@@ -30,8 +30,7 @@ import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.fs.IndexedFile;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultIndexedFile;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.scan.filesystem.FileExclusions;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -41,17 +40,19 @@ public class ExclusionFiltersTest {
   @Rule
   public TemporaryFolder temp = new TemporaryFolder();
   private Path moduleBaseDir;
+  private MapSettings settings;
+  private ExclusionFilters filter;
 
   @Before
   public void setUp() throws IOException {
+    settings = new MapSettings();
     moduleBaseDir = temp.newFolder().toPath();
+    filter = new ExclusionFilters(new FileExclusions(settings.asConfig()));
   }
 
   @Test
   public void no_inclusions_nor_exclusions() throws IOException {
-    ExclusionFilters filter = new ExclusionFilters(new FileExclusions(new MapSettings()));
     filter.prepare();
-
     IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/FooDao.java");
     assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isTrue();
     assertThat(filter.accept(indexedFile, InputFile.Type.TEST)).isTrue();
@@ -59,9 +60,7 @@ public class ExclusionFiltersTest {
 
   @Test
   public void match_inclusion() throws IOException {
-    Settings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Dao.java");
-    ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
     filter.prepare();
 
     IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/FooDao.java");
@@ -73,10 +72,7 @@ public class ExclusionFiltersTest {
 
   @Test
   public void match_at_least_one_inclusion() throws IOException {
-    Settings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Dao.java,**/*Dto.java");
-    ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
-
     filter.prepare();
 
     IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/Foo.java");
@@ -88,12 +84,9 @@ public class ExclusionFiltersTest {
 
   @Test
   public void match_exclusions() throws IOException {
-    Settings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "src/main/java/**/*");
     settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "src/test/java/**/*");
     settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*Dao.java");
-    ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
-
     filter.prepare();
 
     IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/FooDao.java");
@@ -111,11 +104,8 @@ public class ExclusionFiltersTest {
   public void match_exclusion_by_absolute_path() throws IOException {
     File excludedFile = new File(moduleBaseDir.toString(), "src/main/java/org/bar/Bar.java");
 
-    Settings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "src/main/java/**/*");
     settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "file:" + excludedFile.getAbsolutePath());
-    ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
-
     filter.prepare();
 
     IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/org/bar/Foo.java");
@@ -127,9 +117,7 @@ public class ExclusionFiltersTest {
 
   @Test
   public void trim_pattern() {
-    Settings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "   **/*Dao.java   ");
-    ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
 
     assertThat(filter.prepareMainExclusions()[0].toString()).isEqualTo("**/*Dao.java");
   }
index f3b147e00c40e84eb1aae91e4820c68d710e0808..4a7800668e31887d69ea25bf6054e5f608825a4d 100644 (file)
  */
 package org.sonar.scanner.scan.filesystem;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
-
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -34,10 +30,12 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.fs.InputFile.Type;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.scan.filesystem.PathResolver;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
 public class InputFileBuilderTest {
   @Rule
   public TemporaryFolder temp = new TemporaryFolder();
@@ -56,8 +54,8 @@ public class InputFileBuilderTest {
     LanguageDetection langDetection = mock(LanguageDetection.class);
     MetadataGenerator metadataGenerator = mock(MetadataGenerator.class);
     BatchIdGenerator idGenerator = new BatchIdGenerator();
-    Settings settings = new MapSettings();
-    builder = new InputFileBuilder(module, pathResolver, langDetection, metadataGenerator, idGenerator, settings);
+    MapSettings settings = new MapSettings();
+    builder = new InputFileBuilder(module, pathResolver, langDetection, metadataGenerator, idGenerator, settings.asConfig());
   }
 
   @Test
index f59b3bf063280a112d701b62e48da0fb3b35b513..86d33bb66608cb60019c26c9144c563e1e404eb3 100644 (file)
@@ -21,14 +21,14 @@ package org.sonar.scanner.scan.filesystem;
 
 import java.io.File;
 import java.io.IOException;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.fs.internal.DefaultIndexedFile;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.resources.Language;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.utils.MessageException;
@@ -47,6 +47,13 @@ public class LanguageDetectionTest {
   @Rule
   public ExpectedException thrown = ExpectedException.none();
 
+  private MapSettings settings;
+
+  @Before
+  public void setUp() throws IOException {
+    settings = new MapSettings();
+  }
+
   @Test
   public void test_sanitizeExtension() throws Exception {
     assertThat(LanguageDetection.sanitizeExtension(".cbl")).isEqualTo("cbl");
@@ -58,7 +65,7 @@ public class LanguageDetectionTest {
   @Test
   public void search_by_file_extension() throws Exception {
     LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java", "jav"), new MockLanguage("cobol", "cbl", "cob")));
-    LanguageDetection detection = new LanguageDetection(new MapSettings(), languages);
+    LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
 
     assertThat(detection.language(newIndexedFile("Foo.java"))).isEqualTo("java");
     assertThat(detection.language(newIndexedFile("src/Foo.java"))).isEqualTo("java");
@@ -75,7 +82,7 @@ public class LanguageDetectionTest {
 
   @Test
   public void should_not_fail_if_no_language() throws Exception {
-    LanguageDetection detection = spy(new LanguageDetection(new MapSettings(), new DefaultLanguagesRepository(new Languages())));
+    LanguageDetection detection = spy(new LanguageDetection(settings.asConfig(), new DefaultLanguagesRepository(new Languages())));
     assertThat(detection.language(newIndexedFile("Foo.java"))).isNull();
   }
 
@@ -83,7 +90,7 @@ public class LanguageDetectionTest {
   public void plugin_can_declare_a_file_extension_twice_for_case_sensitivity() throws Exception {
     LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("abap", "abap", "ABAP")));
 
-    LanguageDetection detection = new LanguageDetection(new MapSettings(), languages);
+    LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
     assertThat(detection.language(newIndexedFile("abc.abap"))).isEqualTo("abap");
   }
 
@@ -94,14 +101,13 @@ public class LanguageDetectionTest {
     LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("abap")));
 
     // No side-effect on non-ABAP projects
-    LanguageDetection detection = new LanguageDetection(new MapSettings(), languages);
+    LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
     assertThat(detection.language(newIndexedFile("abc"))).isNull();
     assertThat(detection.language(newIndexedFile("abc.abap"))).isNull();
     assertThat(detection.language(newIndexedFile("abc.java"))).isEqualTo("java");
 
-    Settings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "abap");
-    detection = new LanguageDetection(settings, languages);
+    detection = new LanguageDetection(settings.asConfig(), languages);
     assertThat(detection.language(newIndexedFile("abc"))).isEqualTo("abap");
     assertThat(detection.language(newIndexedFile("abc.txt"))).isEqualTo("abap");
     assertThat(detection.language(newIndexedFile("abc.java"))).isEqualTo("abap");
@@ -111,9 +117,8 @@ public class LanguageDetectionTest {
   public void force_language_using_deprecated_property() throws Exception {
     LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
 
-    Settings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "java");
-    LanguageDetection detection = new LanguageDetection(settings, languages);
+    LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
     assertThat(detection.language(newIndexedFile("abc"))).isNull();
     assertThat(detection.language(newIndexedFile("abc.php"))).isNull();
     assertThat(detection.language(newIndexedFile("abc.java"))).isEqualTo("java");
@@ -126,15 +131,14 @@ public class LanguageDetectionTest {
     thrown.expectMessage("You must install a plugin that supports the language 'unknown'");
 
     LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
-    Settings settings = new MapSettings();
     settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "unknown");
-    new LanguageDetection(settings, languages);
+    new LanguageDetection(settings.asConfig(), languages);
   }
 
   @Test
   public void fail_if_conflicting_language_suffix() throws Exception {
     LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
-    LanguageDetection detection = new LanguageDetection(new MapSettings(), languages);
+    LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
     try {
       detection.language(newIndexedFile("abc.xhtml"));
       fail();
@@ -150,10 +154,9 @@ public class LanguageDetectionTest {
   public void solve_conflict_using_filepattern() throws Exception {
     LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
 
-    Settings settings = new MapSettings();
     settings.setProperty("sonar.lang.patterns.xml", "xml/**");
     settings.setProperty("sonar.lang.patterns.web", "web/**");
-    LanguageDetection detection = new LanguageDetection(settings, languages);
+    LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
     assertThat(detection.language(newIndexedFile("xml/abc.xhtml"))).isEqualTo("xml");
     assertThat(detection.language(newIndexedFile("web/abc.xhtml"))).isEqualTo("web");
   }
@@ -161,11 +164,10 @@ public class LanguageDetectionTest {
   @Test
   public void fail_if_conflicting_filepattern() throws Exception {
     LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("abap", "abap"), new MockLanguage("cobol", "cobol")));
-    Settings settings = new MapSettings();
     settings.setProperty("sonar.lang.patterns.abap", "*.abap,*.txt");
     settings.setProperty("sonar.lang.patterns.cobol", "*.cobol,*.txt");
 
-    LanguageDetection detection = new LanguageDetection(settings, languages);
+    LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
 
     assertThat(detection.language(newIndexedFile("abc.abap"))).isEqualTo("abap");
     assertThat(detection.language(newIndexedFile("abc.cobol"))).isEqualTo("cobol");
index ae73b76db13a9e2025e770bb660826d5c36c4d5b..b9a9723e0ebabbeaf8025d1e3785fbe3e17f6179 100644 (file)
  */
 package org.sonar.scanner.scan.filesystem;
 
-import static org.apache.commons.codec.digest.DigestUtils.md5Hex;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-
 import org.apache.commons.io.FileUtils;
 import org.junit.Assert;
 import org.junit.Before;
@@ -47,6 +41,11 @@ import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer;
 import org.sonar.scanner.issue.ignore.pattern.PatternMatcher;
 import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader;
 
+import static org.apache.commons.codec.digest.DigestUtils.md5Hex;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 public class MetadataGeneratorTest {
   @Rule
   public TemporaryFolder temp = new TemporaryFolder();
index 2d6ffaa84491a3dc1bca40770c9712eca2529a74..160580763f0d23d739b1426c2dfa6c3de3cf2717 100644 (file)
@@ -21,8 +21,6 @@ package org.sonar.scanner.scan.filesystem;
 
 import org.junit.Test;
 import org.sonar.scanner.repository.ProjectRepositories;
-import org.sonar.scanner.scan.filesystem.StatusDetection;
-import org.sonar.scanner.scan.filesystem.StatusDetectionFactory;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index 0c7eadb86bd1fd59286cbb8d3f545b6b5e79c2e9..a295fdc08be0c40f2d83bae9ec2c6b13bc5113a4 100644 (file)
@@ -26,7 +26,6 @@ import org.junit.Test;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.scanner.repository.FileData;
 import org.sonar.scanner.repository.ProjectRepositories;
-import org.sonar.scanner.scan.filesystem.StatusDetection;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 572753822cdeb6439bcdd9c0df6f2858ebd16b31..0f302bf21618efe71ea381beb2d866053636c862 100644 (file)
@@ -26,8 +26,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.scanner.issue.IssueCache;
@@ -43,7 +42,7 @@ public class ConsoleReportTest {
   @Rule
   public LogTester logTester = new LogTester();
 
-  private Settings settings;
+  private MapSettings settings;
   private IssueCache issueCache;
   private InputComponentStore inputPathCache;
   private ConsoleReport report;
@@ -53,7 +52,7 @@ public class ConsoleReportTest {
     settings = new MapSettings();
     issueCache = mock(IssueCache.class);
     inputPathCache = mock(InputComponentStore.class);
-    report = new ConsoleReport(settings, issueCache, inputPathCache);
+    report = new ConsoleReport(settings.asConfig(), issueCache, inputPathCache);
   }
 
   @Test
index e999104d907d2fdd600790c0593f783241161caf..926b149ef3e66603e110982ae41a5a60876e2207 100644 (file)
@@ -41,8 +41,7 @@ import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.rule.Rules;
 import org.sonar.api.batch.rule.internal.RulesBuilder;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.platform.Server;
 import org.sonar.api.rule.RuleKey;
@@ -65,12 +64,12 @@ public class JSONReportTest {
   @Rule
   public TemporaryFolder temp = new TemporaryFolder();
 
-  JSONReport jsonReport;
-  DefaultFileSystem fs;
-  Server server = mock(Server.class);
-  Rules rules = mock(Rules.class);
-  Settings settings = new MapSettings();
-  IssueCache issueCache = mock(IssueCache.class);
+  private JSONReport jsonReport;
+  private DefaultFileSystem fs;
+  private Server server = mock(Server.class);
+  private Rules rules = mock(Rules.class);
+  private MapSettings settings = new MapSettings();
+  private IssueCache issueCache = mock(IssueCache.class);
   private InputModuleHierarchy moduleHierarchy;
 
   @Before
@@ -111,7 +110,7 @@ public class JSONReportTest {
     RulesBuilder builder = new RulesBuilder();
     builder.add(RuleKey.of("squid", "AvoidCycles")).setName("Avoid Cycles");
     rules = builder.build();
-    jsonReport = new JSONReport(moduleHierarchy, settings, fs, server, rules, issueCache, rootModule, inputComponentStore, inputComponentTree);
+    jsonReport = new JSONReport(moduleHierarchy, settings.asConfig(), fs, server, rules, issueCache, rootModule, inputComponentStore, inputComponentTree);
   }
 
   @Test
index d9abc47deead0a46d1d4d9757e1e6e5c280c8867..1284ab03bd22ec5de46fcb36722cf5febc6fdf08 100644 (file)
  */
 package org.sonar.scanner.scan.report;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import static org.mockito.Matchers.any;
-
-import org.sonar.api.rule.RuleKey;
-import org.sonar.scanner.scan.report.RuleNameProvider;
-import org.sonar.api.batch.rule.Rule;
-import org.junit.Test;
 import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.batch.rule.Rule;
 import org.sonar.api.batch.rule.Rules;
+import org.sonar.api.rule.RuleKey;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class RuleNameProviderTest {
-  RuleNameProvider provider;
-  Rules rules;
-  Rule rule;
-  RuleKey ruleKey;
+  private RuleNameProvider provider;
+  private Rules rules;
+  private Rule rule;
+  private RuleKey ruleKey;
 
   @Before
   public void setUp() {
index f416dd642aabc199b7320ef3837f0bdf2d8d2ce1..8713d8c88a73b6bce34a555ca48c5fde65140e7a 100644 (file)
@@ -27,7 +27,6 @@ import org.junit.rules.ExpectedException;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.scm.BlameLine;
-import org.sonar.scanner.scm.DefaultBlameOutput;
 
 public class DefaultBlameOutputTest {
 
index 2d5f98780f5349328e736da12018c04a2150fa34..c73b0636e67d4df5af94f9a0f5e4c2a567b6fbca 100644 (file)
@@ -33,8 +33,7 @@ import org.sonar.api.batch.measure.MetricFinder;
 import org.sonar.api.batch.rule.ActiveRules;
 import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
 import org.sonar.api.batch.sensor.internal.SensorStorage;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.internal.SonarRuntimeImpl;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.utils.Version;
@@ -54,7 +53,7 @@ public class DefaultSensorContextTest {
   private ActiveRules activeRules;
   private DefaultFileSystem fs;
   private DefaultSensorContext adaptor;
-  private Settings settings;
+  private MapSettings settings;
   private SensorStorage sensorStorage;
   private AnalysisMode analysisMode;
   private SonarRuntime runtime;
@@ -70,7 +69,7 @@ public class DefaultSensorContextTest {
     sensorStorage = mock(SensorStorage.class);
     analysisMode = mock(AnalysisMode.class);
     runtime = SonarRuntimeImpl.forSonarQube(Version.parse("5.5"), SonarQubeSide.SCANNER);
-    adaptor = new DefaultSensorContext(mock(InputModule.class), settings, fs, activeRules, analysisMode, sensorStorage, runtime);
+    adaptor = new DefaultSensorContext(mock(InputModule.class), settings.asConfig(), settings, fs, activeRules, analysisMode, sensorStorage, runtime);
   }
 
   @Test
index 75d25e7080bede54fbab8e291ea1b0a7d5e7d590..2c375606ae95a2f07b7a166da27c3d6d4e9a28d6 100644 (file)
@@ -34,8 +34,7 @@ import org.sonar.api.batch.measure.MetricFinder;
 import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting;
 import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
 import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.core.metric.ScannerMetrics;
@@ -63,7 +62,7 @@ public class DefaultSensorStorageTest {
   public ExpectedException thrown = ExpectedException.none();
 
   private DefaultSensorStorage underTest;
-  private Settings settings;
+  private MapSettings settings;
   private ModuleIssues moduleIssues;
   private MeasureCache measureCache;
   private ContextPropertiesCache contextPropertiesCache = new ContextPropertiesCache();
@@ -81,7 +80,7 @@ public class DefaultSensorStorageTest {
     ReportPublisher reportPublisher = mock(ReportPublisher.class);
     when(reportPublisher.getWriter()).thenReturn(new ScannerReportWriter(temp.newFolder()));
     underTest = new DefaultSensorStorage(metricFinder,
-      moduleIssues, settings, coverageExclusions, reportPublisher, measureCache,
+      moduleIssues, settings.asConfig(), coverageExclusions, reportPublisher, measureCache,
       mock(SonarCpdBlockIndex.class), contextPropertiesCache, new ScannerMetrics());
   }
 
index 748470679cc83be0e64aa6a53b5205569f47abd6..76b83f4318e7b41af47409df9fedd8746a2a506c 100644 (file)
@@ -30,8 +30,7 @@ import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.rule.ActiveRules;
 import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
 import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
-import org.sonar.api.config.Settings;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.rule.RuleKey;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -46,13 +45,13 @@ public class SensorOptimizerTest {
 
   private DefaultFileSystem fs;
   private SensorOptimizer optimizer;
-  private Settings settings;
+  private MapSettings settings;
 
   @Before
   public void prepare() throws Exception {
     fs = new DefaultFileSystem(temp.newFolder().toPath());
     settings = new MapSettings();
-    optimizer = new SensorOptimizer(fs, new ActiveRulesBuilder().build(), settings);
+    optimizer = new SensorOptimizer(fs, new ActiveRulesBuilder().build(), settings.asConfig());
   }
 
   @Test
@@ -110,7 +109,7 @@ public class SensorOptimizerTest {
       .create(RuleKey.of("repo1", "foo"))
       .activate()
       .build();
-    optimizer = new SensorOptimizer(fs, activeRules, settings);
+    optimizer = new SensorOptimizer(fs, activeRules, settings.asConfig());
 
     assertThat(optimizer.shouldExecute(descriptor)).isFalse();
 
@@ -120,7 +119,7 @@ public class SensorOptimizerTest {
       .create(RuleKey.of("squid", "rule"))
       .activate()
       .build();
-    optimizer = new SensorOptimizer(fs, activeRules, settings);
+    optimizer = new SensorOptimizer(fs, activeRules, settings.asConfig());
     assertThat(optimizer.shouldExecute(descriptor)).isTrue();
   }
 
index 99e82e689766b4a0f605604bd962a82db35b8c06..7eafee529effaa945c7ca25553d86f639de1c32b 100644 (file)
@@ -23,22 +23,21 @@ import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
-import org.sonar.api.config.MapSettings;
 import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
 import org.sonar.core.config.ExclusionProperties;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class CoverageExclusionsTest {
 
-  private Settings settings;
+  private MapSettings settings;
   private CoverageExclusions coverageExclusions;
 
   @Before
   public void prepare() {
     settings = new MapSettings(new PropertyDefinitions(ExclusionProperties.all()));
-    coverageExclusions = new CoverageExclusions(settings);
+    coverageExclusions = new CoverageExclusions(settings.asConfig());
   }
 
   @Test
index 602d139bd847efcf3fd29e899fe47177299d9ed9..45bd4fc8a067426ca538fa1cbe3b53bb73b477b2 100644 (file)
@@ -28,7 +28,6 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting;
 import org.sonar.api.batch.sensor.internal.SensorStorage;
-import org.sonar.scanner.source.DefaultHighlightable;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index 80a35c1df7e80cce5787e10f5d36fda14498f23d..0c67f1369b5a01b70d2bb89cb6cf1e391e7bf435 100644 (file)
@@ -29,7 +29,6 @@ import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable;
 import org.sonar.api.source.Symbol;
 import org.sonar.api.source.Symbolizable;
 import org.sonar.scanner.sensor.DefaultSensorStorage;
-import org.sonar.scanner.source.DefaultSymbolizable;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index 7e7114edafafabab9e78afbed71e5a583362e14d..370c6bdb5fd47d88bd5492fefcc4d4f858e6a909 100644 (file)
@@ -31,7 +31,6 @@ import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable;
 import org.sonar.api.source.Symbol;
 import org.sonar.api.source.Symbolizable;
-import org.sonar.scanner.source.DeprecatedDefaultSymbolTable;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 239f761710b0366f02058340cb975bc5ebdea13e..7b1b1791332e89c6c67e714a2732caf6a79ee45a 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.scanner.storage;
 import com.google.common.collect.Iterables;
 import org.junit.Test;
 import org.sonar.scanner.index.AbstractCachesTest;
-import org.sonar.scanner.storage.Storage;
 import org.sonar.scanner.storage.Storage.Entry;
 
 import static org.assertj.core.api.Assertions.assertThat;
index 612431b511009da133fa3c725898da0b635b94da..03730f412b8334964fa27bc375580094b9cd6635 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.scanner.storage;
 
+import java.io.File;
 import org.junit.Test;
 import org.sonar.scanner.index.AbstractCachesTest;
-import java.io.File;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 4fd5337872a9ff781f1bf68d134962375a243386..4de2db91ee0a6f873c83e9324cbb16868959d235 100644 (file)
  */
 package org.sonar.scanner.storage;
 
-import java.io.Serializable;
-
 import com.persistit.exception.PersistitException;
+import java.io.Serializable;
 import org.junit.Test;
 import org.sonar.scanner.index.AbstractCachesTest;
-import org.sonar.scanner.storage.Storage;
-import org.sonar.scanner.storage.Storages;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
index 9f7788a37ab8fa3f953e871caa8b4ae08e6f54b0..f07e6c8054ebf96c1953c15c2292a2feb3de3024 100644 (file)
@@ -26,8 +26,6 @@ import org.sonar.api.task.Task;
 import org.sonar.api.task.TaskDefinition;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
-import org.sonar.scanner.task.ListTask;
-import org.sonar.scanner.task.Tasks;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index 93340aeeadf75fa20b10991f6150dd80ab106f1a..828f86dfadb2c8080931f1ded862df954a8ab96b 100644 (file)
@@ -24,9 +24,6 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.task.Task;
 import org.sonar.api.task.TaskDefinition;
-import org.sonar.scanner.task.ListTask;
-import org.sonar.scanner.task.ScanTask;
-import org.sonar.scanner.task.Tasks;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 79e4fc3bceaf0d0b041ce26186afbc8f15ca8943..517cca80743af596bb550331dd0d3ed43aeaf20f 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.scanner.util;
 
 import org.junit.Test;
-import org.sonar.scanner.util.ScannerUtils;
 
 import static org.assertj.core.api.Assertions.assertThat;