Explorar el Código

SONAR-17706 Drop support for projects still using modules in SonarQube server

tags/10.0.0.68432
Duarte Meneses hace 1 año
padre
commit
2a867fa579
Se han modificado 20 ficheros con 125 adiciones y 581 borrados
  1. 0
    140
      server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigration.java
  2. 5
    7
      server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStep.java
  3. 7
    33
      server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStep.java
  4. 87
    0
      server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryImplTest.java
  5. 0
    241
      server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java
  6. 0
    2
      server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
  7. 0
    15
      server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
  8. 0
    4
      server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
  9. 0
    19
      server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
  10. 0
    88
      server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
  11. 3
    3
      server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java
  12. 2
    3
      server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
  13. 1
    5
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java
  14. 4
    4
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingValidations.java
  15. 5
    8
      server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java
  16. 2
    3
      sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java
  17. 7
    3
      sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
  18. 1
    1
      sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java
  19. 1
    1
      sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java
  20. 0
    1
      sonar-ws/src/main/java/org/sonarqube/ws/client/issues/SearchRequest.java

+ 0
- 140
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigration.java Ver fichero

@@ -1,140 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2023 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.ce.task.projectanalysis.component;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
import org.sonar.ce.task.projectanalysis.analysis.Branch;
import org.sonar.core.util.Uuids;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchType;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentWithModuleUuidDto;
import org.sonar.db.component.KeyWithUuidDto;

public class ComponentUuidFactoryWithMigration implements ComponentUuidFactory {
private final Map<String, String> uuidsByDbKey = new HashMap<>();
private final Map<String, String> uuidsByMigratedKey = new HashMap<>();

public ComponentUuidFactoryWithMigration(DbClient dbClient, DbSession dbSession, String rootKey, Branch branch,
Function<String, String> pathToKey, Map<String, String> reportModulesPath) {
Map<String, String> modulePathsByUuid;
List<KeyWithUuidDto> keys;
if (branch.isMain()) {
keys = dbClient.componentDao().selectUuidsByKeyFromProjectKey(dbSession, rootKey);
} else if (branch.getType() == BranchType.PULL_REQUEST) {
keys = dbClient.componentDao().selectUuidsByKeyFromProjectKeyAndPullRequest(dbSession, rootKey, branch.getPullRequestKey());
} else {
keys = dbClient.componentDao().selectUuidsByKeyFromProjectKeyAndBranch(dbSession, rootKey, branch.getName());
}

keys.forEach(dto -> uuidsByDbKey.put(dto.key(), dto.uuid()));

if (!reportModulesPath.isEmpty()) {
modulePathsByUuid = loadModulePathsByUuid(dbClient, dbSession, rootKey, branch, reportModulesPath);

if (!modulePathsByUuid.isEmpty()) {
doMigration(dbClient, dbSession, rootKey, pathToKey, modulePathsByUuid);
}
}
}

private void doMigration(DbClient dbClient, DbSession dbSession, String rootKey, Function<String, String> pathToKey, Map<String, String> modulePathsByUuid) {
List<ComponentWithModuleUuidDto> dtos = loadComponentsWithModuleUuid(dbClient, dbSession, rootKey);
for (ComponentWithModuleUuidDto dto : dtos) {
if ("/".equals(dto.path())) {
// skip root folders
continue;
}

if (Scopes.PROJECT.equals(dto.scope())) {
String modulePathFromRootProject = modulePathsByUuid.get(dto.uuid());
if (modulePathFromRootProject != null || StringUtils.isEmpty(dto.moduleUuid())) {
// means that it's a root or a module with a valid path (to avoid overwriting key of root)
pathToKey.apply(modulePathFromRootProject);
uuidsByMigratedKey.put(pathToKey.apply(modulePathFromRootProject), dto.uuid());
}
} else {
String modulePathFromRootProject = modulePathsByUuid.get(dto.moduleUuid());
String componentPath = createComponentPath(dto, modulePathFromRootProject);
uuidsByMigratedKey.put(pathToKey.apply(componentPath), dto.uuid());
}
}
}

@CheckForNull
private static String createComponentPath(ComponentWithModuleUuidDto dto, @Nullable String modulePathFromRootProject) {
if (StringUtils.isEmpty(modulePathFromRootProject)) {
return dto.path();
}

if (StringUtils.isEmpty(dto.path())) {
// will be the case for modules
return modulePathFromRootProject;
}

return modulePathFromRootProject + "/" + dto.path();
}

private static List<ComponentWithModuleUuidDto> loadComponentsWithModuleUuid(DbClient dbClient, DbSession dbSession, String rootKey) {
return dbClient.componentDao().selectEnabledComponentsWithModuleUuidFromProjectKey(dbSession, rootKey);
}

private static Map<String, String> loadModulePathsByUuid(DbClient dbClient, DbSession dbSession, String rootKey,
Branch branch, Map<String, String> pathByModuleKey) {
String branchKey = branch.getType() == BranchType.BRANCH ? branch.getName() : null;
String prKey = branch.getType() == BranchType.PULL_REQUEST ? branch.getPullRequestKey() : null;

List<ComponentDto> moduleDtos = dbClient.componentDao()
.selectProjectAndModulesFromProjectKey(dbSession, rootKey, true, branchKey, prKey).stream()
.filter(c -> Qualifiers.MODULE.equals(c.qualifier()))
.toList();

if (moduleDtos.isEmpty()) {
return Collections.emptyMap();
}

Map<String, String> modulePathByUuid = new HashMap<>();
for (ComponentDto dto : moduleDtos) {
String relativePath = pathByModuleKey.get(dto.getKey());
if (relativePath != null) {
modulePathByUuid.put(dto.uuid(), relativePath);
}
}
return modulePathByUuid;
}

/**
* Get UUID from component having the same key in database if it exists, otherwise look for migrated keys, and finally generate a new one.
*/
@Override
public String getOrCreateForKey(String key) {
return uuidsByDbKey.computeIfAbsent(key, k1 -> uuidsByMigratedKey.computeIfAbsent(k1, k2 -> Uuids.create()));
}
}

+ 5
- 7
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStep.java Ver fichero

@@ -20,7 +20,6 @@
package org.sonar.ce.task.projectanalysis.step;

import java.util.Optional;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.sonar.ce.task.projectanalysis.analysis.Analysis;
import org.sonar.ce.task.projectanalysis.analysis.MutableAnalysisMetadataHolder;
@@ -28,7 +27,8 @@ import org.sonar.ce.task.projectanalysis.batch.BatchReportReader;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.ce.task.projectanalysis.component.ComponentKeyGenerator;
import org.sonar.ce.task.projectanalysis.component.ComponentTreeBuilder;
import org.sonar.ce.task.projectanalysis.component.ComponentUuidFactoryWithMigration;
import org.sonar.ce.task.projectanalysis.component.ComponentUuidFactory;
import org.sonar.ce.task.projectanalysis.component.ComponentUuidFactoryImpl;
import org.sonar.ce.task.projectanalysis.component.MutableTreeRootHolder;
import org.sonar.ce.task.projectanalysis.component.ProjectAttributes;
import org.sonar.ce.task.projectanalysis.component.ReportModulesPath;
@@ -77,16 +77,14 @@ public class BuildComponentTreeStep implements ComputationStep {

// root key of branch, not necessarily of project
String rootKey = keyGenerator.generateKey(reportProject.getKey(), null);
Function<String, String> pathToKey = path -> keyGenerator.generateKey(reportProject.getKey(), path);
// loads the UUIDs from database. If they don't exist, then generate new ones
ComponentUuidFactoryWithMigration componentUuidFactoryWithMigration =
new ComponentUuidFactoryWithMigration(dbClient, dbSession, rootKey, analysisMetadataHolder.getBranch(), pathToKey, reportModulesPath.get());
ComponentUuidFactory componentUuidFactory = new ComponentUuidFactoryImpl(dbClient, dbSession, rootKey, analysisMetadataHolder.getBranch());

String rootUuid = componentUuidFactoryWithMigration.getOrCreateForKey(rootKey);
String rootUuid = componentUuidFactory.getOrCreateForKey(rootKey);
Optional<SnapshotDto> baseAnalysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, rootUuid);

ComponentTreeBuilder builder = new ComponentTreeBuilder(keyGenerator,
componentUuidFactoryWithMigration::getOrCreateForKey,
componentUuidFactory::getOrCreateForKey,
reportReader::readComponent,
analysisMetadataHolder.getProject(),
analysisMetadataHolder.getBranch(),

+ 7
- 33
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStep.java Ver fichero

@@ -23,9 +23,7 @@ import com.google.common.base.Joiner;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.sonar.api.utils.MessageException;
import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
import org.sonar.ce.task.projectanalysis.component.Component;
@@ -64,14 +62,10 @@ public class ValidateProjectStep implements ComputationStep {
@Override
public void execute(ComputationStep.Context context) {
try (DbSession dbSession = dbClient.openSession(false)) {
validateTargetBranch(dbSession);
Component root = treeRootHolder.getRoot();
// FIXME if module have really be dropped, no more need to load them
String branchKey = analysisMetadataHolder.isBranch() ? analysisMetadataHolder.getBranch().getName() : null;
String prKey = analysisMetadataHolder.isPullRequest() ? analysisMetadataHolder.getBranch().getPullRequestKey() : null;
List<ComponentDto> baseModules = dbClient.componentDao().selectEnabledModulesFromProjectKey(dbSession, root.getKey(), branchKey, prKey);
Map<String, ComponentDto> baseModulesByKey = baseModules.stream().collect(Collectors.toMap(ComponentDto::getKey, x -> x));
ValidateProjectsVisitor visitor = new ValidateProjectsVisitor(dbSession, dbClient.componentDao(), baseModulesByKey);
ValidateProjectsVisitor visitor = new ValidateProjectsVisitor(dbSession, dbClient.componentDao());
new DepthTraversalTypeAwareCrawler(visitor).visit(root);

if (!visitor.validationMessages.isEmpty()) {
@@ -80,20 +74,6 @@ public class ValidateProjectStep implements ComputationStep {
}
}

private void validateTargetBranch(DbSession session) {
if (!analysisMetadataHolder.isPullRequest()) {
return;
}
String referenceBranchUuid = analysisMetadataHolder.getBranch().getReferenceBranchUuid();
int moduleCount = dbClient.componentDao().countEnabledModulesByBranchUuid(session, referenceBranchUuid);
if (moduleCount > 0) {
Optional<BranchDto> opt = dbClient.branchDao().selectByUuid(session, referenceBranchUuid);
checkState(opt.isPresent(), "Reference branch '%s' does not exist", referenceBranchUuid);
throw MessageException.of(String.format(
"Due to an upgrade, you need first to re-analyze the target branch '%s' before analyzing this pull request.", opt.get().getKey()));
}
}

@Override
public String getDescription() {
return "Validate project";
@@ -102,14 +82,12 @@ public class ValidateProjectStep implements ComputationStep {
private class ValidateProjectsVisitor extends TypeAwareVisitorAdapter {
private final DbSession session;
private final ComponentDao componentDao;
private final Map<String, ComponentDto> baseModulesByKey;
private final List<String> validationMessages = new ArrayList<>();

public ValidateProjectsVisitor(DbSession session, ComponentDao componentDao, Map<String, ComponentDto> baseModulesByKey) {
public ValidateProjectsVisitor(DbSession session, ComponentDao componentDao) {
super(CrawlerDepthLimit.PROJECT, ComponentVisitor.Order.PRE_ORDER);
this.session = session;
this.componentDao = componentDao;
this.baseModulesByKey = baseModulesByKey;
}

@Override
@@ -142,16 +120,12 @@ public class ValidateProjectStep implements ComputationStep {
}

private Optional<ComponentDto> loadBaseComponent(String rawComponentKey) {
ComponentDto baseComponent = baseModulesByKey.get(rawComponentKey);
if (baseComponent == null) {
// Load component from key to be able to detect issue (try to analyze a module, etc.)
if (analysisMetadataHolder.isBranch()) {
return componentDao.selectByKeyAndBranch(session, rawComponentKey, analysisMetadataHolder.getBranch().getName());
} else {
return componentDao.selectByKeyAndPullRequest(session, rawComponentKey, analysisMetadataHolder.getBranch().getPullRequestKey());
}
// Load component from key to be able to detect issue (try to analyze a module, etc.)
if (analysisMetadataHolder.isBranch()) {
return componentDao.selectByKeyAndBranch(session, rawComponentKey, analysisMetadataHolder.getBranch().getName());
} else {
return componentDao.selectByKeyAndPullRequest(session, rawComponentKey, analysisMetadataHolder.getBranch().getPullRequestKey());
}
return Optional.of(baseComponent);
}
}
}

+ 87
- 0
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryImplTest.java Ver fichero

@@ -0,0 +1,87 @@
/*
* SonarQube
* Copyright (C) 2009-2023 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.ce.task.projectanalysis.component;

import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.projectanalysis.analysis.Branch;
import org.sonar.db.DbTester;
import org.sonar.db.component.BranchType;
import org.sonar.db.component.ComponentDto;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;

public class ComponentUuidFactoryImplTest {
private final Branch mainBranch = new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
private final Branch mockedBranch = mock(Branch.class);

@Rule
public DbTester db = DbTester.create(System2.INSTANCE);

@Test
public void getOrCreateForKey_when_existingComponentsInDbForMainBranch_should_load() {
ComponentDto project = db.components().insertPrivateProject();

ComponentUuidFactory underTest = new ComponentUuidFactoryImpl(db.getDbClient(), db.getSession(), project.getKey(), mainBranch);

assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
}

@Test
public void getOrCreateForKey_when_existingComponentsInDbForNonMainBranch_should_load() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("b1"));
when(mockedBranch.getType()).thenReturn(BranchType.BRANCH);
when(mockedBranch.isMain()).thenReturn(false);
when(mockedBranch.getName()).thenReturn("b1");

ComponentUuidFactory underTest = new ComponentUuidFactoryImpl(db.getDbClient(), db.getSession(), project.getKey(), mockedBranch);

assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(branch.uuid());
}

@Test
public void getOrCreateForKey_when_existingComponentsInDbForPr_should_load() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST).setKey("pr1"));
when(mockedBranch.getType()).thenReturn(BranchType.PULL_REQUEST);
when(mockedBranch.isMain()).thenReturn(false);
when(mockedBranch.getPullRequestKey()).thenReturn("pr1");

ComponentUuidFactory underTest = new ComponentUuidFactoryImpl(db.getDbClient(), db.getSession(), project.getKey(), mockedBranch);

assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(pr.uuid());
}

@Test
public void getOrCreateForKey_when_componentsNotInDb_should_generate() {
ComponentUuidFactory underTest = new ComponentUuidFactoryImpl(db.getDbClient(), db.getSession(), "theProjectKey", mainBranch);

String generatedKey = underTest.getOrCreateForKey("foo");
assertThat(generatedKey).isNotEmpty();

// uuid is kept in memory for further calls with same key
assertThat(underTest.getOrCreateForKey("foo")).isEqualTo(generatedKey);
}
}

+ 0
- 241
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java Ver fichero

@@ -1,241 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2023 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.ce.task.projectanalysis.component;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.projectanalysis.analysis.Branch;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;

import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;

public class ComponentUuidFactoryWithMigrationTest {
private final Branch mainBranch = new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
private Function<String, String> pathToKey = path -> path != null ? "project:" + path : "project";

@Test
public void load_uuids_from_existing_components_in_db() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
Map<String, String> reportModulesPath = Collections.singletonMap(module.getKey(), "module1_path");
pathToKey = path -> path != null ? project.getKey() + ":" + path : project.getKey();

ComponentUuidFactoryWithMigration underTest =
new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), mainBranch, pathToKey, reportModulesPath);

assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
assertThat(underTest.getOrCreateForKey(module.getKey())).isEqualTo(module.uuid());
}

@Test
public void migrate_project_with_modules() {
ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
.setKey("project:module1"));
ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(module1)
.setKey("project:module1:module2"));
ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(project)
.setKey("project:file1")
.setPath("file1_path"));
ComponentDto file2 = db.components().insertComponent(ComponentTesting.newFileDto(module2)
.setKey("project:module1:module2:file2")
.setPath("file2_path"));

assertThat(file2.moduleUuidPath()).isEqualTo("." + project.uuid() + "." + module1.uuid() + "." + module2.uuid() + ".");
Map<String, String> modulesRelativePaths = new HashMap<>();
modulesRelativePaths.put("project:module1", "module1_path");
modulesRelativePaths.put("project:module1:module2", "module1_path/module2_path");
ComponentUuidFactoryWithMigration underTest =
new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), mainBranch, pathToKey, modulesRelativePaths);

// migrated files
assertThat(underTest.getOrCreateForKey("project:file1_path")).isEqualTo(file1.uuid());
assertThat(underTest.getOrCreateForKey("project:module1_path/module2_path/file2_path")).isEqualTo(file2.uuid());

// project remains the same
assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
}

@Test
public void migrate_project_with_disabled_components_no_path() {
ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
.setKey("project:module1"));
ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(project)
.setKey("project:file1")
.setPath("file1"));
ComponentDto disabledFileNoPath = db.components().insertComponent(ComponentTesting.newFileDto(project)
.setKey("project:file2")
.setPath(null)
.setEnabled(false));

Map<String, String> modulesRelativePaths = new HashMap<>();
modulesRelativePaths.put("project:module1", "module1_path");
ComponentUuidFactoryWithMigration underTest =
new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), mainBranch, pathToKey, modulesRelativePaths);

// migrated files
assertThat(underTest.getOrCreateForKey("project:file1")).isEqualTo(file1.uuid());

// project remains the same
assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
}

@Test
public void migrate_project_with_disabled_components_same_path() {
ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
.setKey("project:module1"));
ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(project)
.setKey("project:file1")
.setPath("file1"));
ComponentDto disabledFileSamePath = db.components().insertComponent(ComponentTesting.newFileDto(project)
.setKey("project:file2")
.setPath("file1")
.setEnabled(false));

Map<String, String> modulesRelativePaths = new HashMap<>();
modulesRelativePaths.put("project:module1", "module1_path");
ComponentUuidFactoryWithMigration underTest =
new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), mainBranch, pathToKey, modulesRelativePaths);

// migrated files
assertThat(underTest.getOrCreateForKey("project:file1")).isEqualTo(file1.uuid());

// project remains the same
assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
}

@Test
public void prefers_component_having_same_key() {
ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
.setKey("project:module1"));
ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(module1)
.setKey("project:module1:file1")
.setPath("file1"));
ComponentDto disabledFileSameKey = db.components().insertComponent(ComponentTesting.newFileDto(project)
.setKey("project:module1/file1")
.setPath("module1_path/file1")
.setEnabled(false));

Map<String, String> modulesRelativePaths = new HashMap<>();
modulesRelativePaths.put("project:module1", "module1_path");
ComponentUuidFactoryWithMigration underTest =
new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), mainBranch, pathToKey, modulesRelativePaths);

// in theory we should migrate file1. But since disabledFileSameKey already have the expected migrated key, let's reuse it.
assertThat(underTest.getOrCreateForKey("project:module1/file1")).isEqualTo(disabledFileSameKey.uuid());

// project remains the same
assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
}

@Test
public void migrate_branch_with_modules() {
pathToKey = path -> path != null ? "project:" + path : "project";
ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
.setKey("project:module1"));
ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(module1)
.setKey("project:module1:module2"));
ComponentDto file1 = db.components().insertComponent(ComponentTesting.newFileDto(project)
.setKey("project:file1")
.setPath("file1_path"));
ComponentDto file2 = db.components().insertComponent(ComponentTesting.newFileDto(module2)
.setKey("project:module1:module2:file2")
.setPath("file2_path"));

assertThat(file2.moduleUuidPath()).isEqualTo("." + project.uuid() + "." + module1.uuid() + "." + module2.uuid() + ".");
Map<String, String> modulesRelativePaths = new HashMap<>();
modulesRelativePaths.put("project:module1", "module1_path");
modulesRelativePaths.put("project:module1:module2", "module1_path/module2_path");
ComponentUuidFactoryWithMigration underTest =
new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), mainBranch, pathToKey, modulesRelativePaths);

// migrated files
assertThat(underTest.getOrCreateForKey("project:file1_path")).isEqualTo(file1.uuid());
assertThat(underTest.getOrCreateForKey("project:module1_path/module2_path/file2_path")).isEqualTo(file2.uuid());

// project remains the same
assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());
}

@Test
public void migrate_project_with_root_folders() {
ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
.setKey("project:module1"));
ComponentDto dir1 = db.components().insertComponent(ComponentTesting.newDirectory(module1, "/")
.setKey("project:module1:/"));

Map<String, String> modulesRelativePaths = Collections.singletonMap("project:module1", "module1_path");
ComponentUuidFactoryWithMigration underTest =
new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), mainBranch, pathToKey, modulesRelativePaths);

// project remains the same
assertThat(underTest.getOrCreateForKey(project.getKey())).isEqualTo(project.uuid());

// module migrated to folder
assertThat(underTest.getOrCreateForKey("project:module1_path")).isEqualTo(module1.uuid());
}

@Test
public void dont_override_root_uuid_if_module_path_is_not_sent() {
ComponentDto project = db.components().insertPrivateProject(dto -> dto.setKey("project"));
ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
.setKey("project:module1")
.setEnabled(false));
ComponentDto module2 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
.setKey("project:module2")
.setEnabled(false));
Map<String, String> modulesRelativePaths = new HashMap<>();
modulesRelativePaths.put("project", "");
modulesRelativePaths.put("project:module2", "module2");
ComponentUuidFactoryWithMigration underTest =
new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), project.getKey(), mainBranch, pathToKey, modulesRelativePaths);

// check root project.
assertThat(underTest.getOrCreateForKey("project")).isEqualTo(project.uuid());
}

@Test
public void generate_uuid_if_it_does_not_exist_in_db() {
ComponentUuidFactoryWithMigration underTest =
new ComponentUuidFactoryWithMigration(db.getDbClient(), db.getSession(), "theProjectKey", mainBranch, pathToKey, Collections.emptyMap());

String generatedKey = underTest.getOrCreateForKey("foo");
assertThat(generatedKey).isNotEmpty();

// uuid is kept in memory for further calls with same key
assertThat(underTest.getOrCreateForKey("foo")).isEqualTo(generatedKey);
}

}

+ 0
- 2
server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java Ver fichero

@@ -52,7 +52,6 @@ import org.sonar.db.component.BranchMapper;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentKeyUpdaterMapper;
import org.sonar.db.component.ComponentMapper;
import org.sonar.db.component.ComponentWithModuleUuidDto;
import org.sonar.db.component.FilePathWithHashDto;
import org.sonar.db.component.KeyWithUuidDto;
import org.sonar.db.component.PrBranchAnalyzedLanguageCountByProjectDto;
@@ -192,7 +191,6 @@ public class MyBatis {
confBuilder.loadAlias("ApplicationProject", ApplicationProjectDto.class);
confBuilder.loadAlias("CeTaskCharacteristic", CeTaskCharacteristicDto.class);
confBuilder.loadAlias("Component", ComponentDto.class);
confBuilder.loadAlias("ComponentWithModuleUuid", ComponentWithModuleUuidDto.class);
confBuilder.loadAlias("DuplicationUnit", DuplicationUnitDto.class);
confBuilder.loadAlias("Event", EventDto.class);
confBuilder.loadAlias("FilePathWithHash", FilePathWithHashDto.class);

+ 0
- 15
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java Ver fichero

@@ -105,10 +105,6 @@ public class ComponentDao implements Dao {
return mapper(dbSession).selectByBranchUuid(branchUuid);
}

public int countEnabledModulesByBranchUuid(DbSession session, String branchUuid) {
return mapper(session).countEnabledModulesByBranchUuid(branchUuid);
}

/*
SELECT BY QUERY
*/
@@ -175,13 +171,6 @@ public class ComponentDao implements Dao {
return mapper(session).selectComponentsFromProjectKeyAndScope(projectKey, Scopes.PROJECT, excludeDisabled, branch, pullRequest);
}

/**
* If no branch or pull request is provided, returns components in the main branch
*/
public List<ComponentDto> selectEnabledModulesFromProjectKey(DbSession session, String projectKey, @Nullable String branch, @Nullable String pullRequest) {
return selectProjectAndModulesFromProjectKey(session, projectKey, true, branch, pullRequest);
}

public List<ComponentDto> selectByKeys(DbSession session, Collection<String> keys) {
return selectByKeys(session, keys, null, null);
}
@@ -301,10 +290,6 @@ public class ComponentDao implements Dao {
return new HashSet<>(mapper(dbSession).selectComponentsByQualifiers(qualifiers));
}

public List<ComponentWithModuleUuidDto> selectEnabledComponentsWithModuleUuidFromProjectKey(DbSession dbSession, String projectKey) {
return mapper(dbSession).selectEnabledComponentsWithModuleUuidFromProjectKey(projectKey);
}

/**
* Returns components with open issues from P/Rs that use a certain branch as reference (reference branch).
* Excludes components from the current branch.

+ 0
- 4
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java Ver fichero

@@ -54,8 +54,6 @@ public interface ComponentMapper {

List<ComponentDto> selectComponentsByQualifiers(@Param("qualifiers") Collection<String> qualifiers);

int countEnabledModulesByBranchUuid(@Param("branchUuid") String branchUuid);

List<ComponentDto> selectByQuery(@Param("query") ComponentQuery query, RowBounds rowBounds);

int countByQuery(@Param("query") ComponentQuery query);
@@ -139,7 +137,5 @@ public interface ComponentMapper {

List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc();

List<ComponentWithModuleUuidDto> selectEnabledComponentsWithModuleUuidFromProjectKey(String projectKey);

short checkIfAnyOfComponentsWithQualifiers(@Param("componentKeys") Collection<String> componentKeys, @Param("qualifiers") Set<String> qualifiers);
}

+ 0
- 19
server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml Ver fichero

@@ -257,16 +257,6 @@
</foreach>
</select>

<select id="countEnabledModulesByBranchUuid" resultType="int">
select
count(1)
from components p
where
p.enabled=${_true}
and p.branch_uuid = #{branchUuid,jdbcType=VARCHAR}
and p.qualifier = 'BRC'
</select>

<select id="selectByQuery" resultType="Component">
select
<include refid="componentColumns"/>
@@ -541,15 +531,6 @@
p.branch_uuid = #{branchUuid,jdbcType=VARCHAR}
</select>

<select id="selectEnabledComponentsWithModuleUuidFromProjectKey" resultType="ComponentWithModuleUuid">
SELECT
p.uuid as uuid, p.module_uuid as moduleUuid, p.path as path, p.scope as scope
FROM
components p
INNER JOIN
components root ON root.uuid=p.branch_uuid AND p.enabled = ${_true} AND root.kee=#{projectKey,jdbcType=VARCHAR}
</select>

<select id="selectUuidsByKeyFromProjectKeyAndBranchOrPr" parameterType="string" resultType="KeyWithUuid">
SELECT
p.kee, p.uuid

+ 0
- 88
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java Ver fichero

@@ -407,20 +407,6 @@ public class ComponentDaoTest {
.hasMessage("Qualifiers cannot be empty");
}

@Test
public void count_enabled_modules_by_project_uuid() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto module = db.components().insertComponent(newModuleDto(project));
db.components().insertComponent(newModuleDto(module));
ComponentDto subModule2 = newModuleDto(module);
subModule2.setEnabled(false);
db.components().insertComponent(subModule2);

int result = underTest.countEnabledModulesByBranchUuid(dbSession, project.uuid());

assertThat(result).isEqualTo(2);
}

@Test
public void find_sub_projects_by_component_keys() {
ComponentDto project = db.components().insertPrivateProject();
@@ -504,29 +490,6 @@ public class ComponentDaoTest {
assertThat(underTest.selectEnabledDescendantModules(dbSession, "unknown")).isEmpty();
}

@Test
public void select_enabled_components_with_module_dto() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto module = db.components().insertComponent(newModuleDto(project));
ComponentDto removedModule = db.components().insertComponent(newModuleDto(project).setEnabled(false));
ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
ComponentDto removedSubModule = db.components().insertComponent(newModuleDto(module).setEnabled(false));
ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
ComponentDto removedDirectory = db.components().insertComponent(newDirectory(subModule, "src2").setEnabled(false));
ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));

// From root project
assertThat(underTest.selectEnabledComponentsWithModuleUuidFromProjectKey(dbSession, project.getKey()))
.extracting(ComponentWithModuleUuidDto::uuid)
.containsExactlyInAnyOrder(
project.uuid(),
module.uuid(),
subModule.uuid(),
directory.uuid(),
file.uuid());
}

@Test
public void select_all_modules_tree() {
ComponentDto project = db.components().insertPrivateProject();
@@ -718,57 +681,6 @@ public class ComponentDaoTest {
entry(file.getKey(), file.uuid()));
}

@Test
public void select_enabled_modules_from_project() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto removedProject = db.components().insertPrivateProject(p -> p.setEnabled(false));
ComponentDto module = db.components().insertComponent(newModuleDto(project));
ComponentDto removedModule = db.components().insertComponent(newModuleDto(project).setEnabled(false));
ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
ComponentDto removedSubModule = db.components().insertComponent(newModuleDto(module).setEnabled(false));
ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
ComponentDto removedDirectory = db.components().insertComponent(newDirectory(subModule, "src2").setEnabled(false));
ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));

// Removed modules are not included
assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getKey(), null, null))
.extracting(ComponentDto::getKey)
.containsExactlyInAnyOrder(project.getKey(), module.getKey(), subModule.getKey());

assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, "UNKNOWN", null, null)).isEmpty();
}

@Test
public void select_enabled_modules_from_branch() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("branch1"));
ComponentDto module = db.components().insertComponent(newModuleDto(branch));
ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));

// Removed modules are not included
assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getKey(), "branch1", null))
.extracting(ComponentDto::getKey)
.containsExactlyInAnyOrder(project.getKey(), module.getKey(), subModule.getKey());
}

@Test
public void select_enabled_modules_from_pr() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(PULL_REQUEST).setKey("pr1"));
ComponentDto module = db.components().insertComponent(newModuleDto(branch));
ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
ComponentDto directory = db.components().insertComponent(newDirectory(subModule, "src"));
ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));

// Removed modules are not included
assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getKey(), null, "pr1"))
.extracting(ComponentDto::getKey)
.containsExactlyInAnyOrder(project.getKey(), module.getKey(), subModule.getKey());
}

@Test
public void select_views_and_sub_views_and_applications() {
db.components().insertPublicPortfolio("ABCD", p -> {

+ 3
- 3
server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java Ver fichero

@@ -26,8 +26,8 @@ import org.sonar.db.component.ComponentTesting;
import org.sonar.server.es.textsearch.ComponentTextSearchFeatureRepertoire;

import static java.util.Arrays.asList;
import static org.sonar.api.resources.Qualifiers.DIRECTORY;
import static org.sonar.api.resources.Qualifiers.FILE;
import static org.sonar.api.resources.Qualifiers.MODULE;
import static org.sonar.api.resources.Qualifiers.PROJECT;

public class ComponentIndexScoreTest extends ComponentIndexTest {
@@ -121,14 +121,14 @@ public class ComponentIndexScoreTest extends ComponentIndexTest {

assertSearch(SuggestionQuery.builder()
.setQuery("File")
.setQualifiers(asList(PROJECT, MODULE, FILE))
.setQualifiers(asList(PROJECT, DIRECTORY, FILE))
.setRecentlyBrowsedKeys(ImmutableSet.of(file1.getKey()))
.setFavoriteKeys(ImmutableSet.of(file2.getKey()))
.build()).containsExactly(uuids(file2, file1));

assertSearch(SuggestionQuery.builder()
.setQuery("File")
.setQualifiers(asList(PROJECT, MODULE, FILE))
.setQualifiers(asList(PROJECT, DIRECTORY, FILE))
.setRecentlyBrowsedKeys(ImmutableSet.of(file2.getKey()))
.setFavoriteKeys(ImmutableSet.of(file1.getKey()))
.build()).containsExactly(uuids(file1, file2));

+ 2
- 3
server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java Ver fichero

@@ -37,7 +37,6 @@ import org.sonar.server.tester.UserSessionRule;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.api.resources.Qualifiers.FILE;
import static org.sonar.api.resources.Qualifiers.MODULE;
import static org.sonar.api.resources.Qualifiers.PROJECT;

public abstract class ComponentIndexTest {
@@ -85,7 +84,7 @@ public abstract class ComponentIndexTest {
}

protected ListAssert<String> assertSearch(String query) {
return assertSearch(SuggestionQuery.builder().setQuery(query).setQualifiers(asList(PROJECT, MODULE, FILE)).build());
return assertSearch(SuggestionQuery.builder().setQuery(query).setQualifiers(asList(PROJECT, FILE)).build());
}

protected ListAssert<String> assertSearch(SuggestionQuery query) {
@@ -95,7 +94,7 @@ public abstract class ComponentIndexTest {
}

protected void assertSearchResults(String query, ComponentDto... expectedComponents) {
assertSearchResults(SuggestionQuery.builder().setQuery(query).setQualifiers(asList(PROJECT, MODULE, FILE)).build(), expectedComponents);
assertSearchResults(SuggestionQuery.builder().setQuery(query).setQualifiers(asList(PROJECT, FILE)).build(), expectedComponents);
}

protected void assertSearchResults(SuggestionQuery query, ComponentDto... expectedComponents) {

+ 1
- 5
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java Ver fichero

@@ -130,11 +130,7 @@ public class SearchAction implements ComponentsWsAction {
Set<String> projectUuidsToSearch = components.stream()
.map(ComponentDto::branchUuid)
.collect(toHashSet());
List<ComponentDto> projects = dbClient.componentDao()
.selectByUuids(dbSession, projectUuidsToSearch)
.stream()
.filter(c -> !c.qualifier().equals(Qualifiers.MODULE))
.toList();
List<ComponentDto> projects = dbClient.componentDao().selectByUuids(dbSession, projectUuidsToSearch);
return projects.stream().collect(toMap(ComponentDto::uuid, ComponentDto::getKey));
}


+ 4
- 4
server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingValidations.java Ver fichero

@@ -61,7 +61,7 @@ public class SettingValidations {
"sonar.security.config.pythonsecurity",
"sonar.security.config.roslyn.sonaranalyzer.security.cs"
);
private static final Set<String> SUPPORTED_QUALIFIERS = Set.of(Qualifiers.PROJECT, Qualifiers.VIEW, Qualifiers.APP, Qualifiers.MODULE, Qualifiers.SUBVIEW);
private static final Set<String> SUPPORTED_QUALIFIERS = Set.of(Qualifiers.PROJECT, Qualifiers.VIEW, Qualifiers.APP, Qualifiers.SUBVIEW);

private final PropertyDefinitions definitions;
private final DbClient dbClient;
@@ -180,16 +180,16 @@ public class SettingValidations {
validateJsonSchema(jsonContent.get(), definition);
} catch (ValidationException e) {
throw new IllegalArgumentException(String.format("Provided JSON is invalid [%s]", e.getMessage()));
} catch (IOException e){
} catch (IOException e) {
throw new IllegalArgumentException("Provided JSON is invalid");
}
}
}

private void validateJsonSchema(String json, PropertyDefinition definition) {
if(SECURITY_JSON_PROPERTIES.contains(definition.key())){
if (SECURITY_JSON_PROPERTIES.contains(definition.key())) {
InputStream jsonSchemaInputStream = this.getClass().getClassLoader().getResourceAsStream("json-schemas/security.json");
if(jsonSchemaInputStream != null){
if (jsonSchemaInputStream != null) {
JSONObject jsonSchema = new JSONObject(new JSONTokener(jsonSchemaInputStream));
JSONObject jsonSubject = new JSONObject(new JSONTokener(json));
SchemaLoader.load(jsonSchema).validate(jsonSubject);

+ 5
- 8
server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java Ver fichero

@@ -50,7 +50,6 @@ import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.groups.Tuple.tuple;
import static org.sonar.api.resources.Qualifiers.MODULE;
import static org.sonar.api.resources.Qualifiers.PROJECT;
import static org.sonar.api.web.UserRole.ADMIN;
import static org.sonar.api.web.UserRole.CODEVIEWER;
@@ -193,9 +192,9 @@ public class ListDefinitionsActionTest {
public void return_JSON_property() {
logIn();
propertyDefinitions.addComponent(PropertyDefinition
.builder("foo")
.type(PropertyType.JSON)
.build());
.builder("foo")
.type(PropertyType.JSON)
.build());

ListDefinitionsWsResponse result = executeRequest();

@@ -293,8 +292,7 @@ public class ListDefinitionsActionTest {
propertyDefinitions.addComponents(asList(
PropertyDefinition.builder("global").build(),
PropertyDefinition.builder("global-and-project").onQualifiers(PROJECT).build(),
PropertyDefinition.builder("only-on-project").onlyOnQualifiers(PROJECT).build(),
PropertyDefinition.builder("only-on-module").onlyOnQualifiers(MODULE).build()));
PropertyDefinition.builder("only-on-project").onlyOnQualifiers(PROJECT).build()));

ListDefinitionsWsResponse result = executeRequest();

@@ -307,8 +305,7 @@ public class ListDefinitionsActionTest {
propertyDefinitions.addComponents(asList(
PropertyDefinition.builder("global").build(),
PropertyDefinition.builder("global-and-project").onQualifiers(PROJECT).build(),
PropertyDefinition.builder("only-on-project").onlyOnQualifiers(PROJECT).build(),
PropertyDefinition.builder("only-on-module").onlyOnQualifiers(MODULE).build()));
PropertyDefinition.builder("only-on-project").onlyOnQualifiers(PROJECT).build()));

ListDefinitionsWsResponse result = executeRequest(project.getKey());


+ 2
- 3
sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java Ver fichero

@@ -19,11 +19,11 @@
*/
package org.sonar.core.component;

import org.sonar.api.scanner.ScannerSide;
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceType;
import org.sonar.api.resources.ResourceTypeTree;
import org.sonar.api.scanner.ScannerSide;
import org.sonar.api.server.ServerSide;

@ScannerSide
@@ -61,8 +61,7 @@ public final class DefaultResourceTypes {
.hasSourceCode()
.build())

.addRelations(Qualifiers.PROJECT, Qualifiers.MODULE)
.addRelations(Qualifiers.MODULE, Qualifiers.DIRECTORY)
.addRelations(Qualifiers.PROJECT, Qualifiers.DIRECTORY)
.addRelations(Qualifiers.DIRECTORY, Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE)

.build();

+ 7
- 3
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java Ver fichero

@@ -31,7 +31,10 @@ import org.sonar.api.resources.Qualifiers;
import org.sonar.core.extension.PluginRiskConsent;

import static java.util.Arrays.asList;
import static org.sonar.api.PropertyType.*;
import static org.sonar.api.PropertyType.BOOLEAN;
import static org.sonar.api.PropertyType.SINGLE_SELECT_LIST;
import static org.sonar.api.PropertyType.STRING;
import static org.sonar.api.PropertyType.TEXT;
import static org.sonar.core.extension.PluginRiskConsent.NOT_ACCEPTED;

public class CorePropertyDefinitions {
@@ -73,7 +76,8 @@ public class CorePropertyDefinitions {
.build(),
PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL)
.name("Server base URL")
.description("HTTP(S) URL of this SonarQube server, such as <i>https://yourhost.yourdomain/sonar</i>. This value is used outside SonarQube itself, e.g. for PR decoration, emails, etc.")
.description(
"HTTP(S) URL of this SonarQube server, such as <i>https://yourhost.yourdomain/sonar</i>. This value is used outside SonarQube itself, e.g. for PR decoration, emails, etc.")
.category(CoreProperties.CATEGORY_GENERAL)
.build(),
PropertyDefinition.builder(SONAR_PROJECTCREATION_MAINBRANCHNAME)
@@ -196,7 +200,7 @@ public class CorePropertyDefinitions {
.name("Duplication Exclusions")
.description("Patterns used to exclude some source files from the duplication detection mechanism. " +
"See below to know how to use wildcards to specify this property.")
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.onQualifiers(Qualifiers.PROJECT)
.category(CoreProperties.CATEGORY_EXCLUSIONS)
.subCategory(CoreProperties.SUBCATEGORY_DUPLICATIONS_EXCLUSIONS)
.multiValues(true)

+ 1
- 1
sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java Ver fichero

@@ -41,7 +41,7 @@ public class ExclusionProperties {
.subCategory(CoreProperties.SUBCATEGORY_COVERAGE_EXCLUSIONS)
.type(PropertyType.STRING)
.multiValues(true)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.onQualifiers(Qualifiers.PROJECT)
.build(),

// FILES

+ 1
- 1
sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java Ver fichero

@@ -31,6 +31,6 @@ public class DefaultResourceTypesTest {
ResourceTypeTree tree = DefaultResourceTypes.get();

assertThat(tree.getTypes()).hasSize(5);
assertThat(tree.getChildren(Qualifiers.PROJECT)).containsExactly(Qualifiers.MODULE);
assertThat(tree.getChildren(Qualifiers.PROJECT)).containsExactly(Qualifiers.DIRECTORY);
}
}

+ 0
- 1
sonar-ws/src/main/java/org/sonarqube/ws/client/issues/SearchRequest.java Ver fichero

@@ -266,7 +266,6 @@ public class SearchRequest {
* Possible values:
* <ul>
* <li>"projects"</li>
* <li>"moduleUuids"</li>
* <li>"fileUuids"</li>
* <li>"assigned_to_me"</li>
* <li>"severities"</li>

Cargando…
Cancelar
Guardar