-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLUGINAPI-56 PLUGINAPI-57 Add Clean Code Attribute to plugin-api
- Loading branch information
1 parent
4baf8f9
commit 1fdce7a
Showing
14 changed files
with
204 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
plugin-api/src/main/java/org/sonar/api/rules/CleanCodeAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Sonar Plugin API | ||
* Copyright (C) 2009-2023 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.api.rules; | ||
|
||
import static org.sonar.api.rules.CleanCodeAttributeCategory.ADAPTABLE; | ||
import static org.sonar.api.rules.CleanCodeAttributeCategory.CONSISTENT; | ||
import static org.sonar.api.rules.CleanCodeAttributeCategory.INTENTIONAL; | ||
import static org.sonar.api.rules.CleanCodeAttributeCategory.RESPONSIBLE; | ||
|
||
public enum CleanCodeAttribute { | ||
CONVENTIONAL(CONSISTENT), | ||
FORMATTED(CONSISTENT), | ||
IDENTIFIABLE(CONSISTENT), | ||
|
||
CLEAR(INTENTIONAL), | ||
COMPLETE(INTENTIONAL), | ||
EFFICIENT(INTENTIONAL), | ||
LOGICAL(INTENTIONAL), | ||
|
||
DISTINCT(ADAPTABLE), | ||
FOCUSED(ADAPTABLE), | ||
MODULAR(ADAPTABLE), | ||
TESTED(ADAPTABLE), | ||
|
||
LAWFUL(RESPONSIBLE), | ||
RESPECTFUL(RESPONSIBLE), | ||
TRUSTWORTHY(RESPONSIBLE); | ||
|
||
private final CleanCodeAttributeCategory attributeCategory; | ||
|
||
CleanCodeAttribute(CleanCodeAttributeCategory attributeCategory) { | ||
|
||
this.attributeCategory = attributeCategory; | ||
} | ||
|
||
public CleanCodeAttributeCategory getAttributeCategory() { | ||
return attributeCategory; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
plugin-api/src/main/java/org/sonar/api/rules/CleanCodeAttributeCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Sonar Plugin API | ||
* Copyright (C) 2009-2023 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.api.rules; | ||
|
||
public enum CleanCodeAttributeCategory { | ||
ADAPTABLE, | ||
CONSISTENT, | ||
INTENTIONAL, | ||
RESPONSIBLE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
plugin-api/src/test/java/org/sonar/api/rules/CleanCodeAttributeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Sonar Plugin API | ||
* Copyright (C) 2009-2023 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.api.rules; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
public class CleanCodeAttributeTest { | ||
|
||
@Test | ||
public void values_shouldNotBeEmpty() { | ||
CleanCodeAttribute[] values = CleanCodeAttribute.values(); | ||
|
||
assertThat(values).isNotEmpty(); | ||
} | ||
|
||
@Test | ||
public void getAttributeCategory_shouldReturnExpectedCategory() { | ||
assertThat(CleanCodeAttribute.COMPLETE.getAttributeCategory()).isEqualTo(CleanCodeAttributeCategory.INTENTIONAL); | ||
assertThat(CleanCodeAttribute.CONVENTIONAL.getAttributeCategory()).isEqualTo(CleanCodeAttributeCategory.CONSISTENT); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters