id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
16,200
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/utils/ParsingUtils.java
|
ParsingUtils.parseNumber
|
public static double parseNumber(String number, Locale locale) throws ParseException {
if ("".equals(number)) {
return Double.NaN;
}
return NumberFormat.getNumberInstance(locale).parse(number).doubleValue();
}
|
java
|
public static double parseNumber(String number, Locale locale) throws ParseException {
if ("".equals(number)) {
return Double.NaN;
}
return NumberFormat.getNumberInstance(locale).parse(number).doubleValue();
}
|
[
"public",
"static",
"double",
"parseNumber",
"(",
"String",
"number",
",",
"Locale",
"locale",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"number",
")",
")",
"{",
"return",
"Double",
".",
"NaN",
";",
"}",
"return",
"NumberFormat",
".",
"getNumberInstance",
"(",
"locale",
")",
".",
"parse",
"(",
"number",
")",
".",
"doubleValue",
"(",
")",
";",
"}"
] |
Parses a string with a locale and returns the corresponding number
@throws ParseException if number cannot be parsed
|
[
"Parses",
"a",
"string",
"with",
"a",
"locale",
"and",
"returns",
"the",
"corresponding",
"number"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ParsingUtils.java#L43-L48
|
16,201
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/utils/ParsingUtils.java
|
ParsingUtils.scaleValue
|
public static double scaleValue(double value, int decimals) {
BigDecimal bd = BigDecimal.valueOf(value);
return bd.setScale(decimals, RoundingMode.HALF_UP).doubleValue();
}
|
java
|
public static double scaleValue(double value, int decimals) {
BigDecimal bd = BigDecimal.valueOf(value);
return bd.setScale(decimals, RoundingMode.HALF_UP).doubleValue();
}
|
[
"public",
"static",
"double",
"scaleValue",
"(",
"double",
"value",
",",
"int",
"decimals",
")",
"{",
"BigDecimal",
"bd",
"=",
"BigDecimal",
".",
"valueOf",
"(",
"value",
")",
";",
"return",
"bd",
".",
"setScale",
"(",
"decimals",
",",
"RoundingMode",
".",
"HALF_UP",
")",
".",
"doubleValue",
"(",
")",
";",
"}"
] |
Scales a double value with decimals
|
[
"Scales",
"a",
"double",
"value",
"with",
"decimals"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ParsingUtils.java#L69-L72
|
16,202
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java
|
UserPermissionDao.selectUserPermissionsByQuery
|
public List<UserPermissionDto> selectUserPermissionsByQuery(DbSession dbSession, PermissionQuery query, Collection<Integer> userIds) {
if (userIds.isEmpty()) {
return emptyList();
}
checkArgument(userIds.size() <= DatabaseUtils.PARTITION_SIZE_FOR_ORACLE, "Maximum 1'000 users are accepted");
return mapper(dbSession).selectUserPermissionsByQueryAndUserIds(query, userIds);
}
|
java
|
public List<UserPermissionDto> selectUserPermissionsByQuery(DbSession dbSession, PermissionQuery query, Collection<Integer> userIds) {
if (userIds.isEmpty()) {
return emptyList();
}
checkArgument(userIds.size() <= DatabaseUtils.PARTITION_SIZE_FOR_ORACLE, "Maximum 1'000 users are accepted");
return mapper(dbSession).selectUserPermissionsByQueryAndUserIds(query, userIds);
}
|
[
"public",
"List",
"<",
"UserPermissionDto",
">",
"selectUserPermissionsByQuery",
"(",
"DbSession",
"dbSession",
",",
"PermissionQuery",
"query",
",",
"Collection",
"<",
"Integer",
">",
"userIds",
")",
"{",
"if",
"(",
"userIds",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"emptyList",
"(",
")",
";",
"}",
"checkArgument",
"(",
"userIds",
".",
"size",
"(",
")",
"<=",
"DatabaseUtils",
".",
"PARTITION_SIZE_FOR_ORACLE",
",",
"\"Maximum 1'000 users are accepted\"",
")",
";",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectUserPermissionsByQueryAndUserIds",
"(",
"query",
",",
"userIds",
")",
";",
"}"
] |
List of user permissions ordered by alphabetical order of user names.
Pagination is NOT applied.
No sort is done.
@param query non-null query including optional filters.
@param userIds Filter on user ids, including disabled users. Must not be empty and maximum size is {@link DatabaseUtils#PARTITION_SIZE_FOR_ORACLE}.
|
[
"List",
"of",
"user",
"permissions",
"ordered",
"by",
"alphabetical",
"order",
"of",
"user",
"names",
".",
"Pagination",
"is",
"NOT",
"applied",
".",
"No",
"sort",
"is",
"done",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java#L45-L51
|
16,203
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java
|
UserPermissionDao.countUsersByProjectPermission
|
public List<CountPerProjectPermission> countUsersByProjectPermission(DbSession dbSession, Collection<Long> projectIds) {
return executeLargeInputs(projectIds, mapper(dbSession)::countUsersByProjectPermission);
}
|
java
|
public List<CountPerProjectPermission> countUsersByProjectPermission(DbSession dbSession, Collection<Long> projectIds) {
return executeLargeInputs(projectIds, mapper(dbSession)::countUsersByProjectPermission);
}
|
[
"public",
"List",
"<",
"CountPerProjectPermission",
">",
"countUsersByProjectPermission",
"(",
"DbSession",
"dbSession",
",",
"Collection",
"<",
"Long",
">",
"projectIds",
")",
"{",
"return",
"executeLargeInputs",
"(",
"projectIds",
",",
"mapper",
"(",
"dbSession",
")",
"::",
"countUsersByProjectPermission",
")",
";",
"}"
] |
Count the number of users per permission for a given list of projects
@param projectIds a non-null list of project ids to filter on. If empty then an empty list is returned.
|
[
"Count",
"the",
"number",
"of",
"users",
"per",
"permission",
"for",
"a",
"given",
"list",
"of",
"projects"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java#L71-L73
|
16,204
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java
|
UserPermissionDao.selectGlobalPermissionsOfUser
|
public List<String> selectGlobalPermissionsOfUser(DbSession dbSession, int userId, String organizationUuid) {
return mapper(dbSession).selectGlobalPermissionsOfUser(userId, organizationUuid);
}
|
java
|
public List<String> selectGlobalPermissionsOfUser(DbSession dbSession, int userId, String organizationUuid) {
return mapper(dbSession).selectGlobalPermissionsOfUser(userId, organizationUuid);
}
|
[
"public",
"List",
"<",
"String",
">",
"selectGlobalPermissionsOfUser",
"(",
"DbSession",
"dbSession",
",",
"int",
"userId",
",",
"String",
"organizationUuid",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectGlobalPermissionsOfUser",
"(",
"userId",
",",
"organizationUuid",
")",
";",
"}"
] |
Gets all the global permissions granted to user for the specified organization.
@return the global permissions. An empty list is returned if user or organization do not exist.
|
[
"Gets",
"all",
"the",
"global",
"permissions",
"granted",
"to",
"user",
"for",
"the",
"specified",
"organization",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java#L80-L82
|
16,205
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java
|
UserPermissionDao.selectProjectPermissionsOfUser
|
public List<String> selectProjectPermissionsOfUser(DbSession dbSession, int userId, long projectId) {
return mapper(dbSession).selectProjectPermissionsOfUser(userId, projectId);
}
|
java
|
public List<String> selectProjectPermissionsOfUser(DbSession dbSession, int userId, long projectId) {
return mapper(dbSession).selectProjectPermissionsOfUser(userId, projectId);
}
|
[
"public",
"List",
"<",
"String",
">",
"selectProjectPermissionsOfUser",
"(",
"DbSession",
"dbSession",
",",
"int",
"userId",
",",
"long",
"projectId",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectProjectPermissionsOfUser",
"(",
"userId",
",",
"projectId",
")",
";",
"}"
] |
Gets all the project permissions granted to user for the specified project.
@return the project permissions. An empty list is returned if project or user do not exist.
|
[
"Gets",
"all",
"the",
"project",
"permissions",
"granted",
"to",
"user",
"for",
"the",
"specified",
"project",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java#L89-L91
|
16,206
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java
|
UserPermissionDao.deleteGlobalPermission
|
public void deleteGlobalPermission(DbSession dbSession, int userId, String permission, String organizationUuid) {
mapper(dbSession).deleteGlobalPermission(userId, permission, organizationUuid);
}
|
java
|
public void deleteGlobalPermission(DbSession dbSession, int userId, String permission, String organizationUuid) {
mapper(dbSession).deleteGlobalPermission(userId, permission, organizationUuid);
}
|
[
"public",
"void",
"deleteGlobalPermission",
"(",
"DbSession",
"dbSession",
",",
"int",
"userId",
",",
"String",
"permission",
",",
"String",
"organizationUuid",
")",
"{",
"mapper",
"(",
"dbSession",
")",
".",
"deleteGlobalPermission",
"(",
"userId",
",",
"permission",
",",
"organizationUuid",
")",
";",
"}"
] |
Removes a single global permission from user
|
[
"Removes",
"a",
"single",
"global",
"permission",
"from",
"user"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java#L116-L118
|
16,207
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java
|
UserPermissionDao.deleteProjectPermission
|
public void deleteProjectPermission(DbSession dbSession, int userId, String permission, long projectId) {
mapper(dbSession).deleteProjectPermission(userId, permission, projectId);
}
|
java
|
public void deleteProjectPermission(DbSession dbSession, int userId, String permission, long projectId) {
mapper(dbSession).deleteProjectPermission(userId, permission, projectId);
}
|
[
"public",
"void",
"deleteProjectPermission",
"(",
"DbSession",
"dbSession",
",",
"int",
"userId",
",",
"String",
"permission",
",",
"long",
"projectId",
")",
"{",
"mapper",
"(",
"dbSession",
")",
".",
"deleteProjectPermission",
"(",
"userId",
",",
"permission",
",",
"projectId",
")",
";",
"}"
] |
Removes a single project permission from user
|
[
"Removes",
"a",
"single",
"project",
"permission",
"from",
"user"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java#L123-L125
|
16,208
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java
|
UserPermissionDao.deleteProjectPermissionOfAnyUser
|
public int deleteProjectPermissionOfAnyUser(DbSession dbSession, long projectId, String permission) {
return mapper(dbSession).deleteProjectPermissionOfAnyUser(projectId, permission);
}
|
java
|
public int deleteProjectPermissionOfAnyUser(DbSession dbSession, long projectId, String permission) {
return mapper(dbSession).deleteProjectPermissionOfAnyUser(projectId, permission);
}
|
[
"public",
"int",
"deleteProjectPermissionOfAnyUser",
"(",
"DbSession",
"dbSession",
",",
"long",
"projectId",
",",
"String",
"permission",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"deleteProjectPermissionOfAnyUser",
"(",
"projectId",
",",
"permission",
")",
";",
"}"
] |
Deletes the specified permission on the specified project for any user.
|
[
"Deletes",
"the",
"specified",
"permission",
"on",
"the",
"specified",
"project",
"for",
"any",
"user",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java#L137-L139
|
16,209
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java
|
PluginClassloaderFactory.create
|
public Map<PluginClassLoaderDef, ClassLoader> create(Collection<PluginClassLoaderDef> defs) {
ClassLoader baseClassLoader = baseClassLoader();
ClassloaderBuilder builder = new ClassloaderBuilder();
builder.newClassloader(API_CLASSLOADER_KEY, baseClassLoader);
builder.setMask(API_CLASSLOADER_KEY, apiMask());
for (PluginClassLoaderDef def : defs) {
builder.newClassloader(def.getBasePluginKey());
builder.setParent(def.getBasePluginKey(), API_CLASSLOADER_KEY, new Mask());
builder.setLoadingOrder(def.getBasePluginKey(), def.isSelfFirstStrategy() ? SELF_FIRST : PARENT_FIRST);
for (File jar : def.getFiles()) {
builder.addURL(def.getBasePluginKey(), fileToUrl(jar));
}
exportResources(def, builder, defs);
}
return build(defs, builder);
}
|
java
|
public Map<PluginClassLoaderDef, ClassLoader> create(Collection<PluginClassLoaderDef> defs) {
ClassLoader baseClassLoader = baseClassLoader();
ClassloaderBuilder builder = new ClassloaderBuilder();
builder.newClassloader(API_CLASSLOADER_KEY, baseClassLoader);
builder.setMask(API_CLASSLOADER_KEY, apiMask());
for (PluginClassLoaderDef def : defs) {
builder.newClassloader(def.getBasePluginKey());
builder.setParent(def.getBasePluginKey(), API_CLASSLOADER_KEY, new Mask());
builder.setLoadingOrder(def.getBasePluginKey(), def.isSelfFirstStrategy() ? SELF_FIRST : PARENT_FIRST);
for (File jar : def.getFiles()) {
builder.addURL(def.getBasePluginKey(), fileToUrl(jar));
}
exportResources(def, builder, defs);
}
return build(defs, builder);
}
|
[
"public",
"Map",
"<",
"PluginClassLoaderDef",
",",
"ClassLoader",
">",
"create",
"(",
"Collection",
"<",
"PluginClassLoaderDef",
">",
"defs",
")",
"{",
"ClassLoader",
"baseClassLoader",
"=",
"baseClassLoader",
"(",
")",
";",
"ClassloaderBuilder",
"builder",
"=",
"new",
"ClassloaderBuilder",
"(",
")",
";",
"builder",
".",
"newClassloader",
"(",
"API_CLASSLOADER_KEY",
",",
"baseClassLoader",
")",
";",
"builder",
".",
"setMask",
"(",
"API_CLASSLOADER_KEY",
",",
"apiMask",
"(",
")",
")",
";",
"for",
"(",
"PluginClassLoaderDef",
"def",
":",
"defs",
")",
"{",
"builder",
".",
"newClassloader",
"(",
"def",
".",
"getBasePluginKey",
"(",
")",
")",
";",
"builder",
".",
"setParent",
"(",
"def",
".",
"getBasePluginKey",
"(",
")",
",",
"API_CLASSLOADER_KEY",
",",
"new",
"Mask",
"(",
")",
")",
";",
"builder",
".",
"setLoadingOrder",
"(",
"def",
".",
"getBasePluginKey",
"(",
")",
",",
"def",
".",
"isSelfFirstStrategy",
"(",
")",
"?",
"SELF_FIRST",
":",
"PARENT_FIRST",
")",
";",
"for",
"(",
"File",
"jar",
":",
"def",
".",
"getFiles",
"(",
")",
")",
"{",
"builder",
".",
"addURL",
"(",
"def",
".",
"getBasePluginKey",
"(",
")",
",",
"fileToUrl",
"(",
"jar",
")",
")",
";",
"}",
"exportResources",
"(",
"def",
",",
"builder",
",",
"defs",
")",
";",
"}",
"return",
"build",
"(",
"defs",
",",
"builder",
")",
";",
"}"
] |
Creates as many classloaders as requested by the input parameter.
|
[
"Creates",
"as",
"many",
"classloaders",
"as",
"requested",
"by",
"the",
"input",
"parameter",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java#L56-L74
|
16,210
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java
|
PluginClassloaderFactory.exportResources
|
private void exportResources(PluginClassLoaderDef def, ClassloaderBuilder builder, Collection<PluginClassLoaderDef> allPlugins) {
// export the resources to all other plugins
builder.setExportMask(def.getBasePluginKey(), def.getExportMask());
for (PluginClassLoaderDef other : allPlugins) {
if (!other.getBasePluginKey().equals(def.getBasePluginKey())) {
builder.addSibling(def.getBasePluginKey(), other.getBasePluginKey(), new Mask());
}
}
}
|
java
|
private void exportResources(PluginClassLoaderDef def, ClassloaderBuilder builder, Collection<PluginClassLoaderDef> allPlugins) {
// export the resources to all other plugins
builder.setExportMask(def.getBasePluginKey(), def.getExportMask());
for (PluginClassLoaderDef other : allPlugins) {
if (!other.getBasePluginKey().equals(def.getBasePluginKey())) {
builder.addSibling(def.getBasePluginKey(), other.getBasePluginKey(), new Mask());
}
}
}
|
[
"private",
"void",
"exportResources",
"(",
"PluginClassLoaderDef",
"def",
",",
"ClassloaderBuilder",
"builder",
",",
"Collection",
"<",
"PluginClassLoaderDef",
">",
"allPlugins",
")",
"{",
"// export the resources to all other plugins",
"builder",
".",
"setExportMask",
"(",
"def",
".",
"getBasePluginKey",
"(",
")",
",",
"def",
".",
"getExportMask",
"(",
")",
")",
";",
"for",
"(",
"PluginClassLoaderDef",
"other",
":",
"allPlugins",
")",
"{",
"if",
"(",
"!",
"other",
".",
"getBasePluginKey",
"(",
")",
".",
"equals",
"(",
"def",
".",
"getBasePluginKey",
"(",
")",
")",
")",
"{",
"builder",
".",
"addSibling",
"(",
"def",
".",
"getBasePluginKey",
"(",
")",
",",
"other",
".",
"getBasePluginKey",
"(",
")",
",",
"new",
"Mask",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
A plugin can export some resources to other plugins
|
[
"A",
"plugin",
"can",
"export",
"some",
"resources",
"to",
"other",
"plugins"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java#L79-L87
|
16,211
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java
|
PluginClassloaderFactory.build
|
private Map<PluginClassLoaderDef, ClassLoader> build(Collection<PluginClassLoaderDef> defs, ClassloaderBuilder builder) {
Map<PluginClassLoaderDef, ClassLoader> result = new HashMap<>();
Map<String, ClassLoader> classloadersByBasePluginKey = builder.build();
for (PluginClassLoaderDef def : defs) {
ClassLoader classloader = classloadersByBasePluginKey.get(def.getBasePluginKey());
if (classloader == null) {
throw new IllegalStateException(String.format("Fail to create classloader for plugin [%s]", def.getBasePluginKey()));
}
result.put(def, classloader);
}
return result;
}
|
java
|
private Map<PluginClassLoaderDef, ClassLoader> build(Collection<PluginClassLoaderDef> defs, ClassloaderBuilder builder) {
Map<PluginClassLoaderDef, ClassLoader> result = new HashMap<>();
Map<String, ClassLoader> classloadersByBasePluginKey = builder.build();
for (PluginClassLoaderDef def : defs) {
ClassLoader classloader = classloadersByBasePluginKey.get(def.getBasePluginKey());
if (classloader == null) {
throw new IllegalStateException(String.format("Fail to create classloader for plugin [%s]", def.getBasePluginKey()));
}
result.put(def, classloader);
}
return result;
}
|
[
"private",
"Map",
"<",
"PluginClassLoaderDef",
",",
"ClassLoader",
">",
"build",
"(",
"Collection",
"<",
"PluginClassLoaderDef",
">",
"defs",
",",
"ClassloaderBuilder",
"builder",
")",
"{",
"Map",
"<",
"PluginClassLoaderDef",
",",
"ClassLoader",
">",
"result",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Map",
"<",
"String",
",",
"ClassLoader",
">",
"classloadersByBasePluginKey",
"=",
"builder",
".",
"build",
"(",
")",
";",
"for",
"(",
"PluginClassLoaderDef",
"def",
":",
"defs",
")",
"{",
"ClassLoader",
"classloader",
"=",
"classloadersByBasePluginKey",
".",
"get",
"(",
"def",
".",
"getBasePluginKey",
"(",
")",
")",
";",
"if",
"(",
"classloader",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"Fail to create classloader for plugin [%s]\"",
",",
"def",
".",
"getBasePluginKey",
"(",
")",
")",
")",
";",
"}",
"result",
".",
"put",
"(",
"def",
",",
"classloader",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Builds classloaders and verifies that all of them are correctly defined
|
[
"Builds",
"classloaders",
"and",
"verifies",
"that",
"all",
"of",
"them",
"are",
"correctly",
"defined"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java#L92-L103
|
16,212
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ContextPropertiesCache.java
|
ContextPropertiesCache.put
|
public ContextPropertiesCache put(String key, String value) {
checkArgument(key != null, "Key of context property must not be null");
checkArgument(value != null, "Value of context property must not be null");
props.put(key, value);
return this;
}
|
java
|
public ContextPropertiesCache put(String key, String value) {
checkArgument(key != null, "Key of context property must not be null");
checkArgument(value != null, "Value of context property must not be null");
props.put(key, value);
return this;
}
|
[
"public",
"ContextPropertiesCache",
"put",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"checkArgument",
"(",
"key",
"!=",
"null",
",",
"\"Key of context property must not be null\"",
")",
";",
"checkArgument",
"(",
"value",
"!=",
"null",
",",
"\"Value of context property must not be null\"",
")",
";",
"props",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Value is overridden if the key was already stored.
@throws IllegalArgumentException if key is null
@throws IllegalArgumentException if value is null
@since 6.1
|
[
"Value",
"is",
"overridden",
"if",
"the",
"key",
"was",
"already",
"stored",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ContextPropertiesCache.java#L37-L42
|
16,213
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/FileUtils2.java
|
FileUtils2.deleteDirectory
|
public static void deleteDirectory(File directory) throws IOException {
requireNonNull(directory, DIRECTORY_CAN_NOT_BE_NULL);
if (!directory.exists()) {
return;
}
Path path = directory.toPath();
if (Files.isSymbolicLink(path)) {
throw new IOException(format("Directory '%s' is a symbolic link", directory));
}
if (directory.isFile()) {
throw new IOException(format("Directory '%s' is a file", directory));
}
deleteDirectoryImpl(path);
if (directory.exists()) {
throw new IOException(format("Unable to delete directory '%s'", directory));
}
}
|
java
|
public static void deleteDirectory(File directory) throws IOException {
requireNonNull(directory, DIRECTORY_CAN_NOT_BE_NULL);
if (!directory.exists()) {
return;
}
Path path = directory.toPath();
if (Files.isSymbolicLink(path)) {
throw new IOException(format("Directory '%s' is a symbolic link", directory));
}
if (directory.isFile()) {
throw new IOException(format("Directory '%s' is a file", directory));
}
deleteDirectoryImpl(path);
if (directory.exists()) {
throw new IOException(format("Unable to delete directory '%s'", directory));
}
}
|
[
"public",
"static",
"void",
"deleteDirectory",
"(",
"File",
"directory",
")",
"throws",
"IOException",
"{",
"requireNonNull",
"(",
"directory",
",",
"DIRECTORY_CAN_NOT_BE_NULL",
")",
";",
"if",
"(",
"!",
"directory",
".",
"exists",
"(",
")",
")",
"{",
"return",
";",
"}",
"Path",
"path",
"=",
"directory",
".",
"toPath",
"(",
")",
";",
"if",
"(",
"Files",
".",
"isSymbolicLink",
"(",
"path",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"format",
"(",
"\"Directory '%s' is a symbolic link\"",
",",
"directory",
")",
")",
";",
"}",
"if",
"(",
"directory",
".",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"format",
"(",
"\"Directory '%s' is a file\"",
",",
"directory",
")",
")",
";",
"}",
"deleteDirectoryImpl",
"(",
"path",
")",
";",
"if",
"(",
"directory",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"format",
"(",
"\"Unable to delete directory '%s'\"",
",",
"directory",
")",
")",
";",
"}",
"}"
] |
Deletes a directory recursively. Does not support symbolic link to directories.
@param directory directory to delete
@throws IOException in case deletion is unsuccessful
|
[
"Deletes",
"a",
"directory",
"recursively",
".",
"Does",
"not",
"support",
"symbolic",
"link",
"to",
"directories",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/FileUtils2.java#L98-L117
|
16,214
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/FileUtils2.java
|
FileUtils2.sizeOf
|
public static long sizeOf(Path path) throws IOException {
SizeVisitor visitor = new SizeVisitor();
Files.walkFileTree(path, visitor);
return visitor.size;
}
|
java
|
public static long sizeOf(Path path) throws IOException {
SizeVisitor visitor = new SizeVisitor();
Files.walkFileTree(path, visitor);
return visitor.size;
}
|
[
"public",
"static",
"long",
"sizeOf",
"(",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"SizeVisitor",
"visitor",
"=",
"new",
"SizeVisitor",
"(",
")",
";",
"Files",
".",
"walkFileTree",
"(",
"path",
",",
"visitor",
")",
";",
"return",
"visitor",
".",
"size",
";",
"}"
] |
Size of file or directory, in bytes. In case of a directory,
the size is the sum of the sizes of all files recursively traversed.
This implementation is recommended over commons-io
{@code FileUtils#sizeOf(File)} which suffers from slow usage of Java IO.
@throws IOException if files can't be traversed or size attribute is not present
@see BasicFileAttributes#size()
|
[
"Size",
"of",
"file",
"or",
"directory",
"in",
"bytes",
".",
"In",
"case",
"of",
"a",
"directory",
"the",
"size",
"is",
"the",
"sum",
"of",
"the",
"sizes",
"of",
"all",
"files",
"recursively",
"traversed",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/FileUtils2.java#L129-L133
|
16,215
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/sharedmemoryfile/DefaultProcessCommands.java
|
DefaultProcessCommands.reset
|
public static void reset(File directory, int processNumber) {
try (DefaultProcessCommands processCommands = new DefaultProcessCommands(directory, processNumber, true)) {
// nothing else to do than open file and reset the space of specified process
}
}
|
java
|
public static void reset(File directory, int processNumber) {
try (DefaultProcessCommands processCommands = new DefaultProcessCommands(directory, processNumber, true)) {
// nothing else to do than open file and reset the space of specified process
}
}
|
[
"public",
"static",
"void",
"reset",
"(",
"File",
"directory",
",",
"int",
"processNumber",
")",
"{",
"try",
"(",
"DefaultProcessCommands",
"processCommands",
"=",
"new",
"DefaultProcessCommands",
"(",
"directory",
",",
"processNumber",
",",
"true",
")",
")",
"{",
"// nothing else to do than open file and reset the space of specified process",
"}",
"}"
] |
Clears the shared memory space of the specified process number.
|
[
"Clears",
"the",
"shared",
"memory",
"space",
"of",
"the",
"specified",
"process",
"number",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/sharedmemoryfile/DefaultProcessCommands.java#L58-L62
|
16,216
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java
|
LoadReportAnalysisMetadataHolderStep.checkQualityProfilesConsistency
|
private void checkQualityProfilesConsistency(ScannerReport.Metadata metadata, Organization organization) {
List<String> profileKeys = metadata.getQprofilesPerLanguage().values().stream()
.map(QProfile::getKey)
.collect(toList(metadata.getQprofilesPerLanguage().size()));
try (DbSession dbSession = dbClient.openSession(false)) {
List<QProfileDto> profiles = dbClient.qualityProfileDao().selectByUuids(dbSession, profileKeys);
String badKeys = profiles.stream()
.filter(p -> !p.getOrganizationUuid().equals(organization.getUuid()))
.map(QProfileDto::getKee)
.collect(MoreCollectors.join(Joiner.on(", ")));
if (!badKeys.isEmpty()) {
throw MessageException.of(format("Quality profiles with following keys don't exist in organization [%s]: %s", organization.getKey(), badKeys));
}
}
}
|
java
|
private void checkQualityProfilesConsistency(ScannerReport.Metadata metadata, Organization organization) {
List<String> profileKeys = metadata.getQprofilesPerLanguage().values().stream()
.map(QProfile::getKey)
.collect(toList(metadata.getQprofilesPerLanguage().size()));
try (DbSession dbSession = dbClient.openSession(false)) {
List<QProfileDto> profiles = dbClient.qualityProfileDao().selectByUuids(dbSession, profileKeys);
String badKeys = profiles.stream()
.filter(p -> !p.getOrganizationUuid().equals(organization.getUuid()))
.map(QProfileDto::getKee)
.collect(MoreCollectors.join(Joiner.on(", ")));
if (!badKeys.isEmpty()) {
throw MessageException.of(format("Quality profiles with following keys don't exist in organization [%s]: %s", organization.getKey(), badKeys));
}
}
}
|
[
"private",
"void",
"checkQualityProfilesConsistency",
"(",
"ScannerReport",
".",
"Metadata",
"metadata",
",",
"Organization",
"organization",
")",
"{",
"List",
"<",
"String",
">",
"profileKeys",
"=",
"metadata",
".",
"getQprofilesPerLanguage",
"(",
")",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"QProfile",
"::",
"getKey",
")",
".",
"collect",
"(",
"toList",
"(",
"metadata",
".",
"getQprofilesPerLanguage",
"(",
")",
".",
"size",
"(",
")",
")",
")",
";",
"try",
"(",
"DbSession",
"dbSession",
"=",
"dbClient",
".",
"openSession",
"(",
"false",
")",
")",
"{",
"List",
"<",
"QProfileDto",
">",
"profiles",
"=",
"dbClient",
".",
"qualityProfileDao",
"(",
")",
".",
"selectByUuids",
"(",
"dbSession",
",",
"profileKeys",
")",
";",
"String",
"badKeys",
"=",
"profiles",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"p",
"->",
"!",
"p",
".",
"getOrganizationUuid",
"(",
")",
".",
"equals",
"(",
"organization",
".",
"getUuid",
"(",
")",
")",
")",
".",
"map",
"(",
"QProfileDto",
"::",
"getKee",
")",
".",
"collect",
"(",
"MoreCollectors",
".",
"join",
"(",
"Joiner",
".",
"on",
"(",
"\", \"",
")",
")",
")",
";",
"if",
"(",
"!",
"badKeys",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"MessageException",
".",
"of",
"(",
"format",
"(",
"\"Quality profiles with following keys don't exist in organization [%s]: %s\"",
",",
"organization",
".",
"getKey",
"(",
")",
",",
"badKeys",
")",
")",
";",
"}",
"}",
"}"
] |
Check that the Quality profiles sent by scanner correctly relate to the project organization.
|
[
"Check",
"that",
"the",
"Quality",
"profiles",
"sent",
"by",
"scanner",
"correctly",
"relate",
"to",
"the",
"project",
"organization",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java#L177-L191
|
16,217
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java
|
WebhookDeliveryDao.selectByWebhookUuid
|
public List<WebhookDeliveryLiteDto> selectByWebhookUuid(DbSession dbSession, String webhookUuid, int offset, int limit) {
return mapper(dbSession).selectByWebhookUuid(webhookUuid, new RowBounds(offset, limit));
}
|
java
|
public List<WebhookDeliveryLiteDto> selectByWebhookUuid(DbSession dbSession, String webhookUuid, int offset, int limit) {
return mapper(dbSession).selectByWebhookUuid(webhookUuid, new RowBounds(offset, limit));
}
|
[
"public",
"List",
"<",
"WebhookDeliveryLiteDto",
">",
"selectByWebhookUuid",
"(",
"DbSession",
"dbSession",
",",
"String",
"webhookUuid",
",",
"int",
"offset",
",",
"int",
"limit",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectByWebhookUuid",
"(",
"webhookUuid",
",",
"new",
"RowBounds",
"(",
"offset",
",",
"limit",
")",
")",
";",
"}"
] |
All the deliveries for the specified webhook. Results are ordered by descending date.
|
[
"All",
"the",
"deliveries",
"for",
"the",
"specified",
"webhook",
".",
"Results",
"are",
"ordered",
"by",
"descending",
"date",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java#L45-L47
|
16,218
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java
|
WebhookDeliveryDao.selectOrderedByComponentUuid
|
public List<WebhookDeliveryLiteDto> selectOrderedByComponentUuid(DbSession dbSession, String componentUuid, int offset, int limit) {
return mapper(dbSession).selectOrderedByComponentUuid(componentUuid, new RowBounds(offset, limit));
}
|
java
|
public List<WebhookDeliveryLiteDto> selectOrderedByComponentUuid(DbSession dbSession, String componentUuid, int offset, int limit) {
return mapper(dbSession).selectOrderedByComponentUuid(componentUuid, new RowBounds(offset, limit));
}
|
[
"public",
"List",
"<",
"WebhookDeliveryLiteDto",
">",
"selectOrderedByComponentUuid",
"(",
"DbSession",
"dbSession",
",",
"String",
"componentUuid",
",",
"int",
"offset",
",",
"int",
"limit",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectOrderedByComponentUuid",
"(",
"componentUuid",
",",
"new",
"RowBounds",
"(",
"offset",
",",
"limit",
")",
")",
";",
"}"
] |
All the deliveries for the specified component. Results are ordered by descending date.
|
[
"All",
"the",
"deliveries",
"for",
"the",
"specified",
"component",
".",
"Results",
"are",
"ordered",
"by",
"descending",
"date",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java#L56-L58
|
16,219
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java
|
WebhookDeliveryDao.selectOrderedByCeTaskUuid
|
public List<WebhookDeliveryLiteDto> selectOrderedByCeTaskUuid(DbSession dbSession, String ceTaskUuid, int offset, int limit) {
return mapper(dbSession).selectOrderedByCeTaskUuid(ceTaskUuid, new RowBounds(offset, limit));
}
|
java
|
public List<WebhookDeliveryLiteDto> selectOrderedByCeTaskUuid(DbSession dbSession, String ceTaskUuid, int offset, int limit) {
return mapper(dbSession).selectOrderedByCeTaskUuid(ceTaskUuid, new RowBounds(offset, limit));
}
|
[
"public",
"List",
"<",
"WebhookDeliveryLiteDto",
">",
"selectOrderedByCeTaskUuid",
"(",
"DbSession",
"dbSession",
",",
"String",
"ceTaskUuid",
",",
"int",
"offset",
",",
"int",
"limit",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectOrderedByCeTaskUuid",
"(",
"ceTaskUuid",
",",
"new",
"RowBounds",
"(",
"offset",
",",
"limit",
")",
")",
";",
"}"
] |
All the deliveries for the specified CE task. Results are ordered by descending date.
|
[
"All",
"the",
"deliveries",
"for",
"the",
"specified",
"CE",
"task",
".",
"Results",
"are",
"ordered",
"by",
"descending",
"date",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java#L67-L69
|
16,220
|
SonarSource/sonarqube
|
server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
|
SchedulerImpl.stopProcess
|
private void stopProcess(ProcessId processId) {
SQProcess process = processesById.get(processId);
if (process != null) {
process.stop(1, TimeUnit.MINUTES);
}
}
|
java
|
private void stopProcess(ProcessId processId) {
SQProcess process = processesById.get(processId);
if (process != null) {
process.stop(1, TimeUnit.MINUTES);
}
}
|
[
"private",
"void",
"stopProcess",
"(",
"ProcessId",
"processId",
")",
"{",
"SQProcess",
"process",
"=",
"processesById",
".",
"get",
"(",
"processId",
")",
";",
"if",
"(",
"process",
"!=",
"null",
")",
"{",
"process",
".",
"stop",
"(",
"1",
",",
"TimeUnit",
".",
"MINUTES",
")",
";",
"}",
"}"
] |
Request for graceful stop then blocks until process is stopped.
Returns immediately if the process is disabled in configuration.
|
[
"Request",
"for",
"graceful",
"stop",
"then",
"blocks",
"until",
"process",
"is",
"stopped",
".",
"Returns",
"immediately",
"if",
"the",
"process",
"is",
"disabled",
"in",
"configuration",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java#L179-L184
|
16,221
|
SonarSource/sonarqube
|
server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
|
SchedulerImpl.terminate
|
@Override
public void terminate() {
// disable ability to request for restart
restartRequested.set(false);
restartDisabled.set(true);
if (nodeLifecycle.tryToMoveTo(NodeLifecycle.State.STOPPING)) {
LOG.info("Stopping SonarQube");
}
stopAll();
if (stopperThread != null) {
stopperThread.interrupt();
}
if (restarterThread != null) {
restarterThread.interrupt();
}
keepAlive.countDown();
}
|
java
|
@Override
public void terminate() {
// disable ability to request for restart
restartRequested.set(false);
restartDisabled.set(true);
if (nodeLifecycle.tryToMoveTo(NodeLifecycle.State.STOPPING)) {
LOG.info("Stopping SonarQube");
}
stopAll();
if (stopperThread != null) {
stopperThread.interrupt();
}
if (restarterThread != null) {
restarterThread.interrupt();
}
keepAlive.countDown();
}
|
[
"@",
"Override",
"public",
"void",
"terminate",
"(",
")",
"{",
"// disable ability to request for restart",
"restartRequested",
".",
"set",
"(",
"false",
")",
";",
"restartDisabled",
".",
"set",
"(",
"true",
")",
";",
"if",
"(",
"nodeLifecycle",
".",
"tryToMoveTo",
"(",
"NodeLifecycle",
".",
"State",
".",
"STOPPING",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Stopping SonarQube\"",
")",
";",
"}",
"stopAll",
"(",
")",
";",
"if",
"(",
"stopperThread",
"!=",
"null",
")",
"{",
"stopperThread",
".",
"interrupt",
"(",
")",
";",
"}",
"if",
"(",
"restarterThread",
"!=",
"null",
")",
"{",
"restarterThread",
".",
"interrupt",
"(",
")",
";",
"}",
"keepAlive",
".",
"countDown",
"(",
")",
";",
"}"
] |
Blocks until all processes are stopped. Pending restart, if
any, is disabled.
|
[
"Blocks",
"until",
"all",
"processes",
"are",
"stopped",
".",
"Pending",
"restart",
"if",
"any",
"is",
"disabled",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java#L190-L207
|
16,222
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
|
PersistComponentsStep.indexExistingDtosByUuids
|
private Map<String, ComponentDto> indexExistingDtosByUuids(DbSession session) {
return dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getDbKey())
.stream()
.collect(Collectors.toMap(ComponentDto::uuid, Function.identity()));
}
|
java
|
private Map<String, ComponentDto> indexExistingDtosByUuids(DbSession session) {
return dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getDbKey())
.stream()
.collect(Collectors.toMap(ComponentDto::uuid, Function.identity()));
}
|
[
"private",
"Map",
"<",
"String",
",",
"ComponentDto",
">",
"indexExistingDtosByUuids",
"(",
"DbSession",
"session",
")",
"{",
"return",
"dbClient",
".",
"componentDao",
"(",
")",
".",
"selectAllComponentsFromProjectKey",
"(",
"session",
",",
"treeRootHolder",
".",
"getRoot",
"(",
")",
".",
"getDbKey",
"(",
")",
")",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toMap",
"(",
"ComponentDto",
"::",
"uuid",
",",
"Function",
".",
"identity",
"(",
")",
")",
")",
";",
"}"
] |
Returns a mutable map of the components currently persisted in database for the project, including
disabled components.
|
[
"Returns",
"a",
"mutable",
"map",
"of",
"the",
"components",
"currently",
"persisted",
"in",
"database",
"for",
"the",
"project",
"including",
"disabled",
"components",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java#L159-L163
|
16,223
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
|
PersistComponentsStep.setParentModuleProperties
|
private static void setParentModuleProperties(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
componentDto.setProjectUuid(path.root().getDto().uuid());
ComponentDto parentModule = from(path.getCurrentPath())
.filter(ParentModulePathElement.INSTANCE)
.first()
.get()
.getElement().getDto();
componentDto.setUuidPath(formatUuidPathFromParent(path.parent().getDto()));
componentDto.setRootUuid(parentModule.uuid());
componentDto.setModuleUuid(parentModule.uuid());
componentDto.setModuleUuidPath(parentModule.moduleUuidPath());
}
|
java
|
private static void setParentModuleProperties(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
componentDto.setProjectUuid(path.root().getDto().uuid());
ComponentDto parentModule = from(path.getCurrentPath())
.filter(ParentModulePathElement.INSTANCE)
.first()
.get()
.getElement().getDto();
componentDto.setUuidPath(formatUuidPathFromParent(path.parent().getDto()));
componentDto.setRootUuid(parentModule.uuid());
componentDto.setModuleUuid(parentModule.uuid());
componentDto.setModuleUuidPath(parentModule.moduleUuidPath());
}
|
[
"private",
"static",
"void",
"setParentModuleProperties",
"(",
"ComponentDto",
"componentDto",
",",
"PathAwareVisitor",
".",
"Path",
"<",
"ComponentDtoHolder",
">",
"path",
")",
"{",
"componentDto",
".",
"setProjectUuid",
"(",
"path",
".",
"root",
"(",
")",
".",
"getDto",
"(",
")",
".",
"uuid",
"(",
")",
")",
";",
"ComponentDto",
"parentModule",
"=",
"from",
"(",
"path",
".",
"getCurrentPath",
"(",
")",
")",
".",
"filter",
"(",
"ParentModulePathElement",
".",
"INSTANCE",
")",
".",
"first",
"(",
")",
".",
"get",
"(",
")",
".",
"getElement",
"(",
")",
".",
"getDto",
"(",
")",
";",
"componentDto",
".",
"setUuidPath",
"(",
"formatUuidPathFromParent",
"(",
"path",
".",
"parent",
"(",
")",
".",
"getDto",
"(",
")",
")",
")",
";",
"componentDto",
".",
"setRootUuid",
"(",
"parentModule",
".",
"uuid",
"(",
")",
")",
";",
"componentDto",
".",
"setModuleUuid",
"(",
"parentModule",
".",
"uuid",
"(",
")",
")",
";",
"componentDto",
".",
"setModuleUuidPath",
"(",
"parentModule",
".",
"moduleUuidPath",
"(",
")",
")",
";",
"}"
] |
Applies to a node of type either DIRECTORY or FILE
|
[
"Applies",
"to",
"a",
"node",
"of",
"type",
"either",
"DIRECTORY",
"or",
"FILE"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java#L401-L414
|
16,224
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionnary.java
|
AbstractExtensionDictionnary.getDependents
|
private <T> List<Object> getDependents(T extension) {
return new ArrayList<>(evaluateAnnotatedClasses(extension, DependedUpon.class));
}
|
java
|
private <T> List<Object> getDependents(T extension) {
return new ArrayList<>(evaluateAnnotatedClasses(extension, DependedUpon.class));
}
|
[
"private",
"<",
"T",
">",
"List",
"<",
"Object",
">",
"getDependents",
"(",
"T",
"extension",
")",
"{",
"return",
"new",
"ArrayList",
"<>",
"(",
"evaluateAnnotatedClasses",
"(",
"extension",
",",
"DependedUpon",
".",
"class",
")",
")",
";",
"}"
] |
Objects that depend upon this extension.
|
[
"Objects",
"that",
"depend",
"upon",
"this",
"extension",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionnary.java#L119-L121
|
16,225
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/PluginFiles.java
|
PluginFiles.get
|
public Optional<File> get(InstalledPlugin plugin) {
// Does not fail if another process tries to create the directory at the same time.
File jarInCache = jarInCache(plugin.key, plugin.hash);
if (jarInCache.exists() && jarInCache.isFile()) {
return Optional.of(jarInCache);
}
return download(plugin);
}
|
java
|
public Optional<File> get(InstalledPlugin plugin) {
// Does not fail if another process tries to create the directory at the same time.
File jarInCache = jarInCache(plugin.key, plugin.hash);
if (jarInCache.exists() && jarInCache.isFile()) {
return Optional.of(jarInCache);
}
return download(plugin);
}
|
[
"public",
"Optional",
"<",
"File",
">",
"get",
"(",
"InstalledPlugin",
"plugin",
")",
"{",
"// Does not fail if another process tries to create the directory at the same time.",
"File",
"jarInCache",
"=",
"jarInCache",
"(",
"plugin",
".",
"key",
",",
"plugin",
".",
"hash",
")",
";",
"if",
"(",
"jarInCache",
".",
"exists",
"(",
")",
"&&",
"jarInCache",
".",
"isFile",
"(",
")",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"jarInCache",
")",
";",
"}",
"return",
"download",
"(",
"plugin",
")",
";",
"}"
] |
Get the JAR file of specified plugin. If not present in user local cache,
then it's downloaded from server and added to cache.
@return the file, or {@link Optional#empty()} if plugin not found (404 HTTP code)
@throws IllegalStateException if the plugin can't be downloaded (not 404 nor 2xx HTTP codes)
or can't be cached locally.
|
[
"Get",
"the",
"JAR",
"file",
"of",
"specified",
"plugin",
".",
"If",
"not",
"present",
"in",
"user",
"local",
"cache",
"then",
"it",
"s",
"downloaded",
"from",
"server",
"and",
"added",
"to",
"cache",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/PluginFiles.java#L83-L90
|
16,226
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/event/EventComponentChangeDto.java
|
EventComponentChangeDto.setChangeCategory
|
private EventComponentChangeDto setChangeCategory(String changeCategory) {
this.category = ChangeCategory.fromDbValue(changeCategory)
.orElseThrow(() -> new IllegalArgumentException("Unsupported changeCategory DB value: " + changeCategory));
return this;
}
|
java
|
private EventComponentChangeDto setChangeCategory(String changeCategory) {
this.category = ChangeCategory.fromDbValue(changeCategory)
.orElseThrow(() -> new IllegalArgumentException("Unsupported changeCategory DB value: " + changeCategory));
return this;
}
|
[
"private",
"EventComponentChangeDto",
"setChangeCategory",
"(",
"String",
"changeCategory",
")",
"{",
"this",
".",
"category",
"=",
"ChangeCategory",
".",
"fromDbValue",
"(",
"changeCategory",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported changeCategory DB value: \"",
"+",
"changeCategory",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Used by MyBatis through reflection.
@throws IllegalArgumentException if not a support change category DB value
|
[
"Used",
"by",
"MyBatis",
"through",
"reflection",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/event/EventComponentChangeDto.java#L93-L97
|
16,227
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/platform/PluginInfo.java
|
PluginInfo.isCompatibleWith
|
public boolean isCompatibleWith(String runtimeVersion) {
if (null == this.minimalSqVersion) {
// no constraint defined on the plugin
return true;
}
Version effectiveMin = Version.create(minimalSqVersion.getName()).removeQualifier();
Version effectiveVersion = Version.create(runtimeVersion).removeQualifier();
if (runtimeVersion.endsWith("-SNAPSHOT")) {
// check only the major and minor versions (two first fields)
effectiveMin = Version.create(effectiveMin.getMajor() + "." + effectiveMin.getMinor());
}
return effectiveVersion.compareTo(effectiveMin) >= 0;
}
|
java
|
public boolean isCompatibleWith(String runtimeVersion) {
if (null == this.minimalSqVersion) {
// no constraint defined on the plugin
return true;
}
Version effectiveMin = Version.create(minimalSqVersion.getName()).removeQualifier();
Version effectiveVersion = Version.create(runtimeVersion).removeQualifier();
if (runtimeVersion.endsWith("-SNAPSHOT")) {
// check only the major and minor versions (two first fields)
effectiveMin = Version.create(effectiveMin.getMajor() + "." + effectiveMin.getMinor());
}
return effectiveVersion.compareTo(effectiveMin) >= 0;
}
|
[
"public",
"boolean",
"isCompatibleWith",
"(",
"String",
"runtimeVersion",
")",
"{",
"if",
"(",
"null",
"==",
"this",
".",
"minimalSqVersion",
")",
"{",
"// no constraint defined on the plugin",
"return",
"true",
";",
"}",
"Version",
"effectiveMin",
"=",
"Version",
".",
"create",
"(",
"minimalSqVersion",
".",
"getName",
"(",
")",
")",
".",
"removeQualifier",
"(",
")",
";",
"Version",
"effectiveVersion",
"=",
"Version",
".",
"create",
"(",
"runtimeVersion",
")",
".",
"removeQualifier",
"(",
")",
";",
"if",
"(",
"runtimeVersion",
".",
"endsWith",
"(",
"\"-SNAPSHOT\"",
")",
")",
"{",
"// check only the major and minor versions (two first fields)",
"effectiveMin",
"=",
"Version",
".",
"create",
"(",
"effectiveMin",
".",
"getMajor",
"(",
")",
"+",
"\".\"",
"+",
"effectiveMin",
".",
"getMinor",
"(",
")",
")",
";",
"}",
"return",
"effectiveVersion",
".",
"compareTo",
"(",
"effectiveMin",
")",
">=",
"0",
";",
"}"
] |
Find out if this plugin is compatible with a given version of SonarQube.
The version of SQ must be greater than or equal to the minimal version
needed by the plugin.
|
[
"Find",
"out",
"if",
"this",
"plugin",
"is",
"compatible",
"with",
"a",
"given",
"version",
"of",
"SonarQube",
".",
"The",
"version",
"of",
"SQ",
"must",
"be",
"greater",
"than",
"or",
"equal",
"to",
"the",
"minimal",
"version",
"needed",
"by",
"the",
"plugin",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/platform/PluginInfo.java#L340-L355
|
16,228
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/issue/tracking/BlockRecognizer.java
|
BlockRecognizer.match
|
void match(Input<RAW> rawInput, Input<BASE> baseInput, Tracking<RAW, BASE> tracking) {
BlockHashSequence rawHashSequence = rawInput.getBlockHashSequence();
BlockHashSequence baseHashSequence = baseInput.getBlockHashSequence();
Multimap<Integer, RAW> rawsByLine = groupByLine(tracking.getUnmatchedRaws(), rawHashSequence);
Multimap<Integer, BASE> basesByLine = groupByLine(tracking.getUnmatchedBases(), baseHashSequence);
Map<Integer, HashOccurrence> occurrencesByHash = new HashMap<>();
for (Integer line : basesByLine.keySet()) {
int hash = baseHashSequence.getBlockHashForLine(line);
HashOccurrence hashOccurrence = occurrencesByHash.get(hash);
if (hashOccurrence == null) {
// first occurrence in base
hashOccurrence = new HashOccurrence();
hashOccurrence.baseLine = line;
hashOccurrence.baseCount = 1;
occurrencesByHash.put(hash, hashOccurrence);
} else {
hashOccurrence.baseCount++;
}
}
for (Integer line : rawsByLine.keySet()) {
int hash = rawHashSequence.getBlockHashForLine(line);
HashOccurrence hashOccurrence = occurrencesByHash.get(hash);
if (hashOccurrence != null) {
hashOccurrence.rawLine = line;
hashOccurrence.rawCount++;
}
}
for (HashOccurrence hashOccurrence : occurrencesByHash.values()) {
if (hashOccurrence.baseCount == 1 && hashOccurrence.rawCount == 1) {
// Guaranteed that baseLine has been moved to rawLine, so we can map all issues on baseLine to all issues on rawLine
map(rawsByLine.get(hashOccurrence.rawLine), basesByLine.get(hashOccurrence.baseLine), tracking);
basesByLine.removeAll(hashOccurrence.baseLine);
rawsByLine.removeAll(hashOccurrence.rawLine);
}
}
// Check if remaining number of lines exceeds threshold. It avoids processing too many combinations.
if (basesByLine.keySet().size() * rawsByLine.keySet().size() >= 250_000) {
return;
}
List<LinePair> possibleLinePairs = Lists.newArrayList();
for (Integer baseLine : basesByLine.keySet()) {
for (Integer rawLine : rawsByLine.keySet()) {
int weight = lengthOfMaximalBlock(baseInput.getLineHashSequence(), baseLine, rawInput.getLineHashSequence(), rawLine);
if (weight > 0) {
possibleLinePairs.add(new LinePair(baseLine, rawLine, weight));
}
}
}
Collections.sort(possibleLinePairs, LinePairComparator.INSTANCE);
for (LinePair linePair : possibleLinePairs) {
// High probability that baseLine has been moved to rawLine, so we can map all issues on baseLine to all issues on rawLine
map(rawsByLine.get(linePair.rawLine), basesByLine.get(linePair.baseLine), tracking);
}
}
|
java
|
void match(Input<RAW> rawInput, Input<BASE> baseInput, Tracking<RAW, BASE> tracking) {
BlockHashSequence rawHashSequence = rawInput.getBlockHashSequence();
BlockHashSequence baseHashSequence = baseInput.getBlockHashSequence();
Multimap<Integer, RAW> rawsByLine = groupByLine(tracking.getUnmatchedRaws(), rawHashSequence);
Multimap<Integer, BASE> basesByLine = groupByLine(tracking.getUnmatchedBases(), baseHashSequence);
Map<Integer, HashOccurrence> occurrencesByHash = new HashMap<>();
for (Integer line : basesByLine.keySet()) {
int hash = baseHashSequence.getBlockHashForLine(line);
HashOccurrence hashOccurrence = occurrencesByHash.get(hash);
if (hashOccurrence == null) {
// first occurrence in base
hashOccurrence = new HashOccurrence();
hashOccurrence.baseLine = line;
hashOccurrence.baseCount = 1;
occurrencesByHash.put(hash, hashOccurrence);
} else {
hashOccurrence.baseCount++;
}
}
for (Integer line : rawsByLine.keySet()) {
int hash = rawHashSequence.getBlockHashForLine(line);
HashOccurrence hashOccurrence = occurrencesByHash.get(hash);
if (hashOccurrence != null) {
hashOccurrence.rawLine = line;
hashOccurrence.rawCount++;
}
}
for (HashOccurrence hashOccurrence : occurrencesByHash.values()) {
if (hashOccurrence.baseCount == 1 && hashOccurrence.rawCount == 1) {
// Guaranteed that baseLine has been moved to rawLine, so we can map all issues on baseLine to all issues on rawLine
map(rawsByLine.get(hashOccurrence.rawLine), basesByLine.get(hashOccurrence.baseLine), tracking);
basesByLine.removeAll(hashOccurrence.baseLine);
rawsByLine.removeAll(hashOccurrence.rawLine);
}
}
// Check if remaining number of lines exceeds threshold. It avoids processing too many combinations.
if (basesByLine.keySet().size() * rawsByLine.keySet().size() >= 250_000) {
return;
}
List<LinePair> possibleLinePairs = Lists.newArrayList();
for (Integer baseLine : basesByLine.keySet()) {
for (Integer rawLine : rawsByLine.keySet()) {
int weight = lengthOfMaximalBlock(baseInput.getLineHashSequence(), baseLine, rawInput.getLineHashSequence(), rawLine);
if (weight > 0) {
possibleLinePairs.add(new LinePair(baseLine, rawLine, weight));
}
}
}
Collections.sort(possibleLinePairs, LinePairComparator.INSTANCE);
for (LinePair linePair : possibleLinePairs) {
// High probability that baseLine has been moved to rawLine, so we can map all issues on baseLine to all issues on rawLine
map(rawsByLine.get(linePair.rawLine), basesByLine.get(linePair.baseLine), tracking);
}
}
|
[
"void",
"match",
"(",
"Input",
"<",
"RAW",
">",
"rawInput",
",",
"Input",
"<",
"BASE",
">",
"baseInput",
",",
"Tracking",
"<",
"RAW",
",",
"BASE",
">",
"tracking",
")",
"{",
"BlockHashSequence",
"rawHashSequence",
"=",
"rawInput",
".",
"getBlockHashSequence",
"(",
")",
";",
"BlockHashSequence",
"baseHashSequence",
"=",
"baseInput",
".",
"getBlockHashSequence",
"(",
")",
";",
"Multimap",
"<",
"Integer",
",",
"RAW",
">",
"rawsByLine",
"=",
"groupByLine",
"(",
"tracking",
".",
"getUnmatchedRaws",
"(",
")",
",",
"rawHashSequence",
")",
";",
"Multimap",
"<",
"Integer",
",",
"BASE",
">",
"basesByLine",
"=",
"groupByLine",
"(",
"tracking",
".",
"getUnmatchedBases",
"(",
")",
",",
"baseHashSequence",
")",
";",
"Map",
"<",
"Integer",
",",
"HashOccurrence",
">",
"occurrencesByHash",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Integer",
"line",
":",
"basesByLine",
".",
"keySet",
"(",
")",
")",
"{",
"int",
"hash",
"=",
"baseHashSequence",
".",
"getBlockHashForLine",
"(",
"line",
")",
";",
"HashOccurrence",
"hashOccurrence",
"=",
"occurrencesByHash",
".",
"get",
"(",
"hash",
")",
";",
"if",
"(",
"hashOccurrence",
"==",
"null",
")",
"{",
"// first occurrence in base",
"hashOccurrence",
"=",
"new",
"HashOccurrence",
"(",
")",
";",
"hashOccurrence",
".",
"baseLine",
"=",
"line",
";",
"hashOccurrence",
".",
"baseCount",
"=",
"1",
";",
"occurrencesByHash",
".",
"put",
"(",
"hash",
",",
"hashOccurrence",
")",
";",
"}",
"else",
"{",
"hashOccurrence",
".",
"baseCount",
"++",
";",
"}",
"}",
"for",
"(",
"Integer",
"line",
":",
"rawsByLine",
".",
"keySet",
"(",
")",
")",
"{",
"int",
"hash",
"=",
"rawHashSequence",
".",
"getBlockHashForLine",
"(",
"line",
")",
";",
"HashOccurrence",
"hashOccurrence",
"=",
"occurrencesByHash",
".",
"get",
"(",
"hash",
")",
";",
"if",
"(",
"hashOccurrence",
"!=",
"null",
")",
"{",
"hashOccurrence",
".",
"rawLine",
"=",
"line",
";",
"hashOccurrence",
".",
"rawCount",
"++",
";",
"}",
"}",
"for",
"(",
"HashOccurrence",
"hashOccurrence",
":",
"occurrencesByHash",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"hashOccurrence",
".",
"baseCount",
"==",
"1",
"&&",
"hashOccurrence",
".",
"rawCount",
"==",
"1",
")",
"{",
"// Guaranteed that baseLine has been moved to rawLine, so we can map all issues on baseLine to all issues on rawLine",
"map",
"(",
"rawsByLine",
".",
"get",
"(",
"hashOccurrence",
".",
"rawLine",
")",
",",
"basesByLine",
".",
"get",
"(",
"hashOccurrence",
".",
"baseLine",
")",
",",
"tracking",
")",
";",
"basesByLine",
".",
"removeAll",
"(",
"hashOccurrence",
".",
"baseLine",
")",
";",
"rawsByLine",
".",
"removeAll",
"(",
"hashOccurrence",
".",
"rawLine",
")",
";",
"}",
"}",
"// Check if remaining number of lines exceeds threshold. It avoids processing too many combinations.",
"if",
"(",
"basesByLine",
".",
"keySet",
"(",
")",
".",
"size",
"(",
")",
"*",
"rawsByLine",
".",
"keySet",
"(",
")",
".",
"size",
"(",
")",
">=",
"250_000",
")",
"{",
"return",
";",
"}",
"List",
"<",
"LinePair",
">",
"possibleLinePairs",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"Integer",
"baseLine",
":",
"basesByLine",
".",
"keySet",
"(",
")",
")",
"{",
"for",
"(",
"Integer",
"rawLine",
":",
"rawsByLine",
".",
"keySet",
"(",
")",
")",
"{",
"int",
"weight",
"=",
"lengthOfMaximalBlock",
"(",
"baseInput",
".",
"getLineHashSequence",
"(",
")",
",",
"baseLine",
",",
"rawInput",
".",
"getLineHashSequence",
"(",
")",
",",
"rawLine",
")",
";",
"if",
"(",
"weight",
">",
"0",
")",
"{",
"possibleLinePairs",
".",
"add",
"(",
"new",
"LinePair",
"(",
"baseLine",
",",
"rawLine",
",",
"weight",
")",
")",
";",
"}",
"}",
"}",
"Collections",
".",
"sort",
"(",
"possibleLinePairs",
",",
"LinePairComparator",
".",
"INSTANCE",
")",
";",
"for",
"(",
"LinePair",
"linePair",
":",
"possibleLinePairs",
")",
"{",
"// High probability that baseLine has been moved to rawLine, so we can map all issues on baseLine to all issues on rawLine",
"map",
"(",
"rawsByLine",
".",
"get",
"(",
"linePair",
".",
"rawLine",
")",
",",
"basesByLine",
".",
"get",
"(",
"linePair",
".",
"baseLine",
")",
",",
"tracking",
")",
";",
"}",
"}"
] |
If base source code is available, then detect code moves through block hashes.
Only the issues associated to a line can be matched here.
|
[
"If",
"base",
"source",
"code",
"is",
"available",
"then",
"detect",
"code",
"moves",
"through",
"block",
"hashes",
".",
"Only",
"the",
"issues",
"associated",
"to",
"a",
"line",
"can",
"be",
"matched",
"here",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/issue/tracking/BlockRecognizer.java#L39-L98
|
16,229
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/BaseIssuesLoader.java
|
BaseIssuesLoader.loadUuidsOfComponentsWithOpenIssues
|
public Set<String> loadUuidsOfComponentsWithOpenIssues() {
try (DbSession dbSession = dbClient.openSession(false)) {
return dbClient.issueDao().selectComponentUuidsOfOpenIssuesForProjectUuid(dbSession, treeRootHolder.getRoot().getUuid());
}
}
|
java
|
public Set<String> loadUuidsOfComponentsWithOpenIssues() {
try (DbSession dbSession = dbClient.openSession(false)) {
return dbClient.issueDao().selectComponentUuidsOfOpenIssuesForProjectUuid(dbSession, treeRootHolder.getRoot().getUuid());
}
}
|
[
"public",
"Set",
"<",
"String",
">",
"loadUuidsOfComponentsWithOpenIssues",
"(",
")",
"{",
"try",
"(",
"DbSession",
"dbSession",
"=",
"dbClient",
".",
"openSession",
"(",
"false",
")",
")",
"{",
"return",
"dbClient",
".",
"issueDao",
"(",
")",
".",
"selectComponentUuidsOfOpenIssuesForProjectUuid",
"(",
"dbSession",
",",
"treeRootHolder",
".",
"getRoot",
"(",
")",
".",
"getUuid",
"(",
")",
")",
";",
"}",
"}"
] |
Uuids of all the components that have open issues on this project.
|
[
"Uuids",
"of",
"all",
"the",
"components",
"that",
"have",
"open",
"issues",
"on",
"this",
"project",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/BaseIssuesLoader.java#L43-L47
|
16,230
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/PostJobOptimizer.java
|
PostJobOptimizer.shouldExecute
|
public boolean shouldExecute(DefaultPostJobDescriptor descriptor) {
if (!settingsCondition(descriptor)) {
LOG.debug("'{}' skipped because one of the required properties is missing", descriptor.name());
return false;
}
return true;
}
|
java
|
public boolean shouldExecute(DefaultPostJobDescriptor descriptor) {
if (!settingsCondition(descriptor)) {
LOG.debug("'{}' skipped because one of the required properties is missing", descriptor.name());
return false;
}
return true;
}
|
[
"public",
"boolean",
"shouldExecute",
"(",
"DefaultPostJobDescriptor",
"descriptor",
")",
"{",
"if",
"(",
"!",
"settingsCondition",
"(",
"descriptor",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"'{}' skipped because one of the required properties is missing\"",
",",
"descriptor",
".",
"name",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Decide if the given PostJob should be executed.
|
[
"Decide",
"if",
"the",
"given",
"PostJob",
"should",
"be",
"executed",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/PostJobOptimizer.java#L40-L46
|
16,231
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java
|
RemoveUserAction.ensureLastAdminIsNotRemoved
|
private void ensureLastAdminIsNotRemoved(DbSession dbSession, GroupDto group, UserDto user) {
int remainingAdmins = dbClient.authorizationDao().countUsersWithGlobalPermissionExcludingGroupMember(dbSession,
group.getOrganizationUuid(), OrganizationPermission.ADMINISTER.getKey(), group.getId(), user.getId());
checkRequest(remainingAdmins > 0, "The last administrator user cannot be removed");
}
|
java
|
private void ensureLastAdminIsNotRemoved(DbSession dbSession, GroupDto group, UserDto user) {
int remainingAdmins = dbClient.authorizationDao().countUsersWithGlobalPermissionExcludingGroupMember(dbSession,
group.getOrganizationUuid(), OrganizationPermission.ADMINISTER.getKey(), group.getId(), user.getId());
checkRequest(remainingAdmins > 0, "The last administrator user cannot be removed");
}
|
[
"private",
"void",
"ensureLastAdminIsNotRemoved",
"(",
"DbSession",
"dbSession",
",",
"GroupDto",
"group",
",",
"UserDto",
"user",
")",
"{",
"int",
"remainingAdmins",
"=",
"dbClient",
".",
"authorizationDao",
"(",
")",
".",
"countUsersWithGlobalPermissionExcludingGroupMember",
"(",
"dbSession",
",",
"group",
".",
"getOrganizationUuid",
"(",
")",
",",
"OrganizationPermission",
".",
"ADMINISTER",
".",
"getKey",
"(",
")",
",",
"group",
".",
"getId",
"(",
")",
",",
"user",
".",
"getId",
"(",
")",
")",
";",
"checkRequest",
"(",
"remainingAdmins",
">",
"0",
",",
"\"The last administrator user cannot be removed\"",
")",
";",
"}"
] |
Ensure that there are still users with admin global permission if user is removed from the group.
|
[
"Ensure",
"that",
"there",
"are",
"still",
"users",
"with",
"admin",
"global",
"permission",
"if",
"user",
"is",
"removed",
"from",
"the",
"group",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java#L93-L97
|
16,232
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/es/newindex/StringFieldBuilder.java
|
StringFieldBuilder.addSubFields
|
public T addSubFields(DefaultIndexSettingsElement... analyzers) {
Arrays.stream(analyzers)
.forEach(analyzer -> addSubField(analyzer.getSubFieldSuffix(), analyzer.fieldMapping()));
return castThis();
}
|
java
|
public T addSubFields(DefaultIndexSettingsElement... analyzers) {
Arrays.stream(analyzers)
.forEach(analyzer -> addSubField(analyzer.getSubFieldSuffix(), analyzer.fieldMapping()));
return castThis();
}
|
[
"public",
"T",
"addSubFields",
"(",
"DefaultIndexSettingsElement",
"...",
"analyzers",
")",
"{",
"Arrays",
".",
"stream",
"(",
"analyzers",
")",
".",
"forEach",
"(",
"analyzer",
"->",
"addSubField",
"(",
"analyzer",
".",
"getSubFieldSuffix",
"(",
")",
",",
"analyzer",
".",
"fieldMapping",
"(",
")",
")",
")",
";",
"return",
"castThis",
"(",
")",
";",
"}"
] |
Add subfields, one for each analyzer.
|
[
"Add",
"subfields",
"one",
"for",
"each",
"analyzer",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/es/newindex/StringFieldBuilder.java#L68-L72
|
16,233
|
SonarSource/sonarqube
|
server/sonar-db-core/src/main/java/org/sonar/db/DdlUtils.java
|
DdlUtils.createSchema
|
public static void createSchema(Connection connection, String dialect, boolean createSchemaMigrations) {
if (createSchemaMigrations) {
executeScript(connection, "org/sonar/db/version/schema_migrations-" + dialect + ".ddl");
}
executeScript(connection, "org/sonar/db/version/schema-" + dialect + ".ddl");
executeScript(connection, "org/sonar/db/version/rows-" + dialect + ".sql");
}
|
java
|
public static void createSchema(Connection connection, String dialect, boolean createSchemaMigrations) {
if (createSchemaMigrations) {
executeScript(connection, "org/sonar/db/version/schema_migrations-" + dialect + ".ddl");
}
executeScript(connection, "org/sonar/db/version/schema-" + dialect + ".ddl");
executeScript(connection, "org/sonar/db/version/rows-" + dialect + ".sql");
}
|
[
"public",
"static",
"void",
"createSchema",
"(",
"Connection",
"connection",
",",
"String",
"dialect",
",",
"boolean",
"createSchemaMigrations",
")",
"{",
"if",
"(",
"createSchemaMigrations",
")",
"{",
"executeScript",
"(",
"connection",
",",
"\"org/sonar/db/version/schema_migrations-\"",
"+",
"dialect",
"+",
"\".ddl\"",
")",
";",
"}",
"executeScript",
"(",
"connection",
",",
"\"org/sonar/db/version/schema-\"",
"+",
"dialect",
"+",
"\".ddl\"",
")",
";",
"executeScript",
"(",
"connection",
",",
"\"org/sonar/db/version/rows-\"",
"+",
"dialect",
"+",
"\".sql\"",
")",
";",
"}"
] |
The connection is commited in this method but not closed.
|
[
"The",
"connection",
"is",
"commited",
"in",
"this",
"method",
"but",
"not",
"closed",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-core/src/main/java/org/sonar/db/DdlUtils.java#L45-L51
|
16,234
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
|
RuleUpdater.getRuleDto
|
private RuleDto getRuleDto(RuleUpdate change) {
try (DbSession dbSession = dbClient.openSession(false)) {
RuleDto rule = dbClient.ruleDao().selectOrFailByKey(dbSession, change.getOrganization(), change.getRuleKey());
if (RuleStatus.REMOVED == rule.getStatus()) {
throw new IllegalArgumentException("Rule with REMOVED status cannot be updated: " + change.getRuleKey());
}
return rule;
}
}
|
java
|
private RuleDto getRuleDto(RuleUpdate change) {
try (DbSession dbSession = dbClient.openSession(false)) {
RuleDto rule = dbClient.ruleDao().selectOrFailByKey(dbSession, change.getOrganization(), change.getRuleKey());
if (RuleStatus.REMOVED == rule.getStatus()) {
throw new IllegalArgumentException("Rule with REMOVED status cannot be updated: " + change.getRuleKey());
}
return rule;
}
}
|
[
"private",
"RuleDto",
"getRuleDto",
"(",
"RuleUpdate",
"change",
")",
"{",
"try",
"(",
"DbSession",
"dbSession",
"=",
"dbClient",
".",
"openSession",
"(",
"false",
")",
")",
"{",
"RuleDto",
"rule",
"=",
"dbClient",
".",
"ruleDao",
"(",
")",
".",
"selectOrFailByKey",
"(",
"dbSession",
",",
"change",
".",
"getOrganization",
"(",
")",
",",
"change",
".",
"getRuleKey",
"(",
")",
")",
";",
"if",
"(",
"RuleStatus",
".",
"REMOVED",
"==",
"rule",
".",
"getStatus",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Rule with REMOVED status cannot be updated: \"",
"+",
"change",
".",
"getRuleKey",
"(",
")",
")",
";",
"}",
"return",
"rule",
";",
"}",
"}"
] |
Load all the DTOs required for validating changes and updating rule
|
[
"Load",
"all",
"the",
"DTOs",
"required",
"for",
"validating",
"changes",
"and",
"updating",
"rule"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java#L92-L100
|
16,235
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/setting/ws/ValuesAction.java
|
ValuesAction.loadComponentSettings
|
private Multimap<String, Setting> loadComponentSettings(DbSession dbSession, Set<String> keys, ComponentDto component) {
List<String> componentUuids = DOT_SPLITTER.splitToList(component.moduleUuidPath());
List<ComponentDto> componentDtos = dbClient.componentDao().selectByUuids(dbSession, componentUuids);
Set<Long> componentIds = componentDtos.stream().map(ComponentDto::getId).collect(Collectors.toSet());
Map<Long, String> uuidsById = componentDtos.stream().collect(Collectors.toMap(ComponentDto::getId, ComponentDto::uuid));
List<PropertyDto> properties = dbClient.propertiesDao().selectPropertiesByKeysAndComponentIds(dbSession, keys, componentIds);
List<PropertyDto> propertySets = dbClient.propertiesDao().selectPropertiesByKeysAndComponentIds(dbSession, getPropertySetKeys(properties), componentIds);
Multimap<String, Setting> settingsByUuid = TreeMultimap.create(Ordering.explicit(componentUuids), Ordering.arbitrary());
for (PropertyDto propertyDto : properties) {
Long componentId = propertyDto.getResourceId();
String componentUuid = uuidsById.get(componentId);
String propertyKey = propertyDto.getKey();
settingsByUuid.put(componentUuid,
Setting.createFromDto(propertyDto, getPropertySets(propertyKey, propertySets, componentId), propertyDefinitions.get(propertyKey)));
}
return settingsByUuid;
}
|
java
|
private Multimap<String, Setting> loadComponentSettings(DbSession dbSession, Set<String> keys, ComponentDto component) {
List<String> componentUuids = DOT_SPLITTER.splitToList(component.moduleUuidPath());
List<ComponentDto> componentDtos = dbClient.componentDao().selectByUuids(dbSession, componentUuids);
Set<Long> componentIds = componentDtos.stream().map(ComponentDto::getId).collect(Collectors.toSet());
Map<Long, String> uuidsById = componentDtos.stream().collect(Collectors.toMap(ComponentDto::getId, ComponentDto::uuid));
List<PropertyDto> properties = dbClient.propertiesDao().selectPropertiesByKeysAndComponentIds(dbSession, keys, componentIds);
List<PropertyDto> propertySets = dbClient.propertiesDao().selectPropertiesByKeysAndComponentIds(dbSession, getPropertySetKeys(properties), componentIds);
Multimap<String, Setting> settingsByUuid = TreeMultimap.create(Ordering.explicit(componentUuids), Ordering.arbitrary());
for (PropertyDto propertyDto : properties) {
Long componentId = propertyDto.getResourceId();
String componentUuid = uuidsById.get(componentId);
String propertyKey = propertyDto.getKey();
settingsByUuid.put(componentUuid,
Setting.createFromDto(propertyDto, getPropertySets(propertyKey, propertySets, componentId), propertyDefinitions.get(propertyKey)));
}
return settingsByUuid;
}
|
[
"private",
"Multimap",
"<",
"String",
",",
"Setting",
">",
"loadComponentSettings",
"(",
"DbSession",
"dbSession",
",",
"Set",
"<",
"String",
">",
"keys",
",",
"ComponentDto",
"component",
")",
"{",
"List",
"<",
"String",
">",
"componentUuids",
"=",
"DOT_SPLITTER",
".",
"splitToList",
"(",
"component",
".",
"moduleUuidPath",
"(",
")",
")",
";",
"List",
"<",
"ComponentDto",
">",
"componentDtos",
"=",
"dbClient",
".",
"componentDao",
"(",
")",
".",
"selectByUuids",
"(",
"dbSession",
",",
"componentUuids",
")",
";",
"Set",
"<",
"Long",
">",
"componentIds",
"=",
"componentDtos",
".",
"stream",
"(",
")",
".",
"map",
"(",
"ComponentDto",
"::",
"getId",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"Map",
"<",
"Long",
",",
"String",
">",
"uuidsById",
"=",
"componentDtos",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toMap",
"(",
"ComponentDto",
"::",
"getId",
",",
"ComponentDto",
"::",
"uuid",
")",
")",
";",
"List",
"<",
"PropertyDto",
">",
"properties",
"=",
"dbClient",
".",
"propertiesDao",
"(",
")",
".",
"selectPropertiesByKeysAndComponentIds",
"(",
"dbSession",
",",
"keys",
",",
"componentIds",
")",
";",
"List",
"<",
"PropertyDto",
">",
"propertySets",
"=",
"dbClient",
".",
"propertiesDao",
"(",
")",
".",
"selectPropertiesByKeysAndComponentIds",
"(",
"dbSession",
",",
"getPropertySetKeys",
"(",
"properties",
")",
",",
"componentIds",
")",
";",
"Multimap",
"<",
"String",
",",
"Setting",
">",
"settingsByUuid",
"=",
"TreeMultimap",
".",
"create",
"(",
"Ordering",
".",
"explicit",
"(",
"componentUuids",
")",
",",
"Ordering",
".",
"arbitrary",
"(",
")",
")",
";",
"for",
"(",
"PropertyDto",
"propertyDto",
":",
"properties",
")",
"{",
"Long",
"componentId",
"=",
"propertyDto",
".",
"getResourceId",
"(",
")",
";",
"String",
"componentUuid",
"=",
"uuidsById",
".",
"get",
"(",
"componentId",
")",
";",
"String",
"propertyKey",
"=",
"propertyDto",
".",
"getKey",
"(",
")",
";",
"settingsByUuid",
".",
"put",
"(",
"componentUuid",
",",
"Setting",
".",
"createFromDto",
"(",
"propertyDto",
",",
"getPropertySets",
"(",
"propertyKey",
",",
"propertySets",
",",
"componentId",
")",
",",
"propertyDefinitions",
".",
"get",
"(",
"propertyKey",
")",
")",
")",
";",
"}",
"return",
"settingsByUuid",
";",
"}"
] |
Return list of settings by component uuid, sorted from project to lowest module
|
[
"Return",
"list",
"of",
"settings",
"by",
"component",
"uuid",
"sorted",
"from",
"project",
"to",
"lowest",
"module"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ValuesAction.java#L220-L237
|
16,236
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandler.java
|
ChangesOnMyIssueNotificationHandler.isPeerChanged
|
private static boolean isPeerChanged(Change change, ChangedIssue issue) {
Optional<User> assignee = issue.getAssignee();
return !assignee.isPresent() || !change.isAuthorLogin(assignee.get().getLogin());
}
|
java
|
private static boolean isPeerChanged(Change change, ChangedIssue issue) {
Optional<User> assignee = issue.getAssignee();
return !assignee.isPresent() || !change.isAuthorLogin(assignee.get().getLogin());
}
|
[
"private",
"static",
"boolean",
"isPeerChanged",
"(",
"Change",
"change",
",",
"ChangedIssue",
"issue",
")",
"{",
"Optional",
"<",
"User",
">",
"assignee",
"=",
"issue",
".",
"getAssignee",
"(",
")",
";",
"return",
"!",
"assignee",
".",
"isPresent",
"(",
")",
"||",
"!",
"change",
".",
"isAuthorLogin",
"(",
"assignee",
".",
"get",
"(",
")",
".",
"getLogin",
"(",
")",
")",
";",
"}"
] |
Is the author of the change the assignee of the specified issue?
If not, it means the issue has been changed by a peer of the author of the change.
|
[
"Is",
"the",
"author",
"of",
"the",
"change",
"the",
"assignee",
"of",
"the",
"specified",
"issue?",
"If",
"not",
"it",
"means",
"the",
"issue",
"has",
"been",
"changed",
"by",
"a",
"peer",
"of",
"the",
"author",
"of",
"the",
"change",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandler.java#L174-L177
|
16,237
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/es/Facets.java
|
Facets.get
|
@CheckForNull
public LinkedHashMap<String, Long> get(String facetName) {
return facetsByName.get(facetName);
}
|
java
|
@CheckForNull
public LinkedHashMap<String, Long> get(String facetName) {
return facetsByName.get(facetName);
}
|
[
"@",
"CheckForNull",
"public",
"LinkedHashMap",
"<",
"String",
",",
"Long",
">",
"get",
"(",
"String",
"facetName",
")",
"{",
"return",
"facetsByName",
".",
"get",
"(",
"facetName",
")",
";",
"}"
] |
The buckets of the given facet. Null if the facet does not exist
|
[
"The",
"buckets",
"of",
"the",
"given",
"facet",
".",
"Null",
"if",
"the",
"facet",
"does",
"not",
"exist"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/es/Facets.java#L167-L170
|
16,238
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/user/AbstractUserSession.java
|
AbstractUserSession.doKeepAuthorizedComponents
|
protected List<ComponentDto> doKeepAuthorizedComponents(String permission, Collection<ComponentDto> components) {
boolean allowPublicComponent = PUBLIC_PERMISSIONS.contains(permission);
return components.stream()
.filter(c -> (allowPublicComponent && !c.isPrivate()) || hasComponentPermission(permission, c))
.collect(MoreCollectors.toList());
}
|
java
|
protected List<ComponentDto> doKeepAuthorizedComponents(String permission, Collection<ComponentDto> components) {
boolean allowPublicComponent = PUBLIC_PERMISSIONS.contains(permission);
return components.stream()
.filter(c -> (allowPublicComponent && !c.isPrivate()) || hasComponentPermission(permission, c))
.collect(MoreCollectors.toList());
}
|
[
"protected",
"List",
"<",
"ComponentDto",
">",
"doKeepAuthorizedComponents",
"(",
"String",
"permission",
",",
"Collection",
"<",
"ComponentDto",
">",
"components",
")",
"{",
"boolean",
"allowPublicComponent",
"=",
"PUBLIC_PERMISSIONS",
".",
"contains",
"(",
"permission",
")",
";",
"return",
"components",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"c",
"->",
"(",
"allowPublicComponent",
"&&",
"!",
"c",
".",
"isPrivate",
"(",
")",
")",
"||",
"hasComponentPermission",
"(",
"permission",
",",
"c",
")",
")",
".",
"collect",
"(",
"MoreCollectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
Naive implementation, to be overridden if needed
|
[
"Naive",
"implementation",
"to",
"be",
"overridden",
"if",
"needed"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/user/AbstractUserSession.java#L133-L138
|
16,239
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/setting/ChildSettings.java
|
ChildSettings.getProperties
|
@Override
public Map<String, String> getProperties() {
// order is important. local properties override parent properties.
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.putAll(parentSettings.getProperties());
builder.putAll(localProperties);
return builder.build();
}
|
java
|
@Override
public Map<String, String> getProperties() {
// order is important. local properties override parent properties.
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.putAll(parentSettings.getProperties());
builder.putAll(localProperties);
return builder.build();
}
|
[
"@",
"Override",
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getProperties",
"(",
")",
"{",
"// order is important. local properties override parent properties.",
"ImmutableMap",
".",
"Builder",
"<",
"String",
",",
"String",
">",
"builder",
"=",
"ImmutableMap",
".",
"builder",
"(",
")",
";",
"builder",
".",
"putAll",
"(",
"parentSettings",
".",
"getProperties",
"(",
")",
")",
";",
"builder",
".",
"putAll",
"(",
"localProperties",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] |
Only returns the currently loaded properties.
<p>
On the Web Server, global properties are loaded lazily when requested by name. Therefor,
this will return only global properties which have been requested using
{@link #get(String)} at least once prior to this call.
|
[
"Only",
"returns",
"the",
"currently",
"loaded",
"properties",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/setting/ChildSettings.java#L71-L78
|
16,240
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/duplication/DuplicationDao.java
|
DuplicationDao.insert
|
public void insert(DbSession session, DuplicationUnitDto dto) {
session.getMapper(DuplicationMapper.class).batchInsert(dto);
}
|
java
|
public void insert(DbSession session, DuplicationUnitDto dto) {
session.getMapper(DuplicationMapper.class).batchInsert(dto);
}
|
[
"public",
"void",
"insert",
"(",
"DbSession",
"session",
",",
"DuplicationUnitDto",
"dto",
")",
"{",
"session",
".",
"getMapper",
"(",
"DuplicationMapper",
".",
"class",
")",
".",
"batchInsert",
"(",
"dto",
")",
";",
"}"
] |
Insert rows in the table DUPLICATIONS_INDEX.
Note that generated ids are not returned.
|
[
"Insert",
"rows",
"in",
"the",
"table",
"DUPLICATIONS_INDEX",
".",
"Note",
"that",
"generated",
"ids",
"are",
"not",
"returned",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/duplication/DuplicationDao.java#L45-L47
|
16,241
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/platform/PluginLoader.java
|
PluginLoader.basePluginKey
|
static String basePluginKey(PluginInfo plugin, Map<String, PluginInfo> allPluginsPerKey) {
String base = plugin.getKey();
String parentKey = plugin.getBasePlugin();
while (!Strings.isNullOrEmpty(parentKey)) {
PluginInfo parentPlugin = allPluginsPerKey.get(parentKey);
base = parentPlugin.getKey();
parentKey = parentPlugin.getBasePlugin();
}
return base;
}
|
java
|
static String basePluginKey(PluginInfo plugin, Map<String, PluginInfo> allPluginsPerKey) {
String base = plugin.getKey();
String parentKey = plugin.getBasePlugin();
while (!Strings.isNullOrEmpty(parentKey)) {
PluginInfo parentPlugin = allPluginsPerKey.get(parentKey);
base = parentPlugin.getKey();
parentKey = parentPlugin.getBasePlugin();
}
return base;
}
|
[
"static",
"String",
"basePluginKey",
"(",
"PluginInfo",
"plugin",
",",
"Map",
"<",
"String",
",",
"PluginInfo",
">",
"allPluginsPerKey",
")",
"{",
"String",
"base",
"=",
"plugin",
".",
"getKey",
"(",
")",
";",
"String",
"parentKey",
"=",
"plugin",
".",
"getBasePlugin",
"(",
")",
";",
"while",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"parentKey",
")",
")",
"{",
"PluginInfo",
"parentPlugin",
"=",
"allPluginsPerKey",
".",
"get",
"(",
"parentKey",
")",
";",
"base",
"=",
"parentPlugin",
".",
"getKey",
"(",
")",
";",
"parentKey",
"=",
"parentPlugin",
".",
"getBasePlugin",
"(",
")",
";",
"}",
"return",
"base",
";",
"}"
] |
Get the root key of a tree of plugins. For example if plugin C depends on B, which depends on A, then
B and C must be attached to the classloader of A. The method returns A in the three cases.
|
[
"Get",
"the",
"root",
"key",
"of",
"a",
"tree",
"of",
"plugins",
".",
"For",
"example",
"if",
"plugin",
"C",
"depends",
"on",
"B",
"which",
"depends",
"on",
"A",
"then",
"B",
"and",
"C",
"must",
"be",
"attached",
"to",
"the",
"classloader",
"of",
"A",
".",
"The",
"method",
"returns",
"A",
"in",
"the",
"three",
"cases",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/platform/PluginLoader.java#L158-L167
|
16,242
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/CharsetValidation.java
|
CharsetValidation.isUTF16
|
public Result isUTF16(byte[] buffer, boolean failOnNull) {
if (buffer.length < 2) {
return Result.INVALID;
}
int beAscii = 0;
int beLines = 0;
int leAscii = 0;
int leLines = 0;
for (int i = 0; i < buffer.length / 2; i++) {
// using bytes is fine, since we will compare with positive numbers only
byte c1 = buffer[i * 2];
byte c2 = buffer[i * 2 + 1];
if (c1 == 0) {
if (c2 != 0) {
if (c2 == 0x0a || c2 == 0x0d) {
beLines++;
}
beAscii++;
} else if (failOnNull) {
// it's probably UTF-32 or binary
return Result.INVALID;
}
} else if (c2 == 0) {
leAscii++;
if (c1 == 0x0a || c1 == 0x0d) {
leLines++;
}
}
}
double beAsciiPerc = beAscii * 2.0 / (double) buffer.length;
double leAsciiPerc = leAscii * 2.0 / (double) buffer.length;
if (leLines == 0) {
// could be BE
if (beAsciiPerc >= UTF_16_NULL_PASS_THRESHOLD && leAsciiPerc < UTF_16_NULL_FAIL_THRESHOLD) {
return Result.newValid(StandardCharsets.UTF_16BE);
}
if (beLines > 0) {
// this gives FPs for UTF-32 if !failOnNull
return Result.newValid(StandardCharsets.UTF_16BE);
}
} else if (beLines > 0) {
// lines detected with both endiness -> can't be utf-16
return Result.INVALID;
}
if (beLines == 0) {
// could be BE
if (leAsciiPerc >= UTF_16_NULL_PASS_THRESHOLD && beAsciiPerc < UTF_16_NULL_FAIL_THRESHOLD) {
return Result.newValid(StandardCharsets.UTF_16LE);
}
if (leLines > 0) {
// this gives FPs for UTF-32 if !failOnNull
return Result.newValid(StandardCharsets.UTF_16LE);
}
}
// if we reach here, means that there wasn't a line feed for a single endiness and we didn't see a strong null pattern for any of the
// endiness.
// It could happen if there are no line feeds in the text and it's a language that does not use ANSI (unicode > 255).
return new Result(Validation.MAYBE, null);
}
|
java
|
public Result isUTF16(byte[] buffer, boolean failOnNull) {
if (buffer.length < 2) {
return Result.INVALID;
}
int beAscii = 0;
int beLines = 0;
int leAscii = 0;
int leLines = 0;
for (int i = 0; i < buffer.length / 2; i++) {
// using bytes is fine, since we will compare with positive numbers only
byte c1 = buffer[i * 2];
byte c2 = buffer[i * 2 + 1];
if (c1 == 0) {
if (c2 != 0) {
if (c2 == 0x0a || c2 == 0x0d) {
beLines++;
}
beAscii++;
} else if (failOnNull) {
// it's probably UTF-32 or binary
return Result.INVALID;
}
} else if (c2 == 0) {
leAscii++;
if (c1 == 0x0a || c1 == 0x0d) {
leLines++;
}
}
}
double beAsciiPerc = beAscii * 2.0 / (double) buffer.length;
double leAsciiPerc = leAscii * 2.0 / (double) buffer.length;
if (leLines == 0) {
// could be BE
if (beAsciiPerc >= UTF_16_NULL_PASS_THRESHOLD && leAsciiPerc < UTF_16_NULL_FAIL_THRESHOLD) {
return Result.newValid(StandardCharsets.UTF_16BE);
}
if (beLines > 0) {
// this gives FPs for UTF-32 if !failOnNull
return Result.newValid(StandardCharsets.UTF_16BE);
}
} else if (beLines > 0) {
// lines detected with both endiness -> can't be utf-16
return Result.INVALID;
}
if (beLines == 0) {
// could be BE
if (leAsciiPerc >= UTF_16_NULL_PASS_THRESHOLD && beAsciiPerc < UTF_16_NULL_FAIL_THRESHOLD) {
return Result.newValid(StandardCharsets.UTF_16LE);
}
if (leLines > 0) {
// this gives FPs for UTF-32 if !failOnNull
return Result.newValid(StandardCharsets.UTF_16LE);
}
}
// if we reach here, means that there wasn't a line feed for a single endiness and we didn't see a strong null pattern for any of the
// endiness.
// It could happen if there are no line feeds in the text and it's a language that does not use ANSI (unicode > 255).
return new Result(Validation.MAYBE, null);
}
|
[
"public",
"Result",
"isUTF16",
"(",
"byte",
"[",
"]",
"buffer",
",",
"boolean",
"failOnNull",
")",
"{",
"if",
"(",
"buffer",
".",
"length",
"<",
"2",
")",
"{",
"return",
"Result",
".",
"INVALID",
";",
"}",
"int",
"beAscii",
"=",
"0",
";",
"int",
"beLines",
"=",
"0",
";",
"int",
"leAscii",
"=",
"0",
";",
"int",
"leLines",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"buffer",
".",
"length",
"/",
"2",
";",
"i",
"++",
")",
"{",
"// using bytes is fine, since we will compare with positive numbers only",
"byte",
"c1",
"=",
"buffer",
"[",
"i",
"*",
"2",
"]",
";",
"byte",
"c2",
"=",
"buffer",
"[",
"i",
"*",
"2",
"+",
"1",
"]",
";",
"if",
"(",
"c1",
"==",
"0",
")",
"{",
"if",
"(",
"c2",
"!=",
"0",
")",
"{",
"if",
"(",
"c2",
"==",
"0x0a",
"||",
"c2",
"==",
"0x0d",
")",
"{",
"beLines",
"++",
";",
"}",
"beAscii",
"++",
";",
"}",
"else",
"if",
"(",
"failOnNull",
")",
"{",
"// it's probably UTF-32 or binary",
"return",
"Result",
".",
"INVALID",
";",
"}",
"}",
"else",
"if",
"(",
"c2",
"==",
"0",
")",
"{",
"leAscii",
"++",
";",
"if",
"(",
"c1",
"==",
"0x0a",
"||",
"c1",
"==",
"0x0d",
")",
"{",
"leLines",
"++",
";",
"}",
"}",
"}",
"double",
"beAsciiPerc",
"=",
"beAscii",
"*",
"2.0",
"/",
"(",
"double",
")",
"buffer",
".",
"length",
";",
"double",
"leAsciiPerc",
"=",
"leAscii",
"*",
"2.0",
"/",
"(",
"double",
")",
"buffer",
".",
"length",
";",
"if",
"(",
"leLines",
"==",
"0",
")",
"{",
"// could be BE",
"if",
"(",
"beAsciiPerc",
">=",
"UTF_16_NULL_PASS_THRESHOLD",
"&&",
"leAsciiPerc",
"<",
"UTF_16_NULL_FAIL_THRESHOLD",
")",
"{",
"return",
"Result",
".",
"newValid",
"(",
"StandardCharsets",
".",
"UTF_16BE",
")",
";",
"}",
"if",
"(",
"beLines",
">",
"0",
")",
"{",
"// this gives FPs for UTF-32 if !failOnNull",
"return",
"Result",
".",
"newValid",
"(",
"StandardCharsets",
".",
"UTF_16BE",
")",
";",
"}",
"}",
"else",
"if",
"(",
"beLines",
">",
"0",
")",
"{",
"// lines detected with both endiness -> can't be utf-16",
"return",
"Result",
".",
"INVALID",
";",
"}",
"if",
"(",
"beLines",
"==",
"0",
")",
"{",
"// could be BE",
"if",
"(",
"leAsciiPerc",
">=",
"UTF_16_NULL_PASS_THRESHOLD",
"&&",
"beAsciiPerc",
"<",
"UTF_16_NULL_FAIL_THRESHOLD",
")",
"{",
"return",
"Result",
".",
"newValid",
"(",
"StandardCharsets",
".",
"UTF_16LE",
")",
";",
"}",
"if",
"(",
"leLines",
">",
"0",
")",
"{",
"// this gives FPs for UTF-32 if !failOnNull",
"return",
"Result",
".",
"newValid",
"(",
"StandardCharsets",
".",
"UTF_16LE",
")",
";",
"}",
"}",
"// if we reach here, means that there wasn't a line feed for a single endiness and we didn't see a strong null pattern for any of the",
"// endiness.",
"// It could happen if there are no line feeds in the text and it's a language that does not use ANSI (unicode > 255).",
"return",
"new",
"Result",
"(",
"Validation",
".",
"MAYBE",
",",
"null",
")",
";",
"}"
] |
Checks if an array of bytes looks UTF-16 encoded.
We look for clues by checking the presence of nulls and new line control chars in both little and big endian byte orders.
Failing on nulls will greatly reduce FPs if the buffer is actually encoded in UTF-32.
Note that for any unicode between 0-255, UTF-16 encodes it directly in 2 bytes, being the first 0 (null). Since ASCII, ANSI and control chars are
within this range, we look for number of nulls and see if it is above a certain threshold.
It's possible to have valid chars that map to the opposite (non-null followed by a null) even though it is very unlike.
That will happen, for example, for any unicode 0x??00, being ?? between 00 and D7. For this reason, we give a small maximum tolerance
for opposite nulls (10%).
Line feed code point (0x000A) reversed would be (0x0A00). This code point is reserved and should never be found.
|
[
"Checks",
"if",
"an",
"array",
"of",
"bytes",
"looks",
"UTF",
"-",
"16",
"encoded",
".",
"We",
"look",
"for",
"clues",
"by",
"checking",
"the",
"presence",
"of",
"nulls",
"and",
"new",
"line",
"control",
"chars",
"in",
"both",
"little",
"and",
"big",
"endian",
"byte",
"orders",
".",
"Failing",
"on",
"nulls",
"will",
"greatly",
"reduce",
"FPs",
"if",
"the",
"buffer",
"is",
"actually",
"encoded",
"in",
"UTF",
"-",
"32",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/CharsetValidation.java#L63-L127
|
16,243
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/CharsetValidation.java
|
CharsetValidation.isValidWindows1252
|
public Result isValidWindows1252(byte[] buf) {
for (byte b : buf) {
if (!VALID_WINDOWS_1252[b + 128]) {
return Result.INVALID;
}
}
try {
return new Result(Validation.MAYBE, Charset.forName("Windows-1252"));
} catch (UnsupportedCharsetException e) {
return Result.INVALID;
}
}
|
java
|
public Result isValidWindows1252(byte[] buf) {
for (byte b : buf) {
if (!VALID_WINDOWS_1252[b + 128]) {
return Result.INVALID;
}
}
try {
return new Result(Validation.MAYBE, Charset.forName("Windows-1252"));
} catch (UnsupportedCharsetException e) {
return Result.INVALID;
}
}
|
[
"public",
"Result",
"isValidWindows1252",
"(",
"byte",
"[",
"]",
"buf",
")",
"{",
"for",
"(",
"byte",
"b",
":",
"buf",
")",
"{",
"if",
"(",
"!",
"VALID_WINDOWS_1252",
"[",
"b",
"+",
"128",
"]",
")",
"{",
"return",
"Result",
".",
"INVALID",
";",
"}",
"}",
"try",
"{",
"return",
"new",
"Result",
"(",
"Validation",
".",
"MAYBE",
",",
"Charset",
".",
"forName",
"(",
"\"Windows-1252\"",
")",
")",
";",
"}",
"catch",
"(",
"UnsupportedCharsetException",
"e",
")",
"{",
"return",
"Result",
".",
"INVALID",
";",
"}",
"}"
] |
Verify that the buffer doesn't contain bytes that are not supposed to be used by Windows-1252.
@return Result object with Validation.MAYBE and Windows-1252 if no unknown characters are used,
otherwise Result.INVALID
@param buf byte buffer to validate
|
[
"Verify",
"that",
"the",
"buffer",
"doesn",
"t",
"contain",
"bytes",
"that",
"are",
"not",
"supposed",
"to",
"be",
"used",
"by",
"Windows",
"-",
"1252",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/CharsetValidation.java#L276-L288
|
16,244
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/util/cache/MemoryCache.java
|
MemoryCache.getAll
|
public Map<K, V> getAll(Iterable<K> keys) {
List<K> missingKeys = new ArrayList<>();
Map<K, V> result = new HashMap<>();
for (K key : keys) {
V value = map.get(key);
if (value == null && !map.containsKey(key)) {
missingKeys.add(key);
} else {
result.put(key, value);
}
}
if (!missingKeys.isEmpty()) {
Map<K, V> missingValues = loader.loadAll(missingKeys);
map.putAll(missingValues);
result.putAll(missingValues);
for (K missingKey : missingKeys) {
if (!map.containsKey(missingKey)) {
map.put(missingKey, null);
result.put(missingKey, null);
}
}
}
return result;
}
|
java
|
public Map<K, V> getAll(Iterable<K> keys) {
List<K> missingKeys = new ArrayList<>();
Map<K, V> result = new HashMap<>();
for (K key : keys) {
V value = map.get(key);
if (value == null && !map.containsKey(key)) {
missingKeys.add(key);
} else {
result.put(key, value);
}
}
if (!missingKeys.isEmpty()) {
Map<K, V> missingValues = loader.loadAll(missingKeys);
map.putAll(missingValues);
result.putAll(missingValues);
for (K missingKey : missingKeys) {
if (!map.containsKey(missingKey)) {
map.put(missingKey, null);
result.put(missingKey, null);
}
}
}
return result;
}
|
[
"public",
"Map",
"<",
"K",
",",
"V",
">",
"getAll",
"(",
"Iterable",
"<",
"K",
">",
"keys",
")",
"{",
"List",
"<",
"K",
">",
"missingKeys",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Map",
"<",
"K",
",",
"V",
">",
"result",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"K",
"key",
":",
"keys",
")",
"{",
"V",
"value",
"=",
"map",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"==",
"null",
"&&",
"!",
"map",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"missingKeys",
".",
"add",
"(",
"key",
")",
";",
"}",
"else",
"{",
"result",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"if",
"(",
"!",
"missingKeys",
".",
"isEmpty",
"(",
")",
")",
"{",
"Map",
"<",
"K",
",",
"V",
">",
"missingValues",
"=",
"loader",
".",
"loadAll",
"(",
"missingKeys",
")",
";",
"map",
".",
"putAll",
"(",
"missingValues",
")",
";",
"result",
".",
"putAll",
"(",
"missingValues",
")",
";",
"for",
"(",
"K",
"missingKey",
":",
"missingKeys",
")",
"{",
"if",
"(",
"!",
"map",
".",
"containsKey",
"(",
"missingKey",
")",
")",
"{",
"map",
".",
"put",
"(",
"missingKey",
",",
"null",
")",
";",
"result",
".",
"put",
"(",
"missingKey",
",",
"null",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Get values associated with keys. All the requested keys are included
in the Map result. Value is null if the key is not found in cache.
|
[
"Get",
"values",
"associated",
"with",
"keys",
".",
"All",
"the",
"requested",
"keys",
"are",
"included",
"in",
"the",
"Map",
"result",
".",
"Value",
"is",
"null",
"if",
"the",
"key",
"is",
"not",
"found",
"in",
"cache",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/util/cache/MemoryCache.java#L64-L87
|
16,245
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java
|
LogbackHelper.configureForSubprocessGobbler
|
public void configureForSubprocessGobbler(Props props, String logPattern) {
if (isAllLogsToConsoleEnabled(props)) {
LoggerContext ctx = getRootContext();
ctx.getLogger(ROOT_LOGGER_NAME).addAppender(newConsoleAppender(ctx, "root_console", logPattern));
}
}
|
java
|
public void configureForSubprocessGobbler(Props props, String logPattern) {
if (isAllLogsToConsoleEnabled(props)) {
LoggerContext ctx = getRootContext();
ctx.getLogger(ROOT_LOGGER_NAME).addAppender(newConsoleAppender(ctx, "root_console", logPattern));
}
}
|
[
"public",
"void",
"configureForSubprocessGobbler",
"(",
"Props",
"props",
",",
"String",
"logPattern",
")",
"{",
"if",
"(",
"isAllLogsToConsoleEnabled",
"(",
"props",
")",
")",
"{",
"LoggerContext",
"ctx",
"=",
"getRootContext",
"(",
")",
";",
"ctx",
".",
"getLogger",
"(",
"ROOT_LOGGER_NAME",
")",
".",
"addAppender",
"(",
"newConsoleAppender",
"(",
"ctx",
",",
"\"root_console\"",
",",
"logPattern",
")",
")",
";",
"}",
"}"
] |
Make the logback configuration for a sub process to correctly push all its logs to be read by a stream gobbler
on the sub process's System.out.
@see #buildLogPattern(RootLoggerConfig)
|
[
"Make",
"the",
"logback",
"configuration",
"for",
"a",
"sub",
"process",
"to",
"correctly",
"push",
"all",
"its",
"logs",
"to",
"be",
"read",
"by",
"a",
"stream",
"gobbler",
"on",
"the",
"sub",
"process",
"s",
"System",
".",
"out",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java#L211-L216
|
16,246
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java
|
LogbackHelper.resetFromXml
|
public void resetFromXml(String xmlResourcePath) throws JoranException {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
context.reset();
configurator.doConfigure(LogbackHelper.class.getResource(xmlResourcePath));
}
|
java
|
public void resetFromXml(String xmlResourcePath) throws JoranException {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
context.reset();
configurator.doConfigure(LogbackHelper.class.getResource(xmlResourcePath));
}
|
[
"public",
"void",
"resetFromXml",
"(",
"String",
"xmlResourcePath",
")",
"throws",
"JoranException",
"{",
"LoggerContext",
"context",
"=",
"(",
"LoggerContext",
")",
"LoggerFactory",
".",
"getILoggerFactory",
"(",
")",
";",
"JoranConfigurator",
"configurator",
"=",
"new",
"JoranConfigurator",
"(",
")",
";",
"configurator",
".",
"setContext",
"(",
"context",
")",
";",
"context",
".",
"reset",
"(",
")",
";",
"configurator",
".",
"doConfigure",
"(",
"LogbackHelper",
".",
"class",
".",
"getResource",
"(",
"xmlResourcePath",
")",
")",
";",
"}"
] |
Generally used to reset logback in logging tests
|
[
"Generally",
"used",
"to",
"reset",
"logback",
"in",
"logging",
"tests"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java#L233-L239
|
16,247
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/ProcessEntryPoint.java
|
ProcessEntryPoint.launch
|
public void launch(Monitored mp) {
if (!lifecycle.tryToMoveTo(Lifecycle.State.STARTING)) {
throw new IllegalStateException("Already started");
}
monitored = mp;
Logger logger = LoggerFactory.getLogger(getClass());
try {
launch(logger);
} catch (Exception e) {
logger.warn("Fail to start {}", getKey(), e);
} finally {
stop();
}
}
|
java
|
public void launch(Monitored mp) {
if (!lifecycle.tryToMoveTo(Lifecycle.State.STARTING)) {
throw new IllegalStateException("Already started");
}
monitored = mp;
Logger logger = LoggerFactory.getLogger(getClass());
try {
launch(logger);
} catch (Exception e) {
logger.warn("Fail to start {}", getKey(), e);
} finally {
stop();
}
}
|
[
"public",
"void",
"launch",
"(",
"Monitored",
"mp",
")",
"{",
"if",
"(",
"!",
"lifecycle",
".",
"tryToMoveTo",
"(",
"Lifecycle",
".",
"State",
".",
"STARTING",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Already started\"",
")",
";",
"}",
"monitored",
"=",
"mp",
";",
"Logger",
"logger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"getClass",
"(",
")",
")",
";",
"try",
"{",
"launch",
"(",
"logger",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Fail to start {}\"",
",",
"getKey",
"(",
")",
",",
"e",
")",
";",
"}",
"finally",
"{",
"stop",
"(",
")",
";",
"}",
"}"
] |
Launch process and waits until it's down
|
[
"Launch",
"process",
"and",
"waits",
"until",
"it",
"s",
"down"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/ProcessEntryPoint.java#L92-L106
|
16,248
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/rule/RuleTagHelper.java
|
RuleTagHelper.applyTags
|
static boolean applyTags(RuleDto rule, Set<String> tags) {
for (String tag : tags) {
RuleTagFormat.validate(tag);
}
Set<String> initialTags = rule.getTags();
final Set<String> systemTags = rule.getSystemTags();
Set<String> withoutSystemTags = Sets.filter(tags, input -> input != null && !systemTags.contains(input));
rule.setTags(withoutSystemTags);
return withoutSystemTags.size() != initialTags.size() || !withoutSystemTags.containsAll(initialTags);
}
|
java
|
static boolean applyTags(RuleDto rule, Set<String> tags) {
for (String tag : tags) {
RuleTagFormat.validate(tag);
}
Set<String> initialTags = rule.getTags();
final Set<String> systemTags = rule.getSystemTags();
Set<String> withoutSystemTags = Sets.filter(tags, input -> input != null && !systemTags.contains(input));
rule.setTags(withoutSystemTags);
return withoutSystemTags.size() != initialTags.size() || !withoutSystemTags.containsAll(initialTags);
}
|
[
"static",
"boolean",
"applyTags",
"(",
"RuleDto",
"rule",
",",
"Set",
"<",
"String",
">",
"tags",
")",
"{",
"for",
"(",
"String",
"tag",
":",
"tags",
")",
"{",
"RuleTagFormat",
".",
"validate",
"(",
"tag",
")",
";",
"}",
"Set",
"<",
"String",
">",
"initialTags",
"=",
"rule",
".",
"getTags",
"(",
")",
";",
"final",
"Set",
"<",
"String",
">",
"systemTags",
"=",
"rule",
".",
"getSystemTags",
"(",
")",
";",
"Set",
"<",
"String",
">",
"withoutSystemTags",
"=",
"Sets",
".",
"filter",
"(",
"tags",
",",
"input",
"->",
"input",
"!=",
"null",
"&&",
"!",
"systemTags",
".",
"contains",
"(",
"input",
")",
")",
";",
"rule",
".",
"setTags",
"(",
"withoutSystemTags",
")",
";",
"return",
"withoutSystemTags",
".",
"size",
"(",
")",
"!=",
"initialTags",
".",
"size",
"(",
")",
"||",
"!",
"withoutSystemTags",
".",
"containsAll",
"(",
"initialTags",
")",
";",
"}"
] |
Validates tags and resolves conflicts between user and system tags.
|
[
"Validates",
"tags",
"and",
"resolves",
"conflicts",
"between",
"user",
"and",
"system",
"tags",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleTagHelper.java#L36-L46
|
16,249
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDao.java
|
ActiveRuleDao.selectByProfileUuid
|
public List<OrgActiveRuleDto> selectByProfileUuid(DbSession dbSession, String uuid) {
return mapper(dbSession).selectByProfileUuid(uuid);
}
|
java
|
public List<OrgActiveRuleDto> selectByProfileUuid(DbSession dbSession, String uuid) {
return mapper(dbSession).selectByProfileUuid(uuid);
}
|
[
"public",
"List",
"<",
"OrgActiveRuleDto",
">",
"selectByProfileUuid",
"(",
"DbSession",
"dbSession",
",",
"String",
"uuid",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectByProfileUuid",
"(",
"uuid",
")",
";",
"}"
] |
Active rule on removed rule are NOT returned
|
[
"Active",
"rule",
"on",
"removed",
"rule",
"are",
"NOT",
"returned"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDao.java#L69-L71
|
16,250
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDao.java
|
ActiveRuleDao.selectParamsByActiveRuleId
|
public List<ActiveRuleParamDto> selectParamsByActiveRuleId(DbSession dbSession, Integer activeRuleId) {
return mapper(dbSession).selectParamsByActiveRuleId(activeRuleId);
}
|
java
|
public List<ActiveRuleParamDto> selectParamsByActiveRuleId(DbSession dbSession, Integer activeRuleId) {
return mapper(dbSession).selectParamsByActiveRuleId(activeRuleId);
}
|
[
"public",
"List",
"<",
"ActiveRuleParamDto",
">",
"selectParamsByActiveRuleId",
"(",
"DbSession",
"dbSession",
",",
"Integer",
"activeRuleId",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectParamsByActiveRuleId",
"(",
"activeRuleId",
")",
";",
"}"
] |
Nested DTO ActiveRuleParams
|
[
"Nested",
"DTO",
"ActiveRuleParams"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDao.java#L136-L138
|
16,251
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueAssigner.java
|
IssueAssigner.guessScmAuthor
|
private Optional<String> guessScmAuthor(DefaultIssue issue, Component component) {
String author = null;
if (scmChangesets != null) {
author = IssueLocations.allLinesFor(issue, component.getUuid())
.filter(scmChangesets::hasChangesetForLine)
.mapToObj(scmChangesets::getChangesetForLine)
.filter(c -> StringUtils.isNotEmpty(c.getAuthor()))
.max(Comparator.comparingLong(Changeset::getDate))
.map(Changeset::getAuthor)
.orElse(null);
}
return Optional.ofNullable(defaultIfEmpty(author, lastCommitAuthor));
}
|
java
|
private Optional<String> guessScmAuthor(DefaultIssue issue, Component component) {
String author = null;
if (scmChangesets != null) {
author = IssueLocations.allLinesFor(issue, component.getUuid())
.filter(scmChangesets::hasChangesetForLine)
.mapToObj(scmChangesets::getChangesetForLine)
.filter(c -> StringUtils.isNotEmpty(c.getAuthor()))
.max(Comparator.comparingLong(Changeset::getDate))
.map(Changeset::getAuthor)
.orElse(null);
}
return Optional.ofNullable(defaultIfEmpty(author, lastCommitAuthor));
}
|
[
"private",
"Optional",
"<",
"String",
">",
"guessScmAuthor",
"(",
"DefaultIssue",
"issue",
",",
"Component",
"component",
")",
"{",
"String",
"author",
"=",
"null",
";",
"if",
"(",
"scmChangesets",
"!=",
"null",
")",
"{",
"author",
"=",
"IssueLocations",
".",
"allLinesFor",
"(",
"issue",
",",
"component",
".",
"getUuid",
"(",
")",
")",
".",
"filter",
"(",
"scmChangesets",
"::",
"hasChangesetForLine",
")",
".",
"mapToObj",
"(",
"scmChangesets",
"::",
"getChangesetForLine",
")",
".",
"filter",
"(",
"c",
"->",
"StringUtils",
".",
"isNotEmpty",
"(",
"c",
".",
"getAuthor",
"(",
")",
")",
")",
".",
"max",
"(",
"Comparator",
".",
"comparingLong",
"(",
"Changeset",
"::",
"getDate",
")",
")",
".",
"map",
"(",
"Changeset",
"::",
"getAuthor",
")",
".",
"orElse",
"(",
"null",
")",
";",
"}",
"return",
"Optional",
".",
"ofNullable",
"(",
"defaultIfEmpty",
"(",
"author",
",",
"lastCommitAuthor",
")",
")",
";",
"}"
] |
Author of the latest change on the lines involved by the issue.
If no authors are set on the lines, then the author of the latest change on the file
is returned.
|
[
"Author",
"of",
"the",
"latest",
"change",
"on",
"the",
"lines",
"involved",
"by",
"the",
"issue",
".",
"If",
"no",
"authors",
"are",
"set",
"on",
"the",
"lines",
"then",
"the",
"author",
"of",
"the",
"latest",
"change",
"on",
"the",
"file",
"is",
"returned",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueAssigner.java#L112-L124
|
16,252
|
SonarSource/sonarqube
|
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfiles.java
|
PopulateTableDefaultQProfiles.selectOrgsWithMultipleDefaultProfiles
|
private static Set<OrgLang> selectOrgsWithMultipleDefaultProfiles(Context context) throws SQLException {
Select rows = context.prepareSelect("select organization_uuid, language from rules_profiles " +
" where is_default = ? " +
" group by organization_uuid, language " +
" having count(kee) > 1 ")
.setBoolean(1, true);
return new HashSet<>(rows.list(row -> new OrgLang(row.getString(1), row.getString(2))));
}
|
java
|
private static Set<OrgLang> selectOrgsWithMultipleDefaultProfiles(Context context) throws SQLException {
Select rows = context.prepareSelect("select organization_uuid, language from rules_profiles " +
" where is_default = ? " +
" group by organization_uuid, language " +
" having count(kee) > 1 ")
.setBoolean(1, true);
return new HashSet<>(rows.list(row -> new OrgLang(row.getString(1), row.getString(2))));
}
|
[
"private",
"static",
"Set",
"<",
"OrgLang",
">",
"selectOrgsWithMultipleDefaultProfiles",
"(",
"Context",
"context",
")",
"throws",
"SQLException",
"{",
"Select",
"rows",
"=",
"context",
".",
"prepareSelect",
"(",
"\"select organization_uuid, language from rules_profiles \"",
"+",
"\" where is_default = ? \"",
"+",
"\" group by organization_uuid, language \"",
"+",
"\" having count(kee) > 1 \"",
")",
".",
"setBoolean",
"(",
"1",
",",
"true",
")",
";",
"return",
"new",
"HashSet",
"<>",
"(",
"rows",
".",
"list",
"(",
"row",
"->",
"new",
"OrgLang",
"(",
"row",
".",
"getString",
"(",
"1",
")",
",",
"row",
".",
"getString",
"(",
"2",
")",
")",
")",
")",
";",
"}"
] |
By design the table rules_profiles does not enforce to have a single
profile marked as default for an organization and language.
This method returns the buggy rows.
|
[
"By",
"design",
"the",
"table",
"rules_profiles",
"does",
"not",
"enforce",
"to",
"have",
"a",
"single",
"profile",
"marked",
"as",
"default",
"for",
"an",
"organization",
"and",
"language",
".",
"This",
"method",
"returns",
"the",
"buggy",
"rows",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfiles.java#L85-L92
|
16,253
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/util/ScannerUtils.java
|
ScannerUtils.cleanKeyForFilename
|
public static String cleanKeyForFilename(String projectKey) {
String cleanKey = StringUtils.deleteWhitespace(projectKey);
return StringUtils.replace(cleanKey, ":", "_");
}
|
java
|
public static String cleanKeyForFilename(String projectKey) {
String cleanKey = StringUtils.deleteWhitespace(projectKey);
return StringUtils.replace(cleanKey, ":", "_");
}
|
[
"public",
"static",
"String",
"cleanKeyForFilename",
"(",
"String",
"projectKey",
")",
"{",
"String",
"cleanKey",
"=",
"StringUtils",
".",
"deleteWhitespace",
"(",
"projectKey",
")",
";",
"return",
"StringUtils",
".",
"replace",
"(",
"cleanKey",
",",
"\":\"",
",",
"\"_\"",
")",
";",
"}"
] |
Clean provided string to remove chars that are not valid as file name.
@param projectKey e.g. my:file
|
[
"Clean",
"provided",
"string",
"to",
"remove",
"chars",
"that",
"are",
"not",
"valid",
"as",
"file",
"name",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/util/ScannerUtils.java#L37-L40
|
16,254
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIndexer.java
|
IssueIndexer.deleteByKeys
|
public void deleteByKeys(String projectUuid, Collection<String> issueKeys) {
if (issueKeys.isEmpty()) {
return;
}
BulkIndexer bulkIndexer = createBulkIndexer(Size.REGULAR, IndexingListener.FAIL_ON_ERROR);
bulkIndexer.start();
issueKeys.forEach(issueKey -> bulkIndexer.addDeletion(TYPE_ISSUE.getMainType(), issueKey, AuthorizationDoc.idOf(projectUuid)));
bulkIndexer.stop();
}
|
java
|
public void deleteByKeys(String projectUuid, Collection<String> issueKeys) {
if (issueKeys.isEmpty()) {
return;
}
BulkIndexer bulkIndexer = createBulkIndexer(Size.REGULAR, IndexingListener.FAIL_ON_ERROR);
bulkIndexer.start();
issueKeys.forEach(issueKey -> bulkIndexer.addDeletion(TYPE_ISSUE.getMainType(), issueKey, AuthorizationDoc.idOf(projectUuid)));
bulkIndexer.stop();
}
|
[
"public",
"void",
"deleteByKeys",
"(",
"String",
"projectUuid",
",",
"Collection",
"<",
"String",
">",
"issueKeys",
")",
"{",
"if",
"(",
"issueKeys",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"BulkIndexer",
"bulkIndexer",
"=",
"createBulkIndexer",
"(",
"Size",
".",
"REGULAR",
",",
"IndexingListener",
".",
"FAIL_ON_ERROR",
")",
";",
"bulkIndexer",
".",
"start",
"(",
")",
";",
"issueKeys",
".",
"forEach",
"(",
"issueKey",
"->",
"bulkIndexer",
".",
"addDeletion",
"(",
"TYPE_ISSUE",
".",
"getMainType",
"(",
")",
",",
"issueKey",
",",
"AuthorizationDoc",
".",
"idOf",
"(",
"projectUuid",
")",
")",
")",
";",
"bulkIndexer",
".",
"stop",
"(",
")",
";",
"}"
] |
Used by Compute Engine, no need to recovery on errors
|
[
"Used",
"by",
"Compute",
"Engine",
"no",
"need",
"to",
"recovery",
"on",
"errors"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIndexer.java#L226-L235
|
16,255
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
|
RuleActivator.applySeverityAndParamToChange
|
private void applySeverityAndParamToChange(RuleActivation request, RuleActivationContext context, ActiveRuleChange change) {
RuleWrapper rule = context.getRule();
ActiveRuleWrapper activeRule = context.getActiveRule();
ActiveRuleWrapper parentActiveRule = context.getParentActiveRule();
// First apply severity
String severity;
if (request.isReset()) {
// load severity from parent profile, else from default values
severity = firstNonNull(
parentActiveRule != null ? parentActiveRule.get().getSeverityString() : null,
rule.get().getSeverityString());
} else if (context.getRulesProfile().isBuiltIn()) {
// for builtin quality profiles, the severity from profile, when null use the default severity of the rule
severity = firstNonNull(request.getSeverity(), rule.get().getSeverityString());
} else {
// load severity from request, else keep existing one (if already activated), else from parent, else from default
severity = firstNonNull(
request.getSeverity(),
activeRule == null ? null : activeRule.get().getSeverityString(),
parentActiveRule != null ? parentActiveRule.get().getSeverityString() : null,
rule.get().getSeverityString());
}
change.setSeverity(severity);
// Apply param values
for (RuleParamDto ruleParamDto : rule.getParams()) {
String paramKey = ruleParamDto.getName();
String paramValue;
if (request.isReset()) {
// load params from parent profile, else from default values
paramValue = firstNonNull(
parentActiveRule != null ? parentActiveRule.getParamValue(paramKey) : null,
rule.getParamDefaultValue(paramKey));
} else if (context.getRulesProfile().isBuiltIn()) {
// use the value defined in the profile definition, else the rule default value
paramValue = firstNonNull(
context.getRequestedParamValue(request, paramKey),
rule.getParamDefaultValue(paramKey));
} else {
String parentValue = parentActiveRule != null ? parentActiveRule.getParamValue(paramKey) : null;
String activeRuleValue = activeRule == null ? null : activeRule.getParamValue(paramKey);
paramValue = context.hasRequestedParamValue(request, paramKey) ?
// If the request contains the parameter then we're using either value from request, or parent value, or default value
firstNonNull(
context.getRequestedParamValue(request, paramKey),
parentValue,
rule.getParamDefaultValue(paramKey))
// If the request doesn't contain the parameter, then we're using either value in DB, or parent value, or default value
: firstNonNull(
activeRuleValue,
parentValue,
rule.getParamDefaultValue(paramKey));
}
change.setParameter(paramKey, validateParam(ruleParamDto, paramValue));
}
}
|
java
|
private void applySeverityAndParamToChange(RuleActivation request, RuleActivationContext context, ActiveRuleChange change) {
RuleWrapper rule = context.getRule();
ActiveRuleWrapper activeRule = context.getActiveRule();
ActiveRuleWrapper parentActiveRule = context.getParentActiveRule();
// First apply severity
String severity;
if (request.isReset()) {
// load severity from parent profile, else from default values
severity = firstNonNull(
parentActiveRule != null ? parentActiveRule.get().getSeverityString() : null,
rule.get().getSeverityString());
} else if (context.getRulesProfile().isBuiltIn()) {
// for builtin quality profiles, the severity from profile, when null use the default severity of the rule
severity = firstNonNull(request.getSeverity(), rule.get().getSeverityString());
} else {
// load severity from request, else keep existing one (if already activated), else from parent, else from default
severity = firstNonNull(
request.getSeverity(),
activeRule == null ? null : activeRule.get().getSeverityString(),
parentActiveRule != null ? parentActiveRule.get().getSeverityString() : null,
rule.get().getSeverityString());
}
change.setSeverity(severity);
// Apply param values
for (RuleParamDto ruleParamDto : rule.getParams()) {
String paramKey = ruleParamDto.getName();
String paramValue;
if (request.isReset()) {
// load params from parent profile, else from default values
paramValue = firstNonNull(
parentActiveRule != null ? parentActiveRule.getParamValue(paramKey) : null,
rule.getParamDefaultValue(paramKey));
} else if (context.getRulesProfile().isBuiltIn()) {
// use the value defined in the profile definition, else the rule default value
paramValue = firstNonNull(
context.getRequestedParamValue(request, paramKey),
rule.getParamDefaultValue(paramKey));
} else {
String parentValue = parentActiveRule != null ? parentActiveRule.getParamValue(paramKey) : null;
String activeRuleValue = activeRule == null ? null : activeRule.getParamValue(paramKey);
paramValue = context.hasRequestedParamValue(request, paramKey) ?
// If the request contains the parameter then we're using either value from request, or parent value, or default value
firstNonNull(
context.getRequestedParamValue(request, paramKey),
parentValue,
rule.getParamDefaultValue(paramKey))
// If the request doesn't contain the parameter, then we're using either value in DB, or parent value, or default value
: firstNonNull(
activeRuleValue,
parentValue,
rule.getParamDefaultValue(paramKey));
}
change.setParameter(paramKey, validateParam(ruleParamDto, paramValue));
}
}
|
[
"private",
"void",
"applySeverityAndParamToChange",
"(",
"RuleActivation",
"request",
",",
"RuleActivationContext",
"context",
",",
"ActiveRuleChange",
"change",
")",
"{",
"RuleWrapper",
"rule",
"=",
"context",
".",
"getRule",
"(",
")",
";",
"ActiveRuleWrapper",
"activeRule",
"=",
"context",
".",
"getActiveRule",
"(",
")",
";",
"ActiveRuleWrapper",
"parentActiveRule",
"=",
"context",
".",
"getParentActiveRule",
"(",
")",
";",
"// First apply severity",
"String",
"severity",
";",
"if",
"(",
"request",
".",
"isReset",
"(",
")",
")",
"{",
"// load severity from parent profile, else from default values",
"severity",
"=",
"firstNonNull",
"(",
"parentActiveRule",
"!=",
"null",
"?",
"parentActiveRule",
".",
"get",
"(",
")",
".",
"getSeverityString",
"(",
")",
":",
"null",
",",
"rule",
".",
"get",
"(",
")",
".",
"getSeverityString",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"context",
".",
"getRulesProfile",
"(",
")",
".",
"isBuiltIn",
"(",
")",
")",
"{",
"// for builtin quality profiles, the severity from profile, when null use the default severity of the rule",
"severity",
"=",
"firstNonNull",
"(",
"request",
".",
"getSeverity",
"(",
")",
",",
"rule",
".",
"get",
"(",
")",
".",
"getSeverityString",
"(",
")",
")",
";",
"}",
"else",
"{",
"// load severity from request, else keep existing one (if already activated), else from parent, else from default",
"severity",
"=",
"firstNonNull",
"(",
"request",
".",
"getSeverity",
"(",
")",
",",
"activeRule",
"==",
"null",
"?",
"null",
":",
"activeRule",
".",
"get",
"(",
")",
".",
"getSeverityString",
"(",
")",
",",
"parentActiveRule",
"!=",
"null",
"?",
"parentActiveRule",
".",
"get",
"(",
")",
".",
"getSeverityString",
"(",
")",
":",
"null",
",",
"rule",
".",
"get",
"(",
")",
".",
"getSeverityString",
"(",
")",
")",
";",
"}",
"change",
".",
"setSeverity",
"(",
"severity",
")",
";",
"// Apply param values",
"for",
"(",
"RuleParamDto",
"ruleParamDto",
":",
"rule",
".",
"getParams",
"(",
")",
")",
"{",
"String",
"paramKey",
"=",
"ruleParamDto",
".",
"getName",
"(",
")",
";",
"String",
"paramValue",
";",
"if",
"(",
"request",
".",
"isReset",
"(",
")",
")",
"{",
"// load params from parent profile, else from default values",
"paramValue",
"=",
"firstNonNull",
"(",
"parentActiveRule",
"!=",
"null",
"?",
"parentActiveRule",
".",
"getParamValue",
"(",
"paramKey",
")",
":",
"null",
",",
"rule",
".",
"getParamDefaultValue",
"(",
"paramKey",
")",
")",
";",
"}",
"else",
"if",
"(",
"context",
".",
"getRulesProfile",
"(",
")",
".",
"isBuiltIn",
"(",
")",
")",
"{",
"// use the value defined in the profile definition, else the rule default value",
"paramValue",
"=",
"firstNonNull",
"(",
"context",
".",
"getRequestedParamValue",
"(",
"request",
",",
"paramKey",
")",
",",
"rule",
".",
"getParamDefaultValue",
"(",
"paramKey",
")",
")",
";",
"}",
"else",
"{",
"String",
"parentValue",
"=",
"parentActiveRule",
"!=",
"null",
"?",
"parentActiveRule",
".",
"getParamValue",
"(",
"paramKey",
")",
":",
"null",
";",
"String",
"activeRuleValue",
"=",
"activeRule",
"==",
"null",
"?",
"null",
":",
"activeRule",
".",
"getParamValue",
"(",
"paramKey",
")",
";",
"paramValue",
"=",
"context",
".",
"hasRequestedParamValue",
"(",
"request",
",",
"paramKey",
")",
"?",
"// If the request contains the parameter then we're using either value from request, or parent value, or default value",
"firstNonNull",
"(",
"context",
".",
"getRequestedParamValue",
"(",
"request",
",",
"paramKey",
")",
",",
"parentValue",
",",
"rule",
".",
"getParamDefaultValue",
"(",
"paramKey",
")",
")",
"// If the request doesn't contain the parameter, then we're using either value in DB, or parent value, or default value",
":",
"firstNonNull",
"(",
"activeRuleValue",
",",
"parentValue",
",",
"rule",
".",
"getParamDefaultValue",
"(",
"paramKey",
")",
")",
";",
"}",
"change",
".",
"setParameter",
"(",
"paramKey",
",",
"validateParam",
"(",
"ruleParamDto",
",",
"paramValue",
")",
")",
";",
"}",
"}"
] |
Update severity and params
|
[
"Update",
"severity",
"and",
"params"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java#L159-L216
|
16,256
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
|
RuleActivator.isSameAsParent
|
private static boolean isSameAsParent(ActiveRuleChange change, RuleActivationContext context) {
ActiveRuleWrapper parentActiveRule = context.getParentActiveRule();
if (parentActiveRule == null) {
return false;
}
if (!StringUtils.equals(change.getSeverity(), parentActiveRule.get().getSeverityString())) {
return false;
}
for (Map.Entry<String, String> entry : change.getParameters().entrySet()) {
if (entry.getValue() != null && !entry.getValue().equals(parentActiveRule.getParamValue(entry.getKey()))) {
return false;
}
}
return true;
}
|
java
|
private static boolean isSameAsParent(ActiveRuleChange change, RuleActivationContext context) {
ActiveRuleWrapper parentActiveRule = context.getParentActiveRule();
if (parentActiveRule == null) {
return false;
}
if (!StringUtils.equals(change.getSeverity(), parentActiveRule.get().getSeverityString())) {
return false;
}
for (Map.Entry<String, String> entry : change.getParameters().entrySet()) {
if (entry.getValue() != null && !entry.getValue().equals(parentActiveRule.getParamValue(entry.getKey()))) {
return false;
}
}
return true;
}
|
[
"private",
"static",
"boolean",
"isSameAsParent",
"(",
"ActiveRuleChange",
"change",
",",
"RuleActivationContext",
"context",
")",
"{",
"ActiveRuleWrapper",
"parentActiveRule",
"=",
"context",
".",
"getParentActiveRule",
"(",
")",
";",
"if",
"(",
"parentActiveRule",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"StringUtils",
".",
"equals",
"(",
"change",
".",
"getSeverity",
"(",
")",
",",
"parentActiveRule",
".",
"get",
"(",
")",
".",
"getSeverityString",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"change",
".",
"getParameters",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
"!=",
"null",
"&&",
"!",
"entry",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"parentActiveRule",
".",
"getParamValue",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
True if trying to override an inherited rule but with exactly the same values
|
[
"True",
"if",
"trying",
"to",
"override",
"an",
"inherited",
"rule",
"but",
"with",
"exactly",
"the",
"same",
"values"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java#L454-L468
|
16,257
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureToMeasureDto.java
|
MeasureToMeasureDto.valueAsDouble
|
@CheckForNull
private static Double valueAsDouble(Measure measure) {
switch (measure.getValueType()) {
case BOOLEAN:
return measure.getBooleanValue() ? 1.0d : 0.0d;
case INT:
return (double) measure.getIntValue();
case LONG:
return (double) measure.getLongValue();
case DOUBLE:
return measure.getDoubleValue();
case NO_VALUE:
case STRING:
case LEVEL:
default:
return null;
}
}
|
java
|
@CheckForNull
private static Double valueAsDouble(Measure measure) {
switch (measure.getValueType()) {
case BOOLEAN:
return measure.getBooleanValue() ? 1.0d : 0.0d;
case INT:
return (double) measure.getIntValue();
case LONG:
return (double) measure.getLongValue();
case DOUBLE:
return measure.getDoubleValue();
case NO_VALUE:
case STRING:
case LEVEL:
default:
return null;
}
}
|
[
"@",
"CheckForNull",
"private",
"static",
"Double",
"valueAsDouble",
"(",
"Measure",
"measure",
")",
"{",
"switch",
"(",
"measure",
".",
"getValueType",
"(",
")",
")",
"{",
"case",
"BOOLEAN",
":",
"return",
"measure",
".",
"getBooleanValue",
"(",
")",
"?",
"1.0d",
":",
"0.0d",
";",
"case",
"INT",
":",
"return",
"(",
"double",
")",
"measure",
".",
"getIntValue",
"(",
")",
";",
"case",
"LONG",
":",
"return",
"(",
"double",
")",
"measure",
".",
"getLongValue",
"(",
")",
";",
"case",
"DOUBLE",
":",
"return",
"measure",
".",
"getDoubleValue",
"(",
")",
";",
"case",
"NO_VALUE",
":",
"case",
"STRING",
":",
"case",
"LEVEL",
":",
"default",
":",
"return",
"null",
";",
"}",
"}"
] |
return the numerical value as a double. It's the type used in db.
Returns null if no numerical value found
|
[
"return",
"the",
"numerical",
"value",
"as",
"a",
"double",
".",
"It",
"s",
"the",
"type",
"used",
"in",
"db",
".",
"Returns",
"null",
"if",
"no",
"numerical",
"value",
"found"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureToMeasureDto.java#L97-L114
|
16,258
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java
|
RegisterQualityProfiles.ensureBuiltInDefaultQPContainsRules
|
private void ensureBuiltInDefaultQPContainsRules(DbSession dbSession) {
Map<String, RulesProfileDto> rulesProfilesByLanguage = dbClient.qualityProfileDao().selectBuiltInRuleProfilesWithActiveRules(dbSession).stream()
.collect(toMap(RulesProfileDto::getLanguage, Function.identity(), (oldValue, newValue) -> oldValue));
dbClient.qualityProfileDao().selectDefaultBuiltInProfilesWithoutActiveRules(dbSession, rulesProfilesByLanguage.keySet())
.forEach(qp -> {
RulesProfileDto rulesProfile = rulesProfilesByLanguage.get(qp.getLanguage());
if (rulesProfile == null) {
return;
}
QProfileDto qualityProfile = dbClient.qualityProfileDao().selectByRuleProfileUuid(dbSession, qp.getOrganizationUuid(), rulesProfile.getKee());
if (qualityProfile == null) {
return;
}
Set<String> uuids = dbClient.defaultQProfileDao().selectExistingQProfileUuids(dbSession, qp.getOrganizationUuid(), Collections.singleton(qp.getKee()));
dbClient.defaultQProfileDao().deleteByQProfileUuids(dbSession, uuids);
dbClient.defaultQProfileDao().insertOrUpdate(dbSession, new DefaultQProfileDto()
.setQProfileUuid(qualityProfile.getKee())
.setLanguage(qp.getLanguage())
.setOrganizationUuid(qp.getOrganizationUuid())
);
LOGGER.info("Default built-in quality profile for language [{}] has been updated from [{}] to [{}] since previous default does not have active rules.",
qp.getLanguage(),
qp.getName(),
rulesProfile.getName());
});
dbSession.commit();
}
|
java
|
private void ensureBuiltInDefaultQPContainsRules(DbSession dbSession) {
Map<String, RulesProfileDto> rulesProfilesByLanguage = dbClient.qualityProfileDao().selectBuiltInRuleProfilesWithActiveRules(dbSession).stream()
.collect(toMap(RulesProfileDto::getLanguage, Function.identity(), (oldValue, newValue) -> oldValue));
dbClient.qualityProfileDao().selectDefaultBuiltInProfilesWithoutActiveRules(dbSession, rulesProfilesByLanguage.keySet())
.forEach(qp -> {
RulesProfileDto rulesProfile = rulesProfilesByLanguage.get(qp.getLanguage());
if (rulesProfile == null) {
return;
}
QProfileDto qualityProfile = dbClient.qualityProfileDao().selectByRuleProfileUuid(dbSession, qp.getOrganizationUuid(), rulesProfile.getKee());
if (qualityProfile == null) {
return;
}
Set<String> uuids = dbClient.defaultQProfileDao().selectExistingQProfileUuids(dbSession, qp.getOrganizationUuid(), Collections.singleton(qp.getKee()));
dbClient.defaultQProfileDao().deleteByQProfileUuids(dbSession, uuids);
dbClient.defaultQProfileDao().insertOrUpdate(dbSession, new DefaultQProfileDto()
.setQProfileUuid(qualityProfile.getKee())
.setLanguage(qp.getLanguage())
.setOrganizationUuid(qp.getOrganizationUuid())
);
LOGGER.info("Default built-in quality profile for language [{}] has been updated from [{}] to [{}] since previous default does not have active rules.",
qp.getLanguage(),
qp.getName(),
rulesProfile.getName());
});
dbSession.commit();
}
|
[
"private",
"void",
"ensureBuiltInDefaultQPContainsRules",
"(",
"DbSession",
"dbSession",
")",
"{",
"Map",
"<",
"String",
",",
"RulesProfileDto",
">",
"rulesProfilesByLanguage",
"=",
"dbClient",
".",
"qualityProfileDao",
"(",
")",
".",
"selectBuiltInRuleProfilesWithActiveRules",
"(",
"dbSession",
")",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"toMap",
"(",
"RulesProfileDto",
"::",
"getLanguage",
",",
"Function",
".",
"identity",
"(",
")",
",",
"(",
"oldValue",
",",
"newValue",
")",
"->",
"oldValue",
")",
")",
";",
"dbClient",
".",
"qualityProfileDao",
"(",
")",
".",
"selectDefaultBuiltInProfilesWithoutActiveRules",
"(",
"dbSession",
",",
"rulesProfilesByLanguage",
".",
"keySet",
"(",
")",
")",
".",
"forEach",
"(",
"qp",
"->",
"{",
"RulesProfileDto",
"rulesProfile",
"=",
"rulesProfilesByLanguage",
".",
"get",
"(",
"qp",
".",
"getLanguage",
"(",
")",
")",
";",
"if",
"(",
"rulesProfile",
"==",
"null",
")",
"{",
"return",
";",
"}",
"QProfileDto",
"qualityProfile",
"=",
"dbClient",
".",
"qualityProfileDao",
"(",
")",
".",
"selectByRuleProfileUuid",
"(",
"dbSession",
",",
"qp",
".",
"getOrganizationUuid",
"(",
")",
",",
"rulesProfile",
".",
"getKee",
"(",
")",
")",
";",
"if",
"(",
"qualityProfile",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Set",
"<",
"String",
">",
"uuids",
"=",
"dbClient",
".",
"defaultQProfileDao",
"(",
")",
".",
"selectExistingQProfileUuids",
"(",
"dbSession",
",",
"qp",
".",
"getOrganizationUuid",
"(",
")",
",",
"Collections",
".",
"singleton",
"(",
"qp",
".",
"getKee",
"(",
")",
")",
")",
";",
"dbClient",
".",
"defaultQProfileDao",
"(",
")",
".",
"deleteByQProfileUuids",
"(",
"dbSession",
",",
"uuids",
")",
";",
"dbClient",
".",
"defaultQProfileDao",
"(",
")",
".",
"insertOrUpdate",
"(",
"dbSession",
",",
"new",
"DefaultQProfileDto",
"(",
")",
".",
"setQProfileUuid",
"(",
"qualityProfile",
".",
"getKee",
"(",
")",
")",
".",
"setLanguage",
"(",
"qp",
".",
"getLanguage",
"(",
")",
")",
".",
"setOrganizationUuid",
"(",
"qp",
".",
"getOrganizationUuid",
"(",
")",
")",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Default built-in quality profile for language [{}] has been updated from [{}] to [{}] since previous default does not have active rules.\"",
",",
"qp",
".",
"getLanguage",
"(",
")",
",",
"qp",
".",
"getName",
"(",
")",
",",
"rulesProfile",
".",
"getName",
"(",
")",
")",
";",
"}",
")",
";",
"dbSession",
".",
"commit",
"(",
")",
";",
"}"
] |
This method ensure that if a default built-in quality profile does not have any active rules but another built-in one for the same language
does have active rules, the last one will be the default one.
@see <a href="https://jira.sonarsource.com/browse/SONAR-10363">SONAR-10363</a>
|
[
"This",
"method",
"ensure",
"that",
"if",
"a",
"default",
"built",
"-",
"in",
"quality",
"profile",
"does",
"not",
"have",
"any",
"active",
"rules",
"but",
"another",
"built",
"-",
"in",
"one",
"for",
"the",
"same",
"language",
"does",
"have",
"active",
"rules",
"the",
"last",
"one",
"will",
"be",
"the",
"default",
"one",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java#L155-L186
|
16,259
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/badge/ws/ETagUtils.java
|
ETagUtils.hash
|
private static long hash(byte[] input) {
long hash = FNV1_INIT;
for (byte b : input) {
hash ^= b & 0xff;
hash *= FNV1_PRIME;
}
return hash;
}
|
java
|
private static long hash(byte[] input) {
long hash = FNV1_INIT;
for (byte b : input) {
hash ^= b & 0xff;
hash *= FNV1_PRIME;
}
return hash;
}
|
[
"private",
"static",
"long",
"hash",
"(",
"byte",
"[",
"]",
"input",
")",
"{",
"long",
"hash",
"=",
"FNV1_INIT",
";",
"for",
"(",
"byte",
"b",
":",
"input",
")",
"{",
"hash",
"^=",
"b",
"&",
"0xff",
";",
"hash",
"*=",
"FNV1_PRIME",
";",
"}",
"return",
"hash",
";",
"}"
] |
hash method of a String independant of the JVM
FNV-1a hash method @see <a href="https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash"></a>
|
[
"hash",
"method",
"of",
"a",
"String",
"independant",
"of",
"the",
"JVM",
"FNV",
"-",
"1a",
"hash",
"method"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ETagUtils.java#L39-L46
|
16,260
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
|
IssueDto.toDtoForServerInsert
|
public static IssueDto toDtoForServerInsert(DefaultIssue issue, ComponentDto component, ComponentDto project, int ruleId, long now) {
return toDtoForComputationInsert(issue, ruleId, now)
.setComponent(component)
.setProject(project);
}
|
java
|
public static IssueDto toDtoForServerInsert(DefaultIssue issue, ComponentDto component, ComponentDto project, int ruleId, long now) {
return toDtoForComputationInsert(issue, ruleId, now)
.setComponent(component)
.setProject(project);
}
|
[
"public",
"static",
"IssueDto",
"toDtoForServerInsert",
"(",
"DefaultIssue",
"issue",
",",
"ComponentDto",
"component",
",",
"ComponentDto",
"project",
",",
"int",
"ruleId",
",",
"long",
"now",
")",
"{",
"return",
"toDtoForComputationInsert",
"(",
"issue",
",",
"ruleId",
",",
"now",
")",
".",
"setComponent",
"(",
"component",
")",
".",
"setProject",
"(",
"project",
")",
";",
"}"
] |
On server side, we need component keys and uuid
|
[
"On",
"server",
"side",
"we",
"need",
"component",
"keys",
"and",
"uuid"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java#L148-L152
|
16,261
|
SonarSource/sonarqube
|
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImpl.java
|
CeProcessingSchedulerImpl.stopScheduling
|
@Override
public void stopScheduling() {
LOG.debug("Stopping compute engine");
// Requesting all workers to stop
for (ChainingCallback chainingCallback : chainingCallbacks) {
chainingCallback.stop(false);
}
// Workers have 40s to gracefully stop processing tasks
long until = System.currentTimeMillis() + gracefulStopTimeoutInMs;
LOG.info("Waiting for workers to finish in-progress tasks");
while (System.currentTimeMillis() < until && ceWorkerController.hasAtLeastOneProcessingWorker()) {
try {
Thread.sleep(200L);
} catch (InterruptedException e) {
LOG.debug("Graceful stop period has been interrupted: {}", e);
Thread.currentThread().interrupt();
break;
}
}
if (ceWorkerController.hasAtLeastOneProcessingWorker()) {
LOG.info("Some in-progress tasks did not finish in due time. Tasks will be stopped.");
}
// Interrupting the tasks
for (ChainingCallback chainingCallback : chainingCallbacks) {
chainingCallback.stop(true);
}
}
|
java
|
@Override
public void stopScheduling() {
LOG.debug("Stopping compute engine");
// Requesting all workers to stop
for (ChainingCallback chainingCallback : chainingCallbacks) {
chainingCallback.stop(false);
}
// Workers have 40s to gracefully stop processing tasks
long until = System.currentTimeMillis() + gracefulStopTimeoutInMs;
LOG.info("Waiting for workers to finish in-progress tasks");
while (System.currentTimeMillis() < until && ceWorkerController.hasAtLeastOneProcessingWorker()) {
try {
Thread.sleep(200L);
} catch (InterruptedException e) {
LOG.debug("Graceful stop period has been interrupted: {}", e);
Thread.currentThread().interrupt();
break;
}
}
if (ceWorkerController.hasAtLeastOneProcessingWorker()) {
LOG.info("Some in-progress tasks did not finish in due time. Tasks will be stopped.");
}
// Interrupting the tasks
for (ChainingCallback chainingCallback : chainingCallbacks) {
chainingCallback.stop(true);
}
}
|
[
"@",
"Override",
"public",
"void",
"stopScheduling",
"(",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Stopping compute engine\"",
")",
";",
"// Requesting all workers to stop",
"for",
"(",
"ChainingCallback",
"chainingCallback",
":",
"chainingCallbacks",
")",
"{",
"chainingCallback",
".",
"stop",
"(",
"false",
")",
";",
"}",
"// Workers have 40s to gracefully stop processing tasks",
"long",
"until",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"gracefulStopTimeoutInMs",
";",
"LOG",
".",
"info",
"(",
"\"Waiting for workers to finish in-progress tasks\"",
")",
";",
"while",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"<",
"until",
"&&",
"ceWorkerController",
".",
"hasAtLeastOneProcessingWorker",
"(",
")",
")",
"{",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"200L",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Graceful stop period has been interrupted: {}\"",
",",
"e",
")",
";",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"ceWorkerController",
".",
"hasAtLeastOneProcessingWorker",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Some in-progress tasks did not finish in due time. Tasks will be stopped.\"",
")",
";",
"}",
"// Interrupting the tasks",
"for",
"(",
"ChainingCallback",
"chainingCallback",
":",
"chainingCallbacks",
")",
"{",
"chainingCallback",
".",
"stop",
"(",
"true",
")",
";",
"}",
"}"
] |
This method is stopping all the workers giving them a delay before killing them.
|
[
"This",
"method",
"is",
"stopping",
"all",
"the",
"workers",
"giving",
"them",
"a",
"delay",
"before",
"killing",
"them",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImpl.java#L76-L105
|
16,262
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
|
RulesDefinitionXmlLoader.load
|
public void load(RulesDefinition.NewRepository repo, InputStream input, String encoding) {
load(repo, input, Charset.forName(encoding));
}
|
java
|
public void load(RulesDefinition.NewRepository repo, InputStream input, String encoding) {
load(repo, input, Charset.forName(encoding));
}
|
[
"public",
"void",
"load",
"(",
"RulesDefinition",
".",
"NewRepository",
"repo",
",",
"InputStream",
"input",
",",
"String",
"encoding",
")",
"{",
"load",
"(",
"repo",
",",
"input",
",",
"Charset",
".",
"forName",
"(",
"encoding",
")",
")",
";",
"}"
] |
Loads rules by reading the XML input stream. The input stream is not always closed by the method, so it
should be handled by the caller.
@since 4.3
|
[
"Loads",
"rules",
"by",
"reading",
"the",
"XML",
"input",
"stream",
".",
"The",
"input",
"stream",
"is",
"not",
"always",
"closed",
"by",
"the",
"method",
"so",
"it",
"should",
"be",
"handled",
"by",
"the",
"caller",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java#L196-L198
|
16,263
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
|
RulesDefinitionXmlLoader.load
|
public void load(RulesDefinition.NewRepository repo, Reader reader) {
XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
// just so it won't try to load DTD in if there's DOCTYPE
xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
SMInputFactory inputFactory = new SMInputFactory(xmlFactory);
try {
SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
rootC.advance(); // <rules>
SMInputCursor rulesC = rootC.childElementCursor("rule");
while (rulesC.getNext() != null) {
// <rule>
processRule(repo, rulesC);
}
} catch (XMLStreamException e) {
throw new IllegalStateException("XML is not valid", e);
}
}
|
java
|
public void load(RulesDefinition.NewRepository repo, Reader reader) {
XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
// just so it won't try to load DTD in if there's DOCTYPE
xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
SMInputFactory inputFactory = new SMInputFactory(xmlFactory);
try {
SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
rootC.advance(); // <rules>
SMInputCursor rulesC = rootC.childElementCursor("rule");
while (rulesC.getNext() != null) {
// <rule>
processRule(repo, rulesC);
}
} catch (XMLStreamException e) {
throw new IllegalStateException("XML is not valid", e);
}
}
|
[
"public",
"void",
"load",
"(",
"RulesDefinition",
".",
"NewRepository",
"repo",
",",
"Reader",
"reader",
")",
"{",
"XMLInputFactory",
"xmlFactory",
"=",
"XMLInputFactory",
".",
"newInstance",
"(",
")",
";",
"xmlFactory",
".",
"setProperty",
"(",
"XMLInputFactory",
".",
"IS_COALESCING",
",",
"Boolean",
".",
"TRUE",
")",
";",
"xmlFactory",
".",
"setProperty",
"(",
"XMLInputFactory",
".",
"IS_NAMESPACE_AWARE",
",",
"Boolean",
".",
"FALSE",
")",
";",
"// just so it won't try to load DTD in if there's DOCTYPE",
"xmlFactory",
".",
"setProperty",
"(",
"XMLInputFactory",
".",
"SUPPORT_DTD",
",",
"Boolean",
".",
"FALSE",
")",
";",
"xmlFactory",
".",
"setProperty",
"(",
"XMLInputFactory",
".",
"IS_VALIDATING",
",",
"Boolean",
".",
"FALSE",
")",
";",
"SMInputFactory",
"inputFactory",
"=",
"new",
"SMInputFactory",
"(",
"xmlFactory",
")",
";",
"try",
"{",
"SMHierarchicCursor",
"rootC",
"=",
"inputFactory",
".",
"rootElementCursor",
"(",
"reader",
")",
";",
"rootC",
".",
"advance",
"(",
")",
";",
"// <rules>",
"SMInputCursor",
"rulesC",
"=",
"rootC",
".",
"childElementCursor",
"(",
"\"rule\"",
")",
";",
"while",
"(",
"rulesC",
".",
"getNext",
"(",
")",
"!=",
"null",
")",
"{",
"// <rule>",
"processRule",
"(",
"repo",
",",
"rulesC",
")",
";",
"}",
"}",
"catch",
"(",
"XMLStreamException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"XML is not valid\"",
",",
"e",
")",
";",
"}",
"}"
] |
Loads rules by reading the XML input stream. The reader is not closed by the method, so it
should be handled by the caller.
@since 4.3
|
[
"Loads",
"rules",
"by",
"reading",
"the",
"XML",
"input",
"stream",
".",
"The",
"reader",
"is",
"not",
"closed",
"by",
"the",
"method",
"so",
"it",
"should",
"be",
"handled",
"by",
"the",
"caller",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java#L216-L237
|
16,264
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/internal/SonarRuntimeImpl.java
|
SonarRuntimeImpl.forSonarQube
|
public static SonarRuntime forSonarQube(Version version, SonarQubeSide side) {
return new SonarRuntimeImpl(version, SonarProduct.SONARQUBE, side);
}
|
java
|
public static SonarRuntime forSonarQube(Version version, SonarQubeSide side) {
return new SonarRuntimeImpl(version, SonarProduct.SONARQUBE, side);
}
|
[
"public",
"static",
"SonarRuntime",
"forSonarQube",
"(",
"Version",
"version",
",",
"SonarQubeSide",
"side",
")",
"{",
"return",
"new",
"SonarRuntimeImpl",
"(",
"version",
",",
"SonarProduct",
".",
"SONARQUBE",
",",
"side",
")",
";",
"}"
] |
Create an instance for SonarQube runtime environment.
|
[
"Create",
"an",
"instance",
"for",
"SonarQube",
"runtime",
"environment",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/internal/SonarRuntimeImpl.java#L71-L73
|
16,265
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
|
RulesProfile.getActiveRulesByRepository
|
public List<ActiveRule> getActiveRulesByRepository(String repositoryKey) {
List<ActiveRule> result = new ArrayList<>();
for (ActiveRule activeRule : activeRules) {
if (repositoryKey.equals(activeRule.getRepositoryKey()) && activeRule.isEnabled()) {
result.add(activeRule);
}
}
return result;
}
|
java
|
public List<ActiveRule> getActiveRulesByRepository(String repositoryKey) {
List<ActiveRule> result = new ArrayList<>();
for (ActiveRule activeRule : activeRules) {
if (repositoryKey.equals(activeRule.getRepositoryKey()) && activeRule.isEnabled()) {
result.add(activeRule);
}
}
return result;
}
|
[
"public",
"List",
"<",
"ActiveRule",
">",
"getActiveRulesByRepository",
"(",
"String",
"repositoryKey",
")",
"{",
"List",
"<",
"ActiveRule",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"ActiveRule",
"activeRule",
":",
"activeRules",
")",
"{",
"if",
"(",
"repositoryKey",
".",
"equals",
"(",
"activeRule",
".",
"getRepositoryKey",
"(",
")",
")",
"&&",
"activeRule",
".",
"isEnabled",
"(",
")",
")",
"{",
"result",
".",
"add",
"(",
"activeRule",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Get the active rules of a specific repository.
Only enabled rules are selected. Disabled rules are excluded.
|
[
"Get",
"the",
"active",
"rules",
"of",
"a",
"specific",
"repository",
".",
"Only",
"enabled",
"rules",
"are",
"selected",
".",
"Disabled",
"rules",
"are",
"excluded",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java#L256-L264
|
16,266
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java
|
IssueLifecycle.copyComment
|
private static DefaultIssueComment copyComment(String issueKey, DefaultIssueComment c) {
DefaultIssueComment comment = new DefaultIssueComment();
comment.setIssueKey(issueKey);
comment.setKey(Uuids.create());
comment.setUserUuid(c.userUuid());
comment.setMarkdownText(c.markdownText());
comment.setCreatedAt(c.createdAt()).setUpdatedAt(c.updatedAt());
comment.setNew(true);
return comment;
}
|
java
|
private static DefaultIssueComment copyComment(String issueKey, DefaultIssueComment c) {
DefaultIssueComment comment = new DefaultIssueComment();
comment.setIssueKey(issueKey);
comment.setKey(Uuids.create());
comment.setUserUuid(c.userUuid());
comment.setMarkdownText(c.markdownText());
comment.setCreatedAt(c.createdAt()).setUpdatedAt(c.updatedAt());
comment.setNew(true);
return comment;
}
|
[
"private",
"static",
"DefaultIssueComment",
"copyComment",
"(",
"String",
"issueKey",
",",
"DefaultIssueComment",
"c",
")",
"{",
"DefaultIssueComment",
"comment",
"=",
"new",
"DefaultIssueComment",
"(",
")",
";",
"comment",
".",
"setIssueKey",
"(",
"issueKey",
")",
";",
"comment",
".",
"setKey",
"(",
"Uuids",
".",
"create",
"(",
")",
")",
";",
"comment",
".",
"setUserUuid",
"(",
"c",
".",
"userUuid",
"(",
")",
")",
";",
"comment",
".",
"setMarkdownText",
"(",
"c",
".",
"markdownText",
"(",
")",
")",
";",
"comment",
".",
"setCreatedAt",
"(",
"c",
".",
"createdAt",
"(",
")",
")",
".",
"setUpdatedAt",
"(",
"c",
".",
"updatedAt",
"(",
")",
")",
";",
"comment",
".",
"setNew",
"(",
"true",
")",
";",
"return",
"comment",
";",
"}"
] |
Copy a comment from another issue
|
[
"Copy",
"a",
"comment",
"from",
"another",
"issue"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java#L121-L130
|
16,267
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java
|
IssueLifecycle.copyFieldDiffOfIssueFromOtherBranch
|
private static Optional<FieldDiffs> copyFieldDiffOfIssueFromOtherBranch(String issueKey, FieldDiffs c) {
FieldDiffs result = new FieldDiffs();
result.setIssueKey(issueKey);
result.setUserUuid(c.userUuid());
result.setCreationDate(c.creationDate());
// Don't copy "file" changelogs as they refer to file uuids that might later be purged
c.diffs().entrySet().stream().filter(e -> !e.getKey().equals(IssueFieldsSetter.FILE))
.forEach(e -> result.setDiff(e.getKey(), e.getValue().oldValue(), e.getValue().newValue()));
if (result.diffs().isEmpty()) {
return Optional.empty();
}
return Optional.of(result);
}
|
java
|
private static Optional<FieldDiffs> copyFieldDiffOfIssueFromOtherBranch(String issueKey, FieldDiffs c) {
FieldDiffs result = new FieldDiffs();
result.setIssueKey(issueKey);
result.setUserUuid(c.userUuid());
result.setCreationDate(c.creationDate());
// Don't copy "file" changelogs as they refer to file uuids that might later be purged
c.diffs().entrySet().stream().filter(e -> !e.getKey().equals(IssueFieldsSetter.FILE))
.forEach(e -> result.setDiff(e.getKey(), e.getValue().oldValue(), e.getValue().newValue()));
if (result.diffs().isEmpty()) {
return Optional.empty();
}
return Optional.of(result);
}
|
[
"private",
"static",
"Optional",
"<",
"FieldDiffs",
">",
"copyFieldDiffOfIssueFromOtherBranch",
"(",
"String",
"issueKey",
",",
"FieldDiffs",
"c",
")",
"{",
"FieldDiffs",
"result",
"=",
"new",
"FieldDiffs",
"(",
")",
";",
"result",
".",
"setIssueKey",
"(",
"issueKey",
")",
";",
"result",
".",
"setUserUuid",
"(",
"c",
".",
"userUuid",
"(",
")",
")",
";",
"result",
".",
"setCreationDate",
"(",
"c",
".",
"creationDate",
"(",
")",
")",
";",
"// Don't copy \"file\" changelogs as they refer to file uuids that might later be purged",
"c",
".",
"diffs",
"(",
")",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"e",
"->",
"!",
"e",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"IssueFieldsSetter",
".",
"FILE",
")",
")",
".",
"forEach",
"(",
"e",
"->",
"result",
".",
"setDiff",
"(",
"e",
".",
"getKey",
"(",
")",
",",
"e",
".",
"getValue",
"(",
")",
".",
"oldValue",
"(",
")",
",",
"e",
".",
"getValue",
"(",
")",
".",
"newValue",
"(",
")",
")",
")",
";",
"if",
"(",
"result",
".",
"diffs",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
"return",
"Optional",
".",
"of",
"(",
"result",
")",
";",
"}"
] |
Copy a diff from another issue
|
[
"Copy",
"a",
"diff",
"from",
"another",
"issue"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java#L135-L147
|
16,268
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/issue/tracking/Tracking.java
|
Tracking.getUnmatchedBases
|
public Stream<BASE> getUnmatchedBases() {
return bases.stream().filter(base -> !baseToRaw.containsKey(base));
}
|
java
|
public Stream<BASE> getUnmatchedBases() {
return bases.stream().filter(base -> !baseToRaw.containsKey(base));
}
|
[
"public",
"Stream",
"<",
"BASE",
">",
"getUnmatchedBases",
"(",
")",
"{",
"return",
"bases",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"base",
"->",
"!",
"baseToRaw",
".",
"containsKey",
"(",
"base",
")",
")",
";",
"}"
] |
The base issues that are not matched by a raw issue and that need to be closed.
|
[
"The",
"base",
"issues",
"that",
"are",
"not",
"matched",
"by",
"a",
"raw",
"issue",
"and",
"that",
"need",
"to",
"be",
"closed",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/issue/tracking/Tracking.java#L72-L74
|
16,269
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/organization/MemberUpdater.java
|
MemberUpdater.synchronizeUserOrganizationMembership
|
public void synchronizeUserOrganizationMembership(DbSession dbSession, UserDto user, ALM alm, Set<String> organizationAlmIds) {
Set<String> userOrganizationUuids = dbClient.organizationMemberDao().selectOrganizationUuidsByUser(dbSession, user.getId());
Set<String> userOrganizationUuidsWithMembersSyncEnabled = dbClient.organizationAlmBindingDao().selectByOrganizationUuids(dbSession, userOrganizationUuids).stream()
.filter(OrganizationAlmBindingDto::isMembersSyncEnable)
.map(OrganizationAlmBindingDto::getOrganizationUuid)
.collect(toSet());
Set<String> almOrganizationUuidsWithMembersSyncEnabled = dbClient.organizationAlmBindingDao().selectByOrganizationAlmIds(dbSession, alm, organizationAlmIds).stream()
.filter(OrganizationAlmBindingDto::isMembersSyncEnable)
.map(OrganizationAlmBindingDto::getOrganizationUuid)
.collect(toSet());
Set<String> organizationUuidsToBeAdded = difference(almOrganizationUuidsWithMembersSyncEnabled, userOrganizationUuidsWithMembersSyncEnabled);
Set<String> organizationUuidsToBeRemoved = difference(userOrganizationUuidsWithMembersSyncEnabled, almOrganizationUuidsWithMembersSyncEnabled);
Map<String, OrganizationDto> allOrganizationsByUuid = dbClient.organizationDao().selectByUuids(dbSession, union(organizationUuidsToBeAdded, organizationUuidsToBeRemoved))
.stream()
.collect(uniqueIndex(OrganizationDto::getUuid));
allOrganizationsByUuid.entrySet().stream()
.filter(entry -> organizationUuidsToBeAdded.contains(entry.getKey()))
.forEach(entry -> addMemberInDb(dbSession, entry.getValue(), user));
allOrganizationsByUuid.entrySet().stream()
.filter(entry -> organizationUuidsToBeRemoved.contains(entry.getKey()))
.forEach(entry -> removeMemberInDb(dbSession, entry.getValue(), user));
}
|
java
|
public void synchronizeUserOrganizationMembership(DbSession dbSession, UserDto user, ALM alm, Set<String> organizationAlmIds) {
Set<String> userOrganizationUuids = dbClient.organizationMemberDao().selectOrganizationUuidsByUser(dbSession, user.getId());
Set<String> userOrganizationUuidsWithMembersSyncEnabled = dbClient.organizationAlmBindingDao().selectByOrganizationUuids(dbSession, userOrganizationUuids).stream()
.filter(OrganizationAlmBindingDto::isMembersSyncEnable)
.map(OrganizationAlmBindingDto::getOrganizationUuid)
.collect(toSet());
Set<String> almOrganizationUuidsWithMembersSyncEnabled = dbClient.organizationAlmBindingDao().selectByOrganizationAlmIds(dbSession, alm, organizationAlmIds).stream()
.filter(OrganizationAlmBindingDto::isMembersSyncEnable)
.map(OrganizationAlmBindingDto::getOrganizationUuid)
.collect(toSet());
Set<String> organizationUuidsToBeAdded = difference(almOrganizationUuidsWithMembersSyncEnabled, userOrganizationUuidsWithMembersSyncEnabled);
Set<String> organizationUuidsToBeRemoved = difference(userOrganizationUuidsWithMembersSyncEnabled, almOrganizationUuidsWithMembersSyncEnabled);
Map<String, OrganizationDto> allOrganizationsByUuid = dbClient.organizationDao().selectByUuids(dbSession, union(organizationUuidsToBeAdded, organizationUuidsToBeRemoved))
.stream()
.collect(uniqueIndex(OrganizationDto::getUuid));
allOrganizationsByUuid.entrySet().stream()
.filter(entry -> organizationUuidsToBeAdded.contains(entry.getKey()))
.forEach(entry -> addMemberInDb(dbSession, entry.getValue(), user));
allOrganizationsByUuid.entrySet().stream()
.filter(entry -> organizationUuidsToBeRemoved.contains(entry.getKey()))
.forEach(entry -> removeMemberInDb(dbSession, entry.getValue(), user));
}
|
[
"public",
"void",
"synchronizeUserOrganizationMembership",
"(",
"DbSession",
"dbSession",
",",
"UserDto",
"user",
",",
"ALM",
"alm",
",",
"Set",
"<",
"String",
">",
"organizationAlmIds",
")",
"{",
"Set",
"<",
"String",
">",
"userOrganizationUuids",
"=",
"dbClient",
".",
"organizationMemberDao",
"(",
")",
".",
"selectOrganizationUuidsByUser",
"(",
"dbSession",
",",
"user",
".",
"getId",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"userOrganizationUuidsWithMembersSyncEnabled",
"=",
"dbClient",
".",
"organizationAlmBindingDao",
"(",
")",
".",
"selectByOrganizationUuids",
"(",
"dbSession",
",",
"userOrganizationUuids",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"OrganizationAlmBindingDto",
"::",
"isMembersSyncEnable",
")",
".",
"map",
"(",
"OrganizationAlmBindingDto",
"::",
"getOrganizationUuid",
")",
".",
"collect",
"(",
"toSet",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"almOrganizationUuidsWithMembersSyncEnabled",
"=",
"dbClient",
".",
"organizationAlmBindingDao",
"(",
")",
".",
"selectByOrganizationAlmIds",
"(",
"dbSession",
",",
"alm",
",",
"organizationAlmIds",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"OrganizationAlmBindingDto",
"::",
"isMembersSyncEnable",
")",
".",
"map",
"(",
"OrganizationAlmBindingDto",
"::",
"getOrganizationUuid",
")",
".",
"collect",
"(",
"toSet",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"organizationUuidsToBeAdded",
"=",
"difference",
"(",
"almOrganizationUuidsWithMembersSyncEnabled",
",",
"userOrganizationUuidsWithMembersSyncEnabled",
")",
";",
"Set",
"<",
"String",
">",
"organizationUuidsToBeRemoved",
"=",
"difference",
"(",
"userOrganizationUuidsWithMembersSyncEnabled",
",",
"almOrganizationUuidsWithMembersSyncEnabled",
")",
";",
"Map",
"<",
"String",
",",
"OrganizationDto",
">",
"allOrganizationsByUuid",
"=",
"dbClient",
".",
"organizationDao",
"(",
")",
".",
"selectByUuids",
"(",
"dbSession",
",",
"union",
"(",
"organizationUuidsToBeAdded",
",",
"organizationUuidsToBeRemoved",
")",
")",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"uniqueIndex",
"(",
"OrganizationDto",
"::",
"getUuid",
")",
")",
";",
"allOrganizationsByUuid",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"entry",
"->",
"organizationUuidsToBeAdded",
".",
"contains",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
".",
"forEach",
"(",
"entry",
"->",
"addMemberInDb",
"(",
"dbSession",
",",
"entry",
".",
"getValue",
"(",
")",
",",
"user",
")",
")",
";",
"allOrganizationsByUuid",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"entry",
"->",
"organizationUuidsToBeRemoved",
".",
"contains",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
".",
"forEach",
"(",
"entry",
"->",
"removeMemberInDb",
"(",
"dbSession",
",",
"entry",
".",
"getValue",
"(",
")",
",",
"user",
")",
")",
";",
"}"
] |
Synchronize organization membership of a user from a list of ALM organization specific ids
Please note that no commit will not be executed.
|
[
"Synchronize",
"organization",
"membership",
"of",
"a",
"user",
"from",
"a",
"list",
"of",
"ALM",
"organization",
"specific",
"ids",
"Please",
"note",
"that",
"no",
"commit",
"will",
"not",
"be",
"executed",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/organization/MemberUpdater.java#L110-L133
|
16,270
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueDao.java
|
CeQueueDao.countByStatusAndMainComponentUuids
|
public Map<String, Integer> countByStatusAndMainComponentUuids(DbSession dbSession, CeQueueDto.Status status, Set<String> projectUuids) {
if (projectUuids.isEmpty()) {
return emptyMap();
}
ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
executeLargeUpdates(
projectUuids,
partitionOfProjectUuids -> {
List<QueueCount> i = mapper(dbSession).countByStatusAndMainComponentUuids(status, partitionOfProjectUuids);
i.forEach(o -> builder.put(o.getMainComponentUuid(), o.getTotal()));
});
return builder.build();
}
|
java
|
public Map<String, Integer> countByStatusAndMainComponentUuids(DbSession dbSession, CeQueueDto.Status status, Set<String> projectUuids) {
if (projectUuids.isEmpty()) {
return emptyMap();
}
ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
executeLargeUpdates(
projectUuids,
partitionOfProjectUuids -> {
List<QueueCount> i = mapper(dbSession).countByStatusAndMainComponentUuids(status, partitionOfProjectUuids);
i.forEach(o -> builder.put(o.getMainComponentUuid(), o.getTotal()));
});
return builder.build();
}
|
[
"public",
"Map",
"<",
"String",
",",
"Integer",
">",
"countByStatusAndMainComponentUuids",
"(",
"DbSession",
"dbSession",
",",
"CeQueueDto",
".",
"Status",
"status",
",",
"Set",
"<",
"String",
">",
"projectUuids",
")",
"{",
"if",
"(",
"projectUuids",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"emptyMap",
"(",
")",
";",
"}",
"ImmutableMap",
".",
"Builder",
"<",
"String",
",",
"Integer",
">",
"builder",
"=",
"ImmutableMap",
".",
"builder",
"(",
")",
";",
"executeLargeUpdates",
"(",
"projectUuids",
",",
"partitionOfProjectUuids",
"->",
"{",
"List",
"<",
"QueueCount",
">",
"i",
"=",
"mapper",
"(",
"dbSession",
")",
".",
"countByStatusAndMainComponentUuids",
"(",
"status",
",",
"partitionOfProjectUuids",
")",
";",
"i",
".",
"forEach",
"(",
"o",
"->",
"builder",
".",
"put",
"(",
"o",
".",
"getMainComponentUuid",
"(",
")",
",",
"o",
".",
"getTotal",
"(",
")",
")",
")",
";",
"}",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] |
Counts entries in the queue with the specified status for each specified main component uuid.
The returned map doesn't contain any entry for main component uuids for which there is no entry in the queue (ie.
all entries have a value >= 0).
|
[
"Counts",
"entries",
"in",
"the",
"queue",
"with",
"the",
"specified",
"status",
"for",
"each",
"specified",
"main",
"component",
"uuid",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueDao.java#L151-L164
|
16,271
|
SonarSource/sonarqube
|
sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
|
ScannerReportWriter.writeMetadata
|
public File writeMetadata(ScannerReport.Metadata metadata) {
Protobuf.write(metadata, fileStructure.metadataFile());
return fileStructure.metadataFile();
}
|
java
|
public File writeMetadata(ScannerReport.Metadata metadata) {
Protobuf.write(metadata, fileStructure.metadataFile());
return fileStructure.metadataFile();
}
|
[
"public",
"File",
"writeMetadata",
"(",
"ScannerReport",
".",
"Metadata",
"metadata",
")",
"{",
"Protobuf",
".",
"write",
"(",
"metadata",
",",
"fileStructure",
".",
"metadataFile",
"(",
")",
")",
";",
"return",
"fileStructure",
".",
"metadataFile",
"(",
")",
";",
"}"
] |
Metadata is mandatory
|
[
"Metadata",
"is",
"mandatory"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java#L54-L57
|
16,272
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java
|
AuthorizationDao.selectOrganizationPermissions
|
public Set<String> selectOrganizationPermissions(DbSession dbSession, String organizationUuid, int userId) {
return mapper(dbSession).selectOrganizationPermissions(organizationUuid, userId);
}
|
java
|
public Set<String> selectOrganizationPermissions(DbSession dbSession, String organizationUuid, int userId) {
return mapper(dbSession).selectOrganizationPermissions(organizationUuid, userId);
}
|
[
"public",
"Set",
"<",
"String",
">",
"selectOrganizationPermissions",
"(",
"DbSession",
"dbSession",
",",
"String",
"organizationUuid",
",",
"int",
"userId",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectOrganizationPermissions",
"(",
"organizationUuid",
",",
"userId",
")",
";",
"}"
] |
Loads all the permissions granted to user for the specified organization
|
[
"Loads",
"all",
"the",
"permissions",
"granted",
"to",
"user",
"for",
"the",
"specified",
"organization"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java#L47-L49
|
16,273
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java
|
AuthorizationDao.selectOrganizationPermissionsOfAnonymous
|
public Set<String> selectOrganizationPermissionsOfAnonymous(DbSession dbSession, String organizationUuid) {
return mapper(dbSession).selectOrganizationPermissionsOfAnonymous(organizationUuid);
}
|
java
|
public Set<String> selectOrganizationPermissionsOfAnonymous(DbSession dbSession, String organizationUuid) {
return mapper(dbSession).selectOrganizationPermissionsOfAnonymous(organizationUuid);
}
|
[
"public",
"Set",
"<",
"String",
">",
"selectOrganizationPermissionsOfAnonymous",
"(",
"DbSession",
"dbSession",
",",
"String",
"organizationUuid",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectOrganizationPermissionsOfAnonymous",
"(",
"organizationUuid",
")",
";",
"}"
] |
Loads all the permissions granted to anonymous user for the specified organization
|
[
"Loads",
"all",
"the",
"permissions",
"granted",
"to",
"anonymous",
"user",
"for",
"the",
"specified",
"organization"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java#L54-L56
|
16,274
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java
|
AuthorizationDao.selectUserIdsWithGlobalPermission
|
public List<Integer> selectUserIdsWithGlobalPermission(DbSession dbSession, String organizationUuid, String permission) {
return mapper(dbSession).selectUserIdsWithGlobalPermission(organizationUuid, permission);
}
|
java
|
public List<Integer> selectUserIdsWithGlobalPermission(DbSession dbSession, String organizationUuid, String permission) {
return mapper(dbSession).selectUserIdsWithGlobalPermission(organizationUuid, permission);
}
|
[
"public",
"List",
"<",
"Integer",
">",
"selectUserIdsWithGlobalPermission",
"(",
"DbSession",
"dbSession",
",",
"String",
"organizationUuid",
",",
"String",
"permission",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectUserIdsWithGlobalPermission",
"(",
"organizationUuid",
",",
"permission",
")",
";",
"}"
] |
The list of users who have the global permission.
The anyone virtual group is not taken into account.
|
[
"The",
"list",
"of",
"users",
"who",
"have",
"the",
"global",
"permission",
".",
"The",
"anyone",
"virtual",
"group",
"is",
"not",
"taken",
"into",
"account",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java#L102-L104
|
16,275
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java
|
AuthorizationDao.keepAuthorizedUsersForRoleAndProject
|
public Collection<Integer> keepAuthorizedUsersForRoleAndProject(DbSession dbSession, Collection<Integer> userIds, String role, long projectId) {
return executeLargeInputs(
userIds,
partitionOfIds -> mapper(dbSession).keepAuthorizedUsersForRoleAndProject(role, projectId, partitionOfIds),
partitionSize -> partitionSize / 3);
}
|
java
|
public Collection<Integer> keepAuthorizedUsersForRoleAndProject(DbSession dbSession, Collection<Integer> userIds, String role, long projectId) {
return executeLargeInputs(
userIds,
partitionOfIds -> mapper(dbSession).keepAuthorizedUsersForRoleAndProject(role, projectId, partitionOfIds),
partitionSize -> partitionSize / 3);
}
|
[
"public",
"Collection",
"<",
"Integer",
">",
"keepAuthorizedUsersForRoleAndProject",
"(",
"DbSession",
"dbSession",
",",
"Collection",
"<",
"Integer",
">",
"userIds",
",",
"String",
"role",
",",
"long",
"projectId",
")",
"{",
"return",
"executeLargeInputs",
"(",
"userIds",
",",
"partitionOfIds",
"->",
"mapper",
"(",
"dbSession",
")",
".",
"keepAuthorizedUsersForRoleAndProject",
"(",
"role",
",",
"projectId",
",",
"partitionOfIds",
")",
",",
"partitionSize",
"->",
"partitionSize",
"/",
"3",
")",
";",
"}"
] |
Keep only authorized user that have the given permission on a given project.
Please Note that if the permission is 'Anyone' is NOT taking into account by this method.
|
[
"Keep",
"only",
"authorized",
"user",
"that",
"have",
"the",
"given",
"permission",
"on",
"a",
"given",
"project",
".",
"Please",
"Note",
"that",
"if",
"the",
"permission",
"is",
"Anyone",
"is",
"NOT",
"taking",
"into",
"account",
"by",
"this",
"method",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java#L171-L176
|
16,276
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java
|
AuthorizationDao.selectGlobalAdministerEmailSubscribers
|
public Set<EmailSubscriberDto> selectGlobalAdministerEmailSubscribers(DbSession dbSession) {
return mapper(dbSession).selectEmailSubscribersWithGlobalPermission(ADMINISTER.getKey());
}
|
java
|
public Set<EmailSubscriberDto> selectGlobalAdministerEmailSubscribers(DbSession dbSession) {
return mapper(dbSession).selectEmailSubscribersWithGlobalPermission(ADMINISTER.getKey());
}
|
[
"public",
"Set",
"<",
"EmailSubscriberDto",
">",
"selectGlobalAdministerEmailSubscribers",
"(",
"DbSession",
"dbSession",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectEmailSubscribersWithGlobalPermission",
"(",
"ADMINISTER",
".",
"getKey",
"(",
")",
")",
";",
"}"
] |
Used by license notifications
|
[
"Used",
"by",
"license",
"notifications"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java#L185-L187
|
16,277
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/log/ServerProcessLogging.java
|
ServerProcessLogging.configureDirectToConsoleLoggers
|
private void configureDirectToConsoleLoggers(LoggerContext context, String... loggerNames) {
RootLoggerConfig config = newRootLoggerConfigBuilder()
.setProcessId(ProcessId.APP)
.setThreadIdFieldPattern("")
.build();
String logPattern = helper.buildLogPattern(config);
ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(context, "CONSOLE", logPattern);
for (String loggerName : loggerNames) {
Logger consoleLogger = context.getLogger(loggerName);
consoleLogger.setAdditive(false);
consoleLogger.addAppender(consoleAppender);
}
}
|
java
|
private void configureDirectToConsoleLoggers(LoggerContext context, String... loggerNames) {
RootLoggerConfig config = newRootLoggerConfigBuilder()
.setProcessId(ProcessId.APP)
.setThreadIdFieldPattern("")
.build();
String logPattern = helper.buildLogPattern(config);
ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(context, "CONSOLE", logPattern);
for (String loggerName : loggerNames) {
Logger consoleLogger = context.getLogger(loggerName);
consoleLogger.setAdditive(false);
consoleLogger.addAppender(consoleAppender);
}
}
|
[
"private",
"void",
"configureDirectToConsoleLoggers",
"(",
"LoggerContext",
"context",
",",
"String",
"...",
"loggerNames",
")",
"{",
"RootLoggerConfig",
"config",
"=",
"newRootLoggerConfigBuilder",
"(",
")",
".",
"setProcessId",
"(",
"ProcessId",
".",
"APP",
")",
".",
"setThreadIdFieldPattern",
"(",
"\"\"",
")",
".",
"build",
"(",
")",
";",
"String",
"logPattern",
"=",
"helper",
".",
"buildLogPattern",
"(",
"config",
")",
";",
"ConsoleAppender",
"<",
"ILoggingEvent",
">",
"consoleAppender",
"=",
"helper",
".",
"newConsoleAppender",
"(",
"context",
",",
"\"CONSOLE\"",
",",
"logPattern",
")",
";",
"for",
"(",
"String",
"loggerName",
":",
"loggerNames",
")",
"{",
"Logger",
"consoleLogger",
"=",
"context",
".",
"getLogger",
"(",
"loggerName",
")",
";",
"consoleLogger",
".",
"setAdditive",
"(",
"false",
")",
";",
"consoleLogger",
".",
"addAppender",
"(",
"consoleAppender",
")",
";",
"}",
"}"
] |
Setup one or more specified loggers to be non additive and to print to System.out which will be caught by the Main
Process and written to sonar.log.
|
[
"Setup",
"one",
"or",
"more",
"specified",
"loggers",
"to",
"be",
"non",
"additive",
"and",
"to",
"print",
"to",
"System",
".",
"out",
"which",
"will",
"be",
"caught",
"by",
"the",
"Main",
"Process",
"and",
"written",
"to",
"sonar",
".",
"log",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/log/ServerProcessLogging.java#L140-L153
|
16,278
|
SonarSource/sonarqube
|
sonar-ws/src/main/java/org/sonarqube/ws/client/OkHttpResponse.java
|
OkHttpResponse.content
|
@Override
public String content() {
try (ResponseBody body = okResponse.body()) {
return body.string();
} catch (IOException e) {
throw fail(e);
}
}
|
java
|
@Override
public String content() {
try (ResponseBody body = okResponse.body()) {
return body.string();
} catch (IOException e) {
throw fail(e);
}
}
|
[
"@",
"Override",
"public",
"String",
"content",
"(",
")",
"{",
"try",
"(",
"ResponseBody",
"body",
"=",
"okResponse",
".",
"body",
"(",
")",
")",
"{",
"return",
"body",
".",
"string",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"fail",
"(",
"e",
")",
";",
"}",
"}"
] |
Get body content as a String. This response will be automatically closed.
|
[
"Get",
"body",
"content",
"as",
"a",
"String",
".",
"This",
"response",
"will",
"be",
"automatically",
"closed",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-ws/src/main/java/org/sonarqube/ws/client/OkHttpResponse.java#L78-L85
|
16,279
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/notifications/Notification.java
|
Notification.getDefaultMessage
|
public String getDefaultMessage() {
String defaultMessage = getFieldValue(DEFAULT_MESSAGE_KEY);
if (defaultMessage == null) {
defaultMessage = this.toString();
}
return defaultMessage;
}
|
java
|
public String getDefaultMessage() {
String defaultMessage = getFieldValue(DEFAULT_MESSAGE_KEY);
if (defaultMessage == null) {
defaultMessage = this.toString();
}
return defaultMessage;
}
|
[
"public",
"String",
"getDefaultMessage",
"(",
")",
"{",
"String",
"defaultMessage",
"=",
"getFieldValue",
"(",
"DEFAULT_MESSAGE_KEY",
")",
";",
"if",
"(",
"defaultMessage",
"==",
"null",
")",
"{",
"defaultMessage",
"=",
"this",
".",
"toString",
"(",
")",
";",
"}",
"return",
"defaultMessage",
";",
"}"
] |
Returns the default message to display for this notification.
|
[
"Returns",
"the",
"default",
"message",
"to",
"display",
"for",
"this",
"notification",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/notifications/Notification.java#L89-L95
|
16,280
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java
|
TaskFormatter.computeExecutionTimeMs
|
@CheckForNull
private Long computeExecutionTimeMs(CeQueueDto dto) {
Long startedAt = dto.getStartedAt();
if (startedAt == null) {
return null;
}
return system2.now() - startedAt;
}
|
java
|
@CheckForNull
private Long computeExecutionTimeMs(CeQueueDto dto) {
Long startedAt = dto.getStartedAt();
if (startedAt == null) {
return null;
}
return system2.now() - startedAt;
}
|
[
"@",
"CheckForNull",
"private",
"Long",
"computeExecutionTimeMs",
"(",
"CeQueueDto",
"dto",
")",
"{",
"Long",
"startedAt",
"=",
"dto",
".",
"getStartedAt",
"(",
")",
";",
"if",
"(",
"startedAt",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"system2",
".",
"now",
"(",
")",
"-",
"startedAt",
";",
"}"
] |
now - startedAt
|
[
"now",
"-",
"startedAt"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java#L290-L297
|
16,281
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/authentication/ws/LogoutAction.java
|
LogoutAction.generateAuthenticationEvent
|
private void generateAuthenticationEvent(HttpServletRequest request, HttpServletResponse response) {
try {
Optional<JwtHttpHandler.Token> token = jwtHttpHandler.getToken(request, response);
String userLogin = token.isPresent() ? token.get().getUserDto().getLogin() : null;
authenticationEvent.logoutSuccess(request, userLogin);
} catch (AuthenticationException e) {
authenticationEvent.logoutFailure(request, e.getMessage());
}
}
|
java
|
private void generateAuthenticationEvent(HttpServletRequest request, HttpServletResponse response) {
try {
Optional<JwtHttpHandler.Token> token = jwtHttpHandler.getToken(request, response);
String userLogin = token.isPresent() ? token.get().getUserDto().getLogin() : null;
authenticationEvent.logoutSuccess(request, userLogin);
} catch (AuthenticationException e) {
authenticationEvent.logoutFailure(request, e.getMessage());
}
}
|
[
"private",
"void",
"generateAuthenticationEvent",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"{",
"try",
"{",
"Optional",
"<",
"JwtHttpHandler",
".",
"Token",
">",
"token",
"=",
"jwtHttpHandler",
".",
"getToken",
"(",
"request",
",",
"response",
")",
";",
"String",
"userLogin",
"=",
"token",
".",
"isPresent",
"(",
")",
"?",
"token",
".",
"get",
"(",
")",
".",
"getUserDto",
"(",
")",
".",
"getLogin",
"(",
")",
":",
"null",
";",
"authenticationEvent",
".",
"logoutSuccess",
"(",
"request",
",",
"userLogin",
")",
";",
"}",
"catch",
"(",
"AuthenticationException",
"e",
")",
"{",
"authenticationEvent",
".",
"logoutFailure",
"(",
"request",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
The generation of the authentication event should not prevent the removal of JWT cookie, that's why it's done in a separate method
|
[
"The",
"generation",
"of",
"the",
"authentication",
"event",
"should",
"not",
"prevent",
"the",
"removal",
"of",
"JWT",
"cookie",
"that",
"s",
"why",
"it",
"s",
"done",
"in",
"a",
"separate",
"method"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/LogoutAction.java#L87-L95
|
16,282
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java
|
Durations.format
|
@Deprecated
public String format(Locale locale, Duration duration, DurationFormat format) {
return format(duration);
}
|
java
|
@Deprecated
public String format(Locale locale, Duration duration, DurationFormat format) {
return format(duration);
}
|
[
"@",
"Deprecated",
"public",
"String",
"format",
"(",
"Locale",
"locale",
",",
"Duration",
"duration",
",",
"DurationFormat",
"format",
")",
"{",
"return",
"format",
"(",
"duration",
")",
";",
"}"
] |
Return the formatted work duration.
@deprecated since 6.3 as the {@link Locale#ENGLISH} is always used. Use {@link #format(Duration)} instead
|
[
"Return",
"the",
"formatted",
"work",
"duration",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java#L83-L86
|
16,283
|
SonarSource/sonarqube
|
server/sonar-main/src/main/java/org/sonar/application/command/JvmOptions.java
|
JvmOptions.add
|
public T add(String str) {
requireNonNull(str, JVM_OPTION_NOT_NULL_ERROR_MESSAGE);
String value = str.trim();
if (isInvalidOption(value)) {
throw new IllegalArgumentException("a JVM option can't be empty and must start with '-'");
}
checkMandatoryOptionOverwrite(value);
options.add(value);
return castThis();
}
|
java
|
public T add(String str) {
requireNonNull(str, JVM_OPTION_NOT_NULL_ERROR_MESSAGE);
String value = str.trim();
if (isInvalidOption(value)) {
throw new IllegalArgumentException("a JVM option can't be empty and must start with '-'");
}
checkMandatoryOptionOverwrite(value);
options.add(value);
return castThis();
}
|
[
"public",
"T",
"add",
"(",
"String",
"str",
")",
"{",
"requireNonNull",
"(",
"str",
",",
"JVM_OPTION_NOT_NULL_ERROR_MESSAGE",
")",
";",
"String",
"value",
"=",
"str",
".",
"trim",
"(",
")",
";",
"if",
"(",
"isInvalidOption",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"a JVM option can't be empty and must start with '-'\"",
")",
";",
"}",
"checkMandatoryOptionOverwrite",
"(",
"value",
")",
";",
"options",
".",
"add",
"(",
"value",
")",
";",
"return",
"castThis",
"(",
")",
";",
"}"
] |
Add an option.
Argument is trimmed before being added.
@throws IllegalArgumentException if argument is empty or does not start with {@code -}.
|
[
"Add",
"an",
"option",
".",
"Argument",
"is",
"trimmed",
"before",
"being",
"added",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-main/src/main/java/org/sonar/application/command/JvmOptions.java#L114-L124
|
16,284
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java
|
DateUtils.parseDate
|
public static Date parseDate(String s) {
return Date.from(parseLocalDate(s).atStartOfDay(ZoneId.systemDefault()).toInstant());
}
|
java
|
public static Date parseDate(String s) {
return Date.from(parseLocalDate(s).atStartOfDay(ZoneId.systemDefault()).toInstant());
}
|
[
"public",
"static",
"Date",
"parseDate",
"(",
"String",
"s",
")",
"{",
"return",
"Date",
".",
"from",
"(",
"parseLocalDate",
"(",
"s",
")",
".",
"atStartOfDay",
"(",
"ZoneId",
".",
"systemDefault",
"(",
")",
")",
".",
"toInstant",
"(",
")",
")",
";",
"}"
] |
Return a date at the start of day.
@param s string in format {@link #DATE_FORMAT}
@throws SonarException when string cannot be parsed
|
[
"Return",
"a",
"date",
"at",
"the",
"start",
"of",
"day",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java#L110-L112
|
16,285
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java
|
DateUtils.addDays
|
public static Date addDays(Date date, int numberOfDays) {
return Date.from(date.toInstant().plus(numberOfDays, ChronoUnit.DAYS));
}
|
java
|
public static Date addDays(Date date, int numberOfDays) {
return Date.from(date.toInstant().plus(numberOfDays, ChronoUnit.DAYS));
}
|
[
"public",
"static",
"Date",
"addDays",
"(",
"Date",
"date",
",",
"int",
"numberOfDays",
")",
"{",
"return",
"Date",
".",
"from",
"(",
"date",
".",
"toInstant",
"(",
")",
".",
"plus",
"(",
"numberOfDays",
",",
"ChronoUnit",
".",
"DAYS",
")",
")",
";",
"}"
] |
Adds a number of days to a date returning a new object.
The original date object is unchanged.
@param date the date, not null
@param numberOfDays the amount to add, may be negative
@return the new date object with the amount added
|
[
"Adds",
"a",
"number",
"of",
"days",
"to",
"a",
"date",
"returning",
"a",
"new",
"object",
".",
"The",
"original",
"date",
"object",
"is",
"unchanged",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java#L297-L299
|
16,286
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java
|
HttpsTrust.createSocketFactory
|
private static SSLSocketFactory createSocketFactory(Ssl context) {
try {
return context.newFactory(new AlwaysTrustManager());
} catch (Exception e) {
throw new IllegalStateException("Fail to build SSL factory", e);
}
}
|
java
|
private static SSLSocketFactory createSocketFactory(Ssl context) {
try {
return context.newFactory(new AlwaysTrustManager());
} catch (Exception e) {
throw new IllegalStateException("Fail to build SSL factory", e);
}
}
|
[
"private",
"static",
"SSLSocketFactory",
"createSocketFactory",
"(",
"Ssl",
"context",
")",
"{",
"try",
"{",
"return",
"context",
".",
"newFactory",
"(",
"new",
"AlwaysTrustManager",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Fail to build SSL factory\"",
",",
"e",
")",
";",
"}",
"}"
] |
Trust all certificates
|
[
"Trust",
"all",
"certificates"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java#L69-L75
|
16,287
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java
|
HttpsTrust.createHostnameVerifier
|
private static HostnameVerifier createHostnameVerifier() {
return new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
}
|
java
|
private static HostnameVerifier createHostnameVerifier() {
return new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
}
|
[
"private",
"static",
"HostnameVerifier",
"createHostnameVerifier",
"(",
")",
"{",
"return",
"new",
"HostnameVerifier",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"verify",
"(",
"String",
"hostname",
",",
"SSLSession",
"session",
")",
"{",
"return",
"true",
";",
"}",
"}",
";",
"}"
] |
Trust all hosts
|
[
"Trust",
"all",
"hosts"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java#L80-L87
|
16,288
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
|
ComponentDao.selectByKeysAndBranches
|
public List<ComponentDto> selectByKeysAndBranches(DbSession session, Map<String, String> branchesByKey) {
Set<String> dbKeys = branchesByKey.entrySet().stream()
.map(entry -> generateBranchKey(entry.getKey(), entry.getValue()))
.collect(toSet());
return selectByDbKeys(session, dbKeys);
}
|
java
|
public List<ComponentDto> selectByKeysAndBranches(DbSession session, Map<String, String> branchesByKey) {
Set<String> dbKeys = branchesByKey.entrySet().stream()
.map(entry -> generateBranchKey(entry.getKey(), entry.getValue()))
.collect(toSet());
return selectByDbKeys(session, dbKeys);
}
|
[
"public",
"List",
"<",
"ComponentDto",
">",
"selectByKeysAndBranches",
"(",
"DbSession",
"session",
",",
"Map",
"<",
"String",
",",
"String",
">",
"branchesByKey",
")",
"{",
"Set",
"<",
"String",
">",
"dbKeys",
"=",
"branchesByKey",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"entry",
"->",
"generateBranchKey",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
")",
".",
"collect",
"(",
"toSet",
"(",
")",
")",
";",
"return",
"selectByDbKeys",
"(",
"session",
",",
"dbKeys",
")",
";",
"}"
] |
Return list of components that will will mix main and branch components.
Please note that a project can only appear once in the list, it's not possible to ask for many branches on same project with this method.
|
[
"Return",
"list",
"of",
"components",
"that",
"will",
"will",
"mix",
"main",
"and",
"branch",
"components",
".",
"Please",
"note",
"that",
"a",
"project",
"can",
"only",
"appear",
"once",
"in",
"the",
"list",
"it",
"s",
"not",
"possible",
"to",
"ask",
"for",
"many",
"branches",
"on",
"same",
"project",
"with",
"this",
"method",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java#L212-L217
|
16,289
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
|
ComponentDao.selectAncestors
|
public List<ComponentDto> selectAncestors(DbSession dbSession, ComponentDto component) {
if (component.isRoot()) {
return Collections.emptyList();
}
List<String> ancestorUuids = component.getUuidPathAsList();
List<ComponentDto> ancestors = selectByUuids(dbSession, ancestorUuids);
return Ordering.explicit(ancestorUuids).onResultOf(ComponentDto::uuid).immutableSortedCopy(ancestors);
}
|
java
|
public List<ComponentDto> selectAncestors(DbSession dbSession, ComponentDto component) {
if (component.isRoot()) {
return Collections.emptyList();
}
List<String> ancestorUuids = component.getUuidPathAsList();
List<ComponentDto> ancestors = selectByUuids(dbSession, ancestorUuids);
return Ordering.explicit(ancestorUuids).onResultOf(ComponentDto::uuid).immutableSortedCopy(ancestors);
}
|
[
"public",
"List",
"<",
"ComponentDto",
">",
"selectAncestors",
"(",
"DbSession",
"dbSession",
",",
"ComponentDto",
"component",
")",
"{",
"if",
"(",
"component",
".",
"isRoot",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"List",
"<",
"String",
">",
"ancestorUuids",
"=",
"component",
".",
"getUuidPathAsList",
"(",
")",
";",
"List",
"<",
"ComponentDto",
">",
"ancestors",
"=",
"selectByUuids",
"(",
"dbSession",
",",
"ancestorUuids",
")",
";",
"return",
"Ordering",
".",
"explicit",
"(",
"ancestorUuids",
")",
".",
"onResultOf",
"(",
"ComponentDto",
"::",
"uuid",
")",
".",
"immutableSortedCopy",
"(",
"ancestors",
")",
";",
"}"
] |
List of ancestors, ordered from root to parent. The list is empty
if the component is a tree root. Disabled components are excluded by design
as tree represents the more recent analysis.
|
[
"List",
"of",
"ancestors",
"ordered",
"from",
"root",
"to",
"parent",
".",
"The",
"list",
"is",
"empty",
"if",
"the",
"component",
"is",
"a",
"tree",
"root",
".",
"Disabled",
"components",
"are",
"excluded",
"by",
"design",
"as",
"tree",
"represents",
"the",
"more",
"recent",
"analysis",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java#L238-L245
|
16,290
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationContext.java
|
RuleActivationContext.selectChild
|
void selectChild(QProfileDto to) {
checkState(!to.isBuiltIn());
QProfileDto qp = requireNonNull(this.profilesByUuid.get(to.getKee()), () -> "No profile with uuid " + to.getKee());
RulesProfileDto ruleProfile = RulesProfileDto.from(qp);
doSwitch(ruleProfile, getRule().get().getId());
}
|
java
|
void selectChild(QProfileDto to) {
checkState(!to.isBuiltIn());
QProfileDto qp = requireNonNull(this.profilesByUuid.get(to.getKee()), () -> "No profile with uuid " + to.getKee());
RulesProfileDto ruleProfile = RulesProfileDto.from(qp);
doSwitch(ruleProfile, getRule().get().getId());
}
|
[
"void",
"selectChild",
"(",
"QProfileDto",
"to",
")",
"{",
"checkState",
"(",
"!",
"to",
".",
"isBuiltIn",
"(",
")",
")",
";",
"QProfileDto",
"qp",
"=",
"requireNonNull",
"(",
"this",
".",
"profilesByUuid",
".",
"get",
"(",
"to",
".",
"getKee",
"(",
")",
")",
",",
"(",
")",
"->",
"\"No profile with uuid \"",
"+",
"to",
".",
"getKee",
"(",
")",
")",
";",
"RulesProfileDto",
"ruleProfile",
"=",
"RulesProfileDto",
".",
"from",
"(",
"qp",
")",
";",
"doSwitch",
"(",
"ruleProfile",
",",
"getRule",
"(",
")",
".",
"get",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"}"
] |
Moves cursor to a child profile
|
[
"Moves",
"cursor",
"to",
"a",
"child",
"profile"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationContext.java#L214-L220
|
16,291
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
|
MoreCollectors.toOneElement
|
public static <T> Collector<T, ?, T> toOneElement() {
return java.util.stream.Collectors.collectingAndThen(
java.util.stream.Collectors.toList(),
list -> {
if (list.size() != 1) {
throw new IllegalStateException("Stream should have only one element");
}
return list.get(0);
});
}
|
java
|
public static <T> Collector<T, ?, T> toOneElement() {
return java.util.stream.Collectors.collectingAndThen(
java.util.stream.Collectors.toList(),
list -> {
if (list.size() != 1) {
throw new IllegalStateException("Stream should have only one element");
}
return list.get(0);
});
}
|
[
"public",
"static",
"<",
"T",
">",
"Collector",
"<",
"T",
",",
"?",
",",
"T",
">",
"toOneElement",
"(",
")",
"{",
"return",
"java",
".",
"util",
".",
"stream",
".",
"Collectors",
".",
"collectingAndThen",
"(",
"java",
".",
"util",
".",
"stream",
".",
"Collectors",
".",
"toList",
"(",
")",
",",
"list",
"->",
"{",
"if",
"(",
"list",
".",
"size",
"(",
")",
"!=",
"1",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Stream should have only one element\"",
")",
";",
"}",
"return",
"list",
".",
"get",
"(",
"0",
")",
";",
"}",
")",
";",
"}"
] |
For stream of one expected element, return the element
@throws IllegalArgumentException if stream has no element or more than 1 element
|
[
"For",
"stream",
"of",
"one",
"expected",
"element",
"return",
"the",
"element"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java#L281-L290
|
16,292
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/util/UuidFactoryFast.java
|
UuidFactoryFast.putLong
|
private static void putLong(byte[] array, long l, int pos, int numberOfLongBytes) {
for (int i = 0; i < numberOfLongBytes; ++i) {
array[pos + numberOfLongBytes - i - 1] = (byte) (l >>> (i * 8));
}
}
|
java
|
private static void putLong(byte[] array, long l, int pos, int numberOfLongBytes) {
for (int i = 0; i < numberOfLongBytes; ++i) {
array[pos + numberOfLongBytes - i - 1] = (byte) (l >>> (i * 8));
}
}
|
[
"private",
"static",
"void",
"putLong",
"(",
"byte",
"[",
"]",
"array",
",",
"long",
"l",
",",
"int",
"pos",
",",
"int",
"numberOfLongBytes",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numberOfLongBytes",
";",
"++",
"i",
")",
"{",
"array",
"[",
"pos",
"+",
"numberOfLongBytes",
"-",
"i",
"-",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"l",
">>>",
"(",
"i",
"*",
"8",
")",
")",
";",
"}",
"}"
] |
Puts the lower numberOfLongBytes from l into the array, starting index pos.
|
[
"Puts",
"the",
"lower",
"numberOfLongBytes",
"from",
"l",
"into",
"the",
"array",
"starting",
"index",
"pos",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/util/UuidFactoryFast.java#L62-L66
|
16,293
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryImpl.java
|
ComponentUuidFactoryImpl.getOrCreateForKey
|
@Override
public String getOrCreateForKey(String key) {
return uuidsByKey.computeIfAbsent(key, k -> Uuids.create());
}
|
java
|
@Override
public String getOrCreateForKey(String key) {
return uuidsByKey.computeIfAbsent(key, k -> Uuids.create());
}
|
[
"@",
"Override",
"public",
"String",
"getOrCreateForKey",
"(",
"String",
"key",
")",
"{",
"return",
"uuidsByKey",
".",
"computeIfAbsent",
"(",
"key",
",",
"k",
"->",
"Uuids",
".",
"create",
"(",
")",
")",
";",
"}"
] |
Get UUID from database if it exists, otherwise generate a new one.
|
[
"Get",
"UUID",
"from",
"database",
"if",
"it",
"exists",
"otherwise",
"generate",
"a",
"new",
"one",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryImpl.java#L41-L44
|
16,294
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java
|
AnalysisContextReportPublisher.collectModuleSpecificProps
|
private Map<String, String> collectModuleSpecificProps(DefaultInputModule module) {
Map<String, String> moduleSpecificProps = new HashMap<>();
AbstractProjectOrModule parent = hierarchy.parent(module);
if (parent == null) {
moduleSpecificProps.putAll(module.properties());
} else {
Map<String, String> parentProps = parent.properties();
for (Map.Entry<String, String> entry : module.properties().entrySet()) {
if (!parentProps.containsKey(entry.getKey()) || !parentProps.get(entry.getKey()).equals(entry.getValue())) {
moduleSpecificProps.put(entry.getKey(), entry.getValue());
}
}
}
return moduleSpecificProps;
}
|
java
|
private Map<String, String> collectModuleSpecificProps(DefaultInputModule module) {
Map<String, String> moduleSpecificProps = new HashMap<>();
AbstractProjectOrModule parent = hierarchy.parent(module);
if (parent == null) {
moduleSpecificProps.putAll(module.properties());
} else {
Map<String, String> parentProps = parent.properties();
for (Map.Entry<String, String> entry : module.properties().entrySet()) {
if (!parentProps.containsKey(entry.getKey()) || !parentProps.get(entry.getKey()).equals(entry.getValue())) {
moduleSpecificProps.put(entry.getKey(), entry.getValue());
}
}
}
return moduleSpecificProps;
}
|
[
"private",
"Map",
"<",
"String",
",",
"String",
">",
"collectModuleSpecificProps",
"(",
"DefaultInputModule",
"module",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"moduleSpecificProps",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"AbstractProjectOrModule",
"parent",
"=",
"hierarchy",
".",
"parent",
"(",
"module",
")",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"moduleSpecificProps",
".",
"putAll",
"(",
"module",
".",
"properties",
"(",
")",
")",
";",
"}",
"else",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"parentProps",
"=",
"parent",
".",
"properties",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"module",
".",
"properties",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"parentProps",
".",
"containsKey",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
"||",
"!",
"parentProps",
".",
"get",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
".",
"equals",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
"{",
"moduleSpecificProps",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"moduleSpecificProps",
";",
"}"
] |
Only keep props that are not in parent
|
[
"Only",
"keep",
"props",
"that",
"are",
"not",
"in",
"parent"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java#L174-L188
|
16,295
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/property/ws/IndexAction.java
|
IndexAction.loadComponentSettings
|
private Multimap<String, PropertyDto> loadComponentSettings(DbSession dbSession, Optional<String> key, ComponentDto component) {
List<String> componentUuids = DOT_SPLITTER.splitToList(component.moduleUuidPath());
List<ComponentDto> componentDtos = dbClient.componentDao().selectByUuids(dbSession, componentUuids);
Set<Long> componentIds = componentDtos.stream().map(ComponentDto::getId).collect(Collectors.toSet());
Map<Long, String> uuidsById = componentDtos.stream().collect(Collectors.toMap(ComponentDto::getId, ComponentDto::uuid));
List<PropertyDto> properties = key.isPresent() ? dbClient.propertiesDao().selectPropertiesByKeysAndComponentIds(dbSession, Collections.singleton(key.get()), componentIds)
: dbClient.propertiesDao().selectPropertiesByComponentIds(dbSession, componentIds);
Multimap<String, PropertyDto> propertyDtosByUuid = TreeMultimap.create(Ordering.explicit(componentUuids), Ordering.arbitrary());
for (PropertyDto propertyDto : properties) {
Long componentId = propertyDto.getResourceId();
String componentUuid = uuidsById.get(componentId);
propertyDtosByUuid.put(componentUuid, propertyDto);
}
return propertyDtosByUuid;
}
|
java
|
private Multimap<String, PropertyDto> loadComponentSettings(DbSession dbSession, Optional<String> key, ComponentDto component) {
List<String> componentUuids = DOT_SPLITTER.splitToList(component.moduleUuidPath());
List<ComponentDto> componentDtos = dbClient.componentDao().selectByUuids(dbSession, componentUuids);
Set<Long> componentIds = componentDtos.stream().map(ComponentDto::getId).collect(Collectors.toSet());
Map<Long, String> uuidsById = componentDtos.stream().collect(Collectors.toMap(ComponentDto::getId, ComponentDto::uuid));
List<PropertyDto> properties = key.isPresent() ? dbClient.propertiesDao().selectPropertiesByKeysAndComponentIds(dbSession, Collections.singleton(key.get()), componentIds)
: dbClient.propertiesDao().selectPropertiesByComponentIds(dbSession, componentIds);
Multimap<String, PropertyDto> propertyDtosByUuid = TreeMultimap.create(Ordering.explicit(componentUuids), Ordering.arbitrary());
for (PropertyDto propertyDto : properties) {
Long componentId = propertyDto.getResourceId();
String componentUuid = uuidsById.get(componentId);
propertyDtosByUuid.put(componentUuid, propertyDto);
}
return propertyDtosByUuid;
}
|
[
"private",
"Multimap",
"<",
"String",
",",
"PropertyDto",
">",
"loadComponentSettings",
"(",
"DbSession",
"dbSession",
",",
"Optional",
"<",
"String",
">",
"key",
",",
"ComponentDto",
"component",
")",
"{",
"List",
"<",
"String",
">",
"componentUuids",
"=",
"DOT_SPLITTER",
".",
"splitToList",
"(",
"component",
".",
"moduleUuidPath",
"(",
")",
")",
";",
"List",
"<",
"ComponentDto",
">",
"componentDtos",
"=",
"dbClient",
".",
"componentDao",
"(",
")",
".",
"selectByUuids",
"(",
"dbSession",
",",
"componentUuids",
")",
";",
"Set",
"<",
"Long",
">",
"componentIds",
"=",
"componentDtos",
".",
"stream",
"(",
")",
".",
"map",
"(",
"ComponentDto",
"::",
"getId",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"Map",
"<",
"Long",
",",
"String",
">",
"uuidsById",
"=",
"componentDtos",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toMap",
"(",
"ComponentDto",
"::",
"getId",
",",
"ComponentDto",
"::",
"uuid",
")",
")",
";",
"List",
"<",
"PropertyDto",
">",
"properties",
"=",
"key",
".",
"isPresent",
"(",
")",
"?",
"dbClient",
".",
"propertiesDao",
"(",
")",
".",
"selectPropertiesByKeysAndComponentIds",
"(",
"dbSession",
",",
"Collections",
".",
"singleton",
"(",
"key",
".",
"get",
"(",
")",
")",
",",
"componentIds",
")",
":",
"dbClient",
".",
"propertiesDao",
"(",
")",
".",
"selectPropertiesByComponentIds",
"(",
"dbSession",
",",
"componentIds",
")",
";",
"Multimap",
"<",
"String",
",",
"PropertyDto",
">",
"propertyDtosByUuid",
"=",
"TreeMultimap",
".",
"create",
"(",
"Ordering",
".",
"explicit",
"(",
"componentUuids",
")",
",",
"Ordering",
".",
"arbitrary",
"(",
")",
")",
";",
"for",
"(",
"PropertyDto",
"propertyDto",
":",
"properties",
")",
"{",
"Long",
"componentId",
"=",
"propertyDto",
".",
"getResourceId",
"(",
")",
";",
"String",
"componentUuid",
"=",
"uuidsById",
".",
"get",
"(",
"componentId",
")",
";",
"propertyDtosByUuid",
".",
"put",
"(",
"componentUuid",
",",
"propertyDto",
")",
";",
"}",
"return",
"propertyDtosByUuid",
";",
"}"
] |
Return list of propertyDto by component uuid, sorted from project to lowest module
|
[
"Return",
"list",
"of",
"propertyDto",
"by",
"component",
"uuid",
"sorted",
"from",
"project",
"to",
"lowest",
"module"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/property/ws/IndexAction.java#L159-L174
|
16,296
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java
|
ModuleConfigurationProvider.getTopDownParentProjects
|
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;
}
|
java
|
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;
}
|
[
"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",
";",
"}"
] |
From root to given project
|
[
"From",
"root",
"to",
"given",
"project"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java#L60-L68
|
16,297
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java
|
PlatformLevel.addIfStartupLeader
|
AddIfStartupLeader addIfStartupLeader(Object... objects) {
if (addIfStartupLeader == null) {
this.addIfStartupLeader = new AddIfStartupLeader(getWebServer().isStartupLeader());
}
addIfStartupLeader.ifAdd(objects);
return addIfStartupLeader;
}
|
java
|
AddIfStartupLeader addIfStartupLeader(Object... objects) {
if (addIfStartupLeader == null) {
this.addIfStartupLeader = new AddIfStartupLeader(getWebServer().isStartupLeader());
}
addIfStartupLeader.ifAdd(objects);
return addIfStartupLeader;
}
|
[
"AddIfStartupLeader",
"addIfStartupLeader",
"(",
"Object",
"...",
"objects",
")",
"{",
"if",
"(",
"addIfStartupLeader",
"==",
"null",
")",
"{",
"this",
".",
"addIfStartupLeader",
"=",
"new",
"AddIfStartupLeader",
"(",
"getWebServer",
"(",
")",
".",
"isStartupLeader",
"(",
")",
")",
";",
"}",
"addIfStartupLeader",
".",
"ifAdd",
"(",
"objects",
")",
";",
"return",
"addIfStartupLeader",
";",
"}"
] |
Add a component to container only if the web server is startup leader.
@throws IllegalStateException if called from PlatformLevel1, when cluster settings are not loaded
|
[
"Add",
"a",
"component",
"to",
"container",
"only",
"if",
"the",
"web",
"server",
"is",
"startup",
"leader",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java#L139-L145
|
16,298
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java
|
PlatformLevel.addIfCluster
|
AddIfCluster addIfCluster(Object... objects) {
if (addIfCluster == null) {
addIfCluster = new AddIfCluster(!getWebServer().isStandalone());
}
addIfCluster.ifAdd(objects);
return addIfCluster;
}
|
java
|
AddIfCluster addIfCluster(Object... objects) {
if (addIfCluster == null) {
addIfCluster = new AddIfCluster(!getWebServer().isStandalone());
}
addIfCluster.ifAdd(objects);
return addIfCluster;
}
|
[
"AddIfCluster",
"addIfCluster",
"(",
"Object",
"...",
"objects",
")",
"{",
"if",
"(",
"addIfCluster",
"==",
"null",
")",
"{",
"addIfCluster",
"=",
"new",
"AddIfCluster",
"(",
"!",
"getWebServer",
"(",
")",
".",
"isStandalone",
"(",
")",
")",
";",
"}",
"addIfCluster",
".",
"ifAdd",
"(",
"objects",
")",
";",
"return",
"addIfCluster",
";",
"}"
] |
Add a component to container only if clustering is enabled.
@throws IllegalStateException if called from PlatformLevel1, when cluster settings are not loaded
|
[
"Add",
"a",
"component",
"to",
"container",
"only",
"if",
"clustering",
"is",
"enabled",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java#L152-L158
|
16,299
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java
|
PlatformLevel.addIfStandalone
|
AddIfStandalone addIfStandalone(Object... objects) {
if (addIfStandalone == null) {
addIfStandalone = new AddIfStandalone(getWebServer().isStandalone());
}
addIfStandalone.ifAdd(objects);
return addIfStandalone;
}
|
java
|
AddIfStandalone addIfStandalone(Object... objects) {
if (addIfStandalone == null) {
addIfStandalone = new AddIfStandalone(getWebServer().isStandalone());
}
addIfStandalone.ifAdd(objects);
return addIfStandalone;
}
|
[
"AddIfStandalone",
"addIfStandalone",
"(",
"Object",
"...",
"objects",
")",
"{",
"if",
"(",
"addIfStandalone",
"==",
"null",
")",
"{",
"addIfStandalone",
"=",
"new",
"AddIfStandalone",
"(",
"getWebServer",
"(",
")",
".",
"isStandalone",
"(",
")",
")",
";",
"}",
"addIfStandalone",
".",
"ifAdd",
"(",
"objects",
")",
";",
"return",
"addIfStandalone",
";",
"}"
] |
Add a component to container only if this is a standalone instance, without clustering.
@throws IllegalStateException if called from PlatformLevel1, when cluster settings are not loaded
|
[
"Add",
"a",
"component",
"to",
"container",
"only",
"if",
"this",
"is",
"a",
"standalone",
"instance",
"without",
"clustering",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java#L165-L171
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.