dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:2.9.0.1147'
dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.9.0.3429'
dependency 'org.sonarsource.slang:sonar-scala-plugin:1.9.0.3429'
- dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.8.0.196'
+ dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.8.0.203'
dependency 'org.sonarsource.xml:sonar-xml-plugin:2.5.0.3376'
dependency 'org.sonarsource.iac:sonar-iac-plugin:1.7.0.2012'
dependency 'org.sonarsource.text:sonar-text-plugin:1.1.0.282'
oneIssuePerLine
.setDebtRemediationFunction(oneIssuePerLine.debtRemediationFunctions().linear("1min"))
.setGapDescription("It takes about 1 minute to an experienced software craftsman to remove a line of code")
- .addGenericConceptKeys("defense_in_depth", "least_trust_principle");
+ .addEducationPrincipleKeys("defense_in_depth", "least_trust_principle");
NewRule oneQuickFixPerLine = repo.createRule(OneQuickFixPerLineSensor.RULE_KEY).setName("One Quick Fix Per Line")
.setTags("line");
private String ruleKey = null;
private final Set<RuleDescriptionSectionDto> ruleDescriptionSectionDtos = new HashSet<>();
- private String genericConceptsField = null;
+ private String educationPrinciplesField = null;
/**
* Description format can be null on external rule, otherwise it should never be null
return Objects.equals(contextKey, otherContextKey);
}
- public Set<String> getGenericConcepts() {
- return deserializeStringSet(genericConceptsField);
+ public Set<String> getEducationPrinciples() {
+ return deserializeStringSet(educationPrinciplesField);
}
- public RuleDto setGenericConcepts(Set<String> genericConcepts){
- this.genericConceptsField = serializeStringSet(genericConcepts);
+ public RuleDto setEducationPrinciples(Set<String> educationPrinciples){
+ this.educationPrinciplesField = serializeStringSet(educationPrinciples);
return this;
}
r.ad_hoc_description as "adHocDescription",
r.ad_hoc_severity as "adHocSeverity",
r.ad_hoc_type as "adHocType",
- r.generic_concepts as "genericConceptsField"
+ r.education_principles as "educationPrinciplesField"
</sql>
<sql id="leftOuterJoinRulesDescriptionSections">
ad_hoc_description,
ad_hoc_severity,
ad_hoc_type,
- generic_concepts,
+ education_principles,
created_at,
updated_at
)
#{adHocDescription,jdbcType=CLOB},
#{adHocSeverity,jdbcType=VARCHAR},
#{adHocType,jdbcType=TINYINT},
- #{genericConceptsField,jdbcType=VARCHAR},
+ #{educationPrinciplesField,jdbcType=VARCHAR},
#{createdAt,jdbcType=BIGINT},
#{updatedAt,jdbcType=BIGINT}
)
ad_hoc_description=#{adHocDescription,jdbcType=CLOB},
ad_hoc_severity=#{adHocSeverity,jdbcType=VARCHAR},
ad_hoc_type=#{adHocType,jdbcType=TINYINT},
- generic_concepts=#{genericConceptsField,jdbcType=VARCHAR},
+ education_principles=#{educationPrinciplesField,jdbcType=VARCHAR},
updated_at=#{updatedAt,jdbcType=BIGINT}
where
uuid=#{uuid,jdbcType=VARCHAR}
"AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT,
"AD_HOC_SEVERITY" CHARACTER VARYING(10),
"AD_HOC_TYPE" TINYINT,
- "GENERIC_CONCEPTS" CHARACTER VARYING(255)
+ "EDUCATION_PRINCIPLES" CHARACTER VARYING(255)
);
ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID");
CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY" NULLS FIRST, "PLUGIN_NAME" NULLS FIRST);
assertThat(actual.getAdHocType()).isEqualTo(expected.getAdHocType());
assertThat(actual.getRuleDescriptionSectionDtos()).usingRecursiveFieldByFieldElementComparator()
.containsExactlyInAnyOrderElementsOf(expected.getRuleDescriptionSectionDtos());
- assertThat(actual.getGenericConcepts()).isEqualTo(expected.getGenericConcepts());
+ assertThat(actual.getEducationPrinciples()).isEqualTo(expected.getEducationPrinciples());
}
@Test
.setCreatedAt(currentTimeMillis)
.setUpdatedAt(currentTimeMillis + 5)
.setScope(Scope.MAIN)
- .setGenericConcepts(Set.of(randomAlphanumeric(5), randomAlphanumeric(5)));
+ .setEducationPrinciples(Set.of(randomAlphanumeric(5), randomAlphanumeric(5)));
}
public static RuleParamDto newRuleParam(RuleDto rule) {
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v96;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.DatabaseUtils;
+import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AddEducationPrinciplesColumnToRuleTable extends DdlChange {
+
+ static final String COLUMN_EDUCATION_PRINCIPLES_KEY = "education_principles";
+
+ static final String RULE_TABLE = "rules";
+
+ public AddEducationPrinciplesColumnToRuleTable(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(DdlChange.Context context) throws SQLException {
+ try (Connection connection = getDatabase().getDataSource().getConnection()) {
+ if (!DatabaseUtils.tableColumnExists(connection, RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY)) {
+ context.execute(new AddColumnsBuilder(getDialect(), RULE_TABLE)
+ .addColumn(newVarcharColumnDefBuilder().setColumnName(COLUMN_EDUCATION_PRINCIPLES_KEY).setIsNullable(true).setLimit(255).build())
+ .build());
+ }
+ }
+ }
+
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.db.migration.version.v96;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import org.sonar.db.Database;
-import org.sonar.db.DatabaseUtils;
-import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-
-import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
-
-public class AddGenericConceptsColumnToRuleTable extends DdlChange {
-
- static final String COLUMN_GENERIC_CONCEPTS_KEY = "generic_concepts";
-
- static final String RULE_TABLE = "rules";
-
- public AddGenericConceptsColumnToRuleTable(Database db) {
- super(db);
- }
-
- @Override
- public void execute(DdlChange.Context context) throws SQLException {
- try (Connection connection = getDatabase().getDataSource().getConnection()) {
- if (!DatabaseUtils.tableColumnExists(connection, RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY)) {
- context.execute(new AddColumnsBuilder(getDialect(), RULE_TABLE)
- .addColumn(newVarcharColumnDefBuilder().setColumnName(COLUMN_GENERIC_CONCEPTS_KEY).setIsNullable(true).setLimit(255).build())
- .build());
- }
- }
- }
-
-}
.add(6503, "Create unique uniq_rule_desc_sections", CreateIndexForRuleDescSections.class)
.add(6504, "Add column 'expiration_date' to 'user_tokens'", AddExpirationDateColumnToUserTokens.class)
.add(6505, "Add column 'rule_description_context_key' to 'issues'", AddRuleDescriptionContextKeyInIssuesTable.class)
- .add(6506, "Add column 'generic_concepts' to 'rules'", AddGenericConceptsColumnToRuleTable.class)
+ .add(6506, "Add column 'education_principles' to 'rules'", AddEducationPrinciplesColumnToRuleTable.class)
;
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v96;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.sonar.db.CoreDbTester.createForSchema;
+import static org.sonar.server.platform.db.migration.version.v96.AddEducationPrinciplesColumnToRuleTable.COLUMN_EDUCATION_PRINCIPLES_KEY;
+import static org.sonar.server.platform.db.migration.version.v96.AddEducationPrinciplesColumnToRuleTable.RULE_TABLE;
+
+public class AddEducationPrinciplesColumnToRuleTableTest {
+ @Rule
+ public final CoreDbTester db = createForSchema(AddEducationPrinciplesColumnToRuleTableTest.class, "schema.sql");
+
+ private final AddEducationPrinciplesColumnToRuleTable addEducationPrinciplesColumnToRuleTable = new AddEducationPrinciplesColumnToRuleTable(db.database());
+
+ @Test
+ public void column_education_principles_should_be_added() throws SQLException {
+ db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY);
+
+ addEducationPrinciplesColumnToRuleTable.execute();
+
+ db.assertColumnDefinition(RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY, Types.VARCHAR, 255, true);
+ }
+
+ @Test
+ public void migration_should_be_reentrant() throws SQLException {
+ db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY);
+
+ addEducationPrinciplesColumnToRuleTable.execute();
+ addEducationPrinciplesColumnToRuleTable.execute();
+
+ db.assertColumnDefinition(RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY, Types.VARCHAR, 255, true);
+ }
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.db.migration.version.v96;
-
-import java.sql.SQLException;
-import java.sql.Types;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.db.CoreDbTester;
-
-import static org.sonar.db.CoreDbTester.createForSchema;
-import static org.sonar.server.platform.db.migration.version.v96.AddGenericConceptsColumnToRuleTable.COLUMN_GENERIC_CONCEPTS_KEY;
-import static org.sonar.server.platform.db.migration.version.v96.AddGenericConceptsColumnToRuleTable.RULE_TABLE;
-
-public class AddGenericConceptsColumnToRuleTableTest {
- @Rule
- public final CoreDbTester db = createForSchema(AddGenericConceptsColumnToRuleTableTest.class, "schema.sql");
-
- private final AddGenericConceptsColumnToRuleTable addGenericConceptsColumnToRuleTable = new AddGenericConceptsColumnToRuleTable(db.database());
-
- @Test
- public void column_generic_concepts_should_be_added() throws SQLException {
- db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY);
-
- addGenericConceptsColumnToRuleTable.execute();
-
- db.assertColumnDefinition(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY, Types.VARCHAR, 255, true);
- }
-
- @Test
- public void migration_should_be_reentrant() throws SQLException {
- db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY);
-
- addGenericConceptsColumnToRuleTable.execute();
- addGenericConceptsColumnToRuleTable.execute();
-
- db.assertColumnDefinition(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY, Types.VARCHAR, 255, true);
- }
-}
--- /dev/null
+CREATE TABLE "RULES"(
+ "UUID" CHARACTER VARYING(40) NOT NULL,
+ "NAME" CHARACTER VARYING(200),
+ "PLUGIN_RULE_KEY" CHARACTER VARYING(200) NOT NULL,
+ "PLUGIN_KEY" CHARACTER VARYING(200),
+ "PLUGIN_CONFIG_KEY" CHARACTER VARYING(200),
+ "PLUGIN_NAME" CHARACTER VARYING(255) NOT NULL,
+ "SCOPE" CHARACTER VARYING(20) NOT NULL,
+ "PRIORITY" INTEGER,
+ "STATUS" CHARACTER VARYING(40),
+ "LANGUAGE" CHARACTER VARYING(20),
+ "DEF_REMEDIATION_FUNCTION" CHARACTER VARYING(20),
+ "DEF_REMEDIATION_GAP_MULT" CHARACTER VARYING(20),
+ "DEF_REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20),
+ "GAP_DESCRIPTION" CHARACTER VARYING(4000),
+ "SYSTEM_TAGS" CHARACTER VARYING(4000),
+ "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL,
+ "DESCRIPTION_FORMAT" CHARACTER VARYING(20),
+ "RULE_TYPE" TINYINT,
+ "SECURITY_STANDARDS" CHARACTER VARYING(4000),
+ "IS_AD_HOC" BOOLEAN NOT NULL,
+ "IS_EXTERNAL" BOOLEAN NOT NULL,
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT,
+ "TEMPLATE_UUID" CHARACTER VARYING(40),
+ "NOTE_DATA" CHARACTER LARGE OBJECT,
+ "NOTE_USER_UUID" CHARACTER VARYING(255),
+ "NOTE_CREATED_AT" BIGINT,
+ "NOTE_UPDATED_AT" BIGINT,
+ "REMEDIATION_FUNCTION" CHARACTER VARYING(20),
+ "REMEDIATION_GAP_MULT" CHARACTER VARYING(20),
+ "REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20),
+ "TAGS" CHARACTER VARYING(4000),
+ "AD_HOC_NAME" CHARACTER VARYING(200),
+ "AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT,
+ "AD_HOC_SEVERITY" CHARACTER VARYING(10),
+ "AD_HOC_TYPE" TINYINT
+);
+ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID");
+CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY" NULLS FIRST, "PLUGIN_NAME" NULLS FIRST);
+++ /dev/null
-CREATE TABLE "RULES"(
- "UUID" CHARACTER VARYING(40) NOT NULL,
- "NAME" CHARACTER VARYING(200),
- "PLUGIN_RULE_KEY" CHARACTER VARYING(200) NOT NULL,
- "PLUGIN_KEY" CHARACTER VARYING(200),
- "PLUGIN_CONFIG_KEY" CHARACTER VARYING(200),
- "PLUGIN_NAME" CHARACTER VARYING(255) NOT NULL,
- "SCOPE" CHARACTER VARYING(20) NOT NULL,
- "PRIORITY" INTEGER,
- "STATUS" CHARACTER VARYING(40),
- "LANGUAGE" CHARACTER VARYING(20),
- "DEF_REMEDIATION_FUNCTION" CHARACTER VARYING(20),
- "DEF_REMEDIATION_GAP_MULT" CHARACTER VARYING(20),
- "DEF_REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20),
- "GAP_DESCRIPTION" CHARACTER VARYING(4000),
- "SYSTEM_TAGS" CHARACTER VARYING(4000),
- "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL,
- "DESCRIPTION_FORMAT" CHARACTER VARYING(20),
- "RULE_TYPE" TINYINT,
- "SECURITY_STANDARDS" CHARACTER VARYING(4000),
- "IS_AD_HOC" BOOLEAN NOT NULL,
- "IS_EXTERNAL" BOOLEAN NOT NULL,
- "CREATED_AT" BIGINT,
- "UPDATED_AT" BIGINT,
- "TEMPLATE_UUID" CHARACTER VARYING(40),
- "NOTE_DATA" CHARACTER LARGE OBJECT,
- "NOTE_USER_UUID" CHARACTER VARYING(255),
- "NOTE_CREATED_AT" BIGINT,
- "NOTE_UPDATED_AT" BIGINT,
- "REMEDIATION_FUNCTION" CHARACTER VARYING(20),
- "REMEDIATION_GAP_MULT" CHARACTER VARYING(20),
- "REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20),
- "TAGS" CHARACTER VARYING(4000),
- "AD_HOC_NAME" CHARACTER VARYING(200),
- "AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT,
- "AD_HOC_SEVERITY" CHARACTER VARYING(10),
- "AD_HOC_TYPE" TINYINT
-);
-ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID");
-CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY" NULLS FIRST, "PLUGIN_NAME" NULLS FIRST);
.setIsAdHoc(false)
.setCreatedAt(system2.now())
.setUpdatedAt(system2.now())
- .setGenericConcepts(ruleDef.genericConceptKeys());
+ .setEducationPrinciples(ruleDef.educationPrincipleKeys());
if (isNotEmpty(ruleDef.htmlDescription())) {
ruleDto.setDescriptionFormat(Format.HTML);
boolean debtDefinitionsMerged = mergeDebtDefinitions(ruleDef, ruleDto);
boolean tagsMerged = mergeTags(ruleDef, ruleDto);
boolean securityStandardsMerged = mergeSecurityStandards(ruleDef, ruleDto);
- boolean genericConceptsMerged = mergeGenericConcepts(ruleDef, ruleDto);
- return ruleMerged || debtDefinitionsMerged || tagsMerged || securityStandardsMerged || genericConceptsMerged;
+ boolean educationPrinciplesMerged = mergeEducationPrinciples(ruleDef, ruleDto);
+ return ruleMerged || debtDefinitionsMerged || tagsMerged || securityStandardsMerged || educationPrinciplesMerged;
}
private boolean mergeRule(RulesDefinition.Rule def, RuleDto dto) {
return changed;
}
- private static boolean mergeGenericConcepts(RulesDefinition.Rule ruleDef, RuleDto dto) {
+ private static boolean mergeEducationPrinciples(RulesDefinition.Rule ruleDef, RuleDto dto) {
boolean changed = false;
- if (dto.getGenericConcepts().size() != ruleDef.genericConceptKeys().size() ||
- !dto.getGenericConcepts().containsAll(ruleDef.genericConceptKeys())) {
- dto.setGenericConcepts(ruleDef.genericConceptKeys());
+ if (dto.getEducationPrinciples().size() != ruleDef.educationPrincipleKeys().size() ||
+ !dto.getEducationPrinciples().containsAll(ruleDef.educationPrincipleKeys())) {
+ dto.setEducationPrinciples(ruleDef.educationPrincipleKeys());
changed = true;
}
return changed;
assertThat(rule.getType()).isEqualTo(RuleType.CODE_SMELL.getDbConstant());
assertThat(rule.getPluginKey()).isEqualTo(FAKE_PLUGIN_KEY);
assertThat(rule.isAdHoc()).isFalse();
- assertThat(rule.getGenericConcepts()).containsOnly("concept1", "concept2", "concept3");
+ assertThat(rule.getEducationPrinciples()).containsOnly("concept1", "concept2", "concept3");
}
@Test
assertThat(rule1.getType()).isEqualTo(RuleType.BUG.getDbConstant());
assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime());
assertThat(rule1.getUpdatedAt()).isEqualTo(DATE2.getTime());
- assertThat(rule1.getGenericConcepts()).containsOnly("concept1","concept4");
+ assertThat(rule1.getEducationPrinciples()).containsOnly("concept1","concept4");
}
@Test
.setType(RuleType.CODE_SMELL)
.setStatus(RuleStatus.BETA)
.setGapDescription("java.S115.effortToFix")
- .addGenericConceptKeys("concept1", "concept2", "concept3");
+ .addEducationPrincipleKeys("concept1", "concept2", "concept3");
rule1.setDebtRemediationFunction(rule1.debtRemediationFunctions().linearWithOffset("5d", "10h"));
rule1.createParam("param1").setDescription("parameter one").setDefaultValue("default1");
.setType(RuleType.BUG)
.setStatus(READY)
.setGapDescription("java.S115.effortToFix.v2")
- .addGenericConceptKeys("concept1", "concept4");
+ .addEducationPrincipleKeys("concept1", "concept4");
rule1.setDebtRemediationFunction(rule1.debtRemediationFunctions().linearWithOffset("6d", "2h"));
rule1.createParam("param1").setDescription("parameter one v2").setDefaultValue("default1 v2");
rule1.createParam("param2").setDescription("parameter two v2").setDefaultValue("default2 v2");
.setScope(RuleScope.ALL)
.setType(RuleType.CODE_SMELL)
.setStatus(RuleStatus.BETA)
- .addGenericConceptKeys("concept1", "concept2", "concept3");
+ .addEducationPrincipleKeys("concept1", "concept2", "concept3");
repo.createRule(EXTERNAL_HOTSPOT_RULE_KEY.rule())
.setName("Hotspot")
import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEFAULT_REM_FUNCTION;
import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEPRECATED_KEYS;
import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DESCRIPTION_SECTIONS;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_EDUCATION_PRINCIPLES;
import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_EFFORT_TO_FIX_DESCRIPTION;
import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_GAP_DESCRIPTION;
-import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_GENERIC_CONCEPTS;
import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_HTML_DESCRIPTION;
import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_INTERNAL_KEY;
import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_IS_EXTERNAL;
setAdHocSeverity(ruleResponse, ruleDto, fieldsToReturn);
setAdHocType(ruleResponse, ruleDto);
}
- setGenericConcepts(ruleResponse, ruleDto, fieldsToReturn);
+ setEducationPrinciples(ruleResponse, ruleDto, fieldsToReturn);
return ruleResponse;
}
}
}
- private static void setGenericConcepts(Rules.Rule.Builder ruleResponse, RuleDto ruleDto, Set<String> fieldsToReturn) {
- if (shouldReturnField(fieldsToReturn, FIELD_GENERIC_CONCEPTS)) {
- ruleResponse.getGenericConceptsBuilder().addAllGenericConcepts((ruleDto.getGenericConcepts()));
+ private static void setEducationPrinciples(Rules.Rule.Builder ruleResponse, RuleDto ruleDto, Set<String> fieldsToReturn) {
+ if (shouldReturnField(fieldsToReturn, FIELD_EDUCATION_PRINCIPLES)) {
+ ruleResponse.getEducationPrinciplesBuilder().addAllEducationPrinciples((ruleDto.getEducationPrinciples()));
}
}
public static final String FIELD_MARKDOWN_DESCRIPTION = "mdDesc";
public static final String FIELD_DESCRIPTION_SECTIONS = "descriptionSections";
- public static final String FIELD_GENERIC_CONCEPTS = "genericConcepts";
+ public static final String FIELD_EDUCATION_PRINCIPLES = "educationPrinciples";
public static final String FIELD_NOTE_LOGIN = "noteLogin";
public static final String FIELD_MARKDOWN_NOTE = "mdNote";
public static final String FIELD_HTML_NOTE = "htmlNote";
FIELD_MARKDOWN_DESCRIPTION, FIELD_DESCRIPTION_SECTIONS, FIELD_NOTE_LOGIN, FIELD_MARKDOWN_NOTE, FIELD_HTML_NOTE,
FIELD_DEFAULT_DEBT_REM_FUNCTION, FIELD_EFFORT_TO_FIX_DESCRIPTION, FIELD_DEBT_OVERLOADED, FIELD_DEBT_REM_FUNCTION,
FIELD_DEFAULT_REM_FUNCTION, FIELD_GAP_DESCRIPTION, FIELD_REM_FUNCTION_OVERLOADED, FIELD_REM_FUNCTION,
- FIELD_PARAMS, FIELD_ACTIVES, FIELD_SCOPE, FIELD_DEPRECATED_KEYS, FIELD_GENERIC_CONCEPTS);
+ FIELD_PARAMS, FIELD_ACTIVES, FIELD_SCOPE, FIELD_DEPRECATED_KEYS, FIELD_EDUCATION_PRINCIPLES);
private RulesWsParameters() {
// prevent instantiation
new Change("9.5", "The field 'descriptionSections' has been added to the payload"),
new Change("9.5", "The field 'descriptionSections' has been added to the 'f' parameter"),
new Change("9.6", "'descriptionSections' can optionally embed a context field"),
- new Change("9.6", "The field 'genericConcepts' has been added to the 'f' parameter")
+ new Change("9.6", "The field 'educationPrinciples' has been added to the 'f' parameter")
);
action.createParam(FACETS)
new Change("9.5", "The field 'descriptionSections' has been added to the payload"),
new Change("9.5", "The field 'descriptionSections' has been added to the 'f' parameter"),
new Change("9.6", "'descriptionSections' can optionally embed a context field"),
- new Change("9.6", "'genericConcepts' has been added")
+ new Change("9.6", "'educationPrinciples' has been added")
);
action
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.server.user.ws.DismissNoticeAction.GENERIC_CONCEPTS;
+import static org.sonar.server.user.ws.DismissNoticeAction.EDUCATION_PRINCIPLES;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.Users.CurrentWsResponse.HomepageType.APPLICATION;
import static org.sonarqube.ws.Users.CurrentWsResponse.HomepageType.PORTFOLIO;
.setHomepage(buildHomepage(dbSession, user))
.setUsingSonarLintConnectedMode(user.getLastSonarlintConnectionDate() != null)
.setSonarLintAdSeen(user.isSonarlintAdSeen())
- .putDismissedNotices(GENERIC_CONCEPTS, isNoticeDismissed(user, GENERIC_CONCEPTS));
+ .putDismissedNotices(EDUCATION_PRINCIPLES, isNoticeDismissed(user, EDUCATION_PRINCIPLES));
ofNullable(emptyToNull(user.getEmail())).ifPresent(builder::setEmail);
ofNullable(emptyToNull(user.getEmail())).ifPresent(u -> builder.setAvatar(avatarResolver.create(user)));
ofNullable(user.getExternalLogin()).ifPresent(builder::setExternalIdentity);
public class DismissNoticeAction implements UsersWsAction {
- public static final String GENERIC_CONCEPTS = "genericConcepts";
+ public static final String EDUCATION_PRINCIPLES = "educationPrinciples";
public static final String USER_DISMISS_CONSTANT = "user.dismissedNotices.";
private final UserSession userSession;
action.createParam("notice")
.setDescription("notice key to dismiss")
- .setExampleValue(GENERIC_CONCEPTS)
- .setPossibleValues(GENERIC_CONCEPTS);
+ .setExampleValue(EDUCATION_PRINCIPLES)
+ .setPossibleValues(EDUCATION_PRINCIPLES);
}
@Override
indexRules();
Rules.SearchResponse response = ws.newRequest()
- .setParam(WebService.Param.FIELDS, "createdAt,langName,genericConcepts")
+ .setParam(WebService.Param.FIELDS, "createdAt,langName,educationPrinciples")
.executeProtobuf(Rules.SearchResponse.class);
Rules.Rule result = response.getRules(0);
// selected fields
assertThat(result.getCreatedAt()).isNotEmpty();
assertThat(result.getLangName()).isNotEmpty();
- assertThat(result.getGenericConcepts().getGenericConceptsList()).containsExactlyElementsOf(rule.getGenericConcepts());
+ assertThat(result.getEducationPrinciples().getEducationPrinciplesList()).containsExactlyElementsOf(rule.getEducationPrinciples());
// not returned fields
assertThat(result.hasEffortToFixDescription()).isFalse();
assertThat(resultRule.getParams().getParamsList())
.extracting(Rule.Param::getKey, Rule.Param::getHtmlDesc, Rule.Param::getDefaultValue)
.containsExactlyInAnyOrder(tuple(ruleParam.getName(), ruleParam.getDescription(), ruleParam.getDefaultValue()));
- assertThat(resultRule.getGenericConcepts().getGenericConceptsList()).containsExactlyElementsOf(rule.getGenericConcepts());
+ assertThat(resultRule.getEducationPrinciples().getEducationPrinciplesList()).containsExactlyElementsOf(rule.getEducationPrinciples());
}
@Test
}
@Test
- public void return_generic_concepts_seen() {
+ public void return_educationPrinciples_dismiss_notice() {
UserDto user = db.users().insertUser();
userSession.logIn(user);
- PropertyDto property = new PropertyDto().setUserUuid(user.getUuid()).setKey("user.dismissedNotices.genericConcepts");
+ PropertyDto property = new PropertyDto().setUserUuid(user.getUuid()).setKey("user.dismissedNotices.educationPrinciples");
db.properties().insertProperties(userSession.getLogin(), null, null, null, property);
CurrentWsResponse response = call();
assertThat(response.getDismissedNoticesMap().entrySet())
.extracting(Map.Entry::getKey, Map.Entry::getValue)
- .contains(Tuple.tuple("genericConcepts", true));
+ .contains(Tuple.tuple("educationPrinciples", true));
}
@Test
- public void return_generic_concepts_not_seen() {
+ public void return_educationPrinciples_not_dismissed() {
UserDto user = db.users().insertUser();
userSession.logIn(user);
assertThat(response.getDismissedNoticesMap().entrySet())
.extracting(Map.Entry::getKey, Map.Entry::getValue)
- .contains(Tuple.tuple("genericConcepts", false));
+ .contains(Tuple.tuple("educationPrinciples", false));
}
@Test
private final WsActionTester tester = new WsActionTester(new DismissNoticeAction(userSessionRule, db.getDbClient()));
@Test
- public void dismiss_genericConcepts() {
+ public void dismiss_educationPrinciples() {
userSessionRule.logIn();
TestResponse testResponse = tester.newRequest()
- .setParam("notice", "genericConcepts")
+ .setParam("notice", "educationPrinciples")
.execute();
assertThat(testResponse.getStatus()).isEqualTo(204);
- Optional<PropertyDto> propertyDto = db.properties().findFirstUserProperty(userSessionRule.getUuid(), "user.dismissedNotices.genericConcepts");
+ Optional<PropertyDto> propertyDto = db.properties().findFirstUserProperty(userSessionRule.getUuid(), "user.dismissedNotices.educationPrinciples");
assertThat(propertyDto).isPresent();
}
assertThatThrownBy(testRequest::execute)
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Value of parameter 'notice' (not_supported_value) must be one of: [genericConcepts]");
+ .hasMessage("Value of parameter 'notice' (not_supported_value) must be one of: [educationPrinciples]");
}
@Test
public void notice_already_exist() {
userSessionRule.logIn();
- PropertyDto property = new PropertyDto().setKey("user.dismissedNotices.genericConcepts").setUserUuid(userSessionRule.getUuid());
+ PropertyDto property = new PropertyDto().setKey("user.dismissedNotices.educationPrinciples").setUserUuid(userSessionRule.getUuid());
db.properties().insertProperties(userSessionRule.getLogin(), null, null, null, property);
TestRequest testRequest = tester.newRequest()
- .setParam("notice", "genericConcepts");
+ .setParam("notice", "educationPrinciples");
assertThatThrownBy(testRequest::execute)
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Notice genericConcepts is already dismissed");
+ .hasMessage("Notice educationPrinciples is already dismissed");
}
optional bool isExternal = 47;
optional DeprecatedKeys deprecatedKeys = 48;
optional DescriptionSections descriptionSections = 49;
- optional GenericConcepts genericConcepts = 50;
+ optional EducationPrinciples educationPrinciples = 50;
message DescriptionSections {
repeated DescriptionSection descriptionSections = 1;
repeated string tags = 1;
}
-message GenericConcepts {
- repeated string genericConcepts = 1;
+message EducationPrinciples {
+ repeated string educationPrinciples = 1;
}
message Actives {