Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review Rulesets and add first party Detekt extensions #5548

Merged
merged 20 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Visit [the project website](https://detekt.dev/) for installation guides, rule d
- [Changelog and migration guides](https://detekt.dev/changelog.html)
- [Available CLI options](https://detekt.dev/cli.html)
- [Rule set and rule descriptions](https://detekt.dev/complexity.html)
- [Writing custom rules and extending detekt](https://detekt.dev/extensions.html)
- [Writing custom rules and extending detekt](https://detekt.dev/docs/introduction/extensions/)
- [Suppressing issues in code](https://detekt.dev/suppressing-rules.html)
- [Suppressing issues via baseline file](https://detekt.dev/baseline.html)
- [Configuring detekt](https://detekt.dev/configurations.html)
Expand Down Expand Up @@ -125,17 +125,24 @@ dependencies {
}
```

Likewise custom [extensions](https://detekt.dev/extensions.html) can be added to detekt.
Similarly, there are extra rule sets available for Detekt from Detekt:
```kotlin
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-libraries:[version]")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-ruleauthors:[version]")
}
```
For more info visit the [Detekt Marketplace](https://detekt.dev/marketplace).

Likewise custom [extensions](https://detekt.dev/docs/introduction/extensions/) can be added to detekt.

### Contributing

See [CONTRIBUTING](.github/CONTRIBUTING.md)

Thanks to all the people who contributed to detekt!

<a href="https://github.com/detekt/detekt/graphs/contributors">
<img src="https://contrib.rocks/image?repo=detekt/detekt" />
</a>
[![Profile images of all the contributors](https://contrib.rocks/image?repo=detekt/detekt)](https://github.com/detekt/detekt/graphs/contributors)

### Mentions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import io.gitlab.arturbosch.detekt.api.internal.ruleSetConfig
* This rule set provides wrappers for rules implemented by ktlint - https://ktlint.github.io/.
*
* Note: Issues reported by this rule set can only be suppressed on file level (`@file:Suppress("detekt.rule")`).
* Note: The formatting rule set is not included in the detekt-cli or gradle plugin.
* Note: The `formatting` rule set is not included in the detekt-cli or Gradle plugin.
*
* To enable this rule set, add `detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:$version"`
* to your gradle dependencies or reference the `detekt-formatting`-jar with the `--plugins` option
* to your gradle `dependencies` or reference the `detekt-formatting`-jar with the `--plugins` option
* in the command line interface.
*/
@ActiveByDefault(since = "1.0.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import io.gitlab.arturbosch.detekt.api.internal.ActiveByDefault

/**
* Rules in this rule set report issues related to libraries API exposure.
*
* Note: The `libraries` rule set is not included in the detekt-cli or Gradle plugin.
*
* To enable this rule set, add `detektPlugins "io.gitlab.arturbosch.detekt:detekt-rules-libraries:$version"`
* to your Gradle `dependencies` or reference the `detekt-rules-libraries`-jar with the `--plugins` option
* in the command line interface.
*/
@ActiveByDefault("1.16.0")
class RuleLibrariesProvider : RuleSetProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import io.gitlab.arturbosch.detekt.api.RuleSetProvider
import io.gitlab.arturbosch.detekt.api.internal.ActiveByDefault

/**
* The rule authors ruleset provides rules that ensures good practices when writing detekt rules
* The rule authors ruleset provides rules that ensures good practices when writing detekt rules.
*
* Note: The `ruleauthors` rule set is not included in the detekt-cli or Gradle plugin.
*
* To enable this rule set, add `detektPlugins "io.gitlab.arturbosch.detekt:detekt-rules-ruleauthors:$version"`
* to your Gradle `dependencies` or reference the `detekt-rules-ruleauthors`-jar with the `--plugins` option
* in the command line interface.
*/
@ActiveByDefault("1.22.0")
class RuleAuthorsProvider : RuleSetProvider {
Expand Down
136 changes: 134 additions & 2 deletions website/src/data/marketplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,39 @@ export const tagTypes = {
ruleset: {
color: "#39ca30",
description: "A collection of custom rules for Detekt",
communityUrls: [
"https://github.com/topics/detekt-rules",
"https://github.com/search?q=%22io.gitlab.arturbosch.detekt.api.RuleSetProvider%22+-org%3Adetekt&type=code",
cortinico marked this conversation as resolved.
Show resolved Hide resolved
],
},
processor: {
color: "#e9669e",
description: "A custom processor for Detekt",
communityUrls: [
"https://github.com/search?q=%22io.gitlab.arturbosch.detekt.api.FileProcessListener%22+-org%3Adetekt&type=code",
],
},
reporter: {
color: "#fe6829",
description: "A custom reporter for Detekt",
communityUrls: [
"https://github.com/search?q=%22io.gitlab.arturbosch.detekt.api.OutputReport%22+-org%3Adetekt&type=code",
"https://github.com/search?q=%22io.gitlab.arturbosch.detekt.api.ConsoleReport%22+-org%3Adetekt&type=code",
],
},
configvalidator: {
color: "#53dbb7",
description: "A custom config validator for Detekt",
communityUrls: [
"https://github.com/search?q=%22io.gitlab.arturbosch.detekt.api.ConfigValidator%22+-org%3Adetekt&type=code",
],
},
plugin: {
color: "#a44fb7",
description: "A plugin or a tool built on top of Detekt",
communityUrls: [
"https://github.com/topics/detekt-plugin"
],
},
};

Expand All @@ -61,12 +82,15 @@ export const extensions = [
ruleset: "compose",
rules: [
"ComposableEventParameterNaming",
"ComposableParametersOrdering",
"ComposeFunctionName",
"MissingModifierDefaultValue",
"ModifierDefaultValue",
"ModifierHeightWithText",
"ModifierParameterPosition",
"PublicComposablePreview",
"ReusedModifierInstance",
"TopLevelComposableFunctions",
"UnnecessaryEventHandlerParameter",
],
usesTypeResolution: false,
Expand All @@ -77,25 +101,59 @@ export const extensions = [
description:
"Static checks to aid with a healthy adoption of Jetpack Compose.",
repo: "https://github.com/twitter/compose-rules/",
docs: "https://twitter.github.io/compose-rules/",
ruleset: "TwitterCompose",
rules: [
"ComposableNaming",
"ComposableParamOrder",
"CompositionLocalAllowlist",
"CompositionLocalNaming",
"ContentEmitterReturningValues",
"ModifierComposable",
"ModifierMissing",
"ModifierReused",
"ModifierWithoutDefault",
"MultipleEmitters",
"MutableParams",
"PreviewNaming",
"PreviewPublic",
"RememberMissing",
"UnstableCollections",
"ViewModelForwarding",
"ViewModelInjection",
],
usesTypeResolution: false,
tags: ["ruleset"],
},
{
title: "Detekt rules for Library Authors",
description:
"Rules in this rule set report issues related to libraries API exposure.",
repo: "https://github.com/detekt/detekt",
docs: "https://detekt.dev/docs/next/rules/libraries",
tags: ["ruleset"],
ruleset: "libraries",
rules: [
"ForbiddenPublicDataClass",
"LibraryCodeMustSpecifyReturnType",
"LibraryEntitiesShouldNotBePublic",
],
usesTypeResolution: true,
},
{
title: "Detekt rules for Detekt Rule Authors",
description:
"The rule authors ruleset provides rules that ensures good practices when writing detekt rules.",
repo: "https://github.com/detekt/detekt",
docs: "https://detekt.dev/docs/next/rules/ruleauthors",
tags: ["ruleset"],
ruleset: "ruleauthors",
rules: [
"UseEntityAtName",
"ViolatesTypeResolutionRequirements",
],
usesTypeResolution: true,
},
{
title: "Doist detekt-rules",
description:
Expand All @@ -113,6 +171,79 @@ export const extensions = [
usesTypeResolution: false,
tags: ["ruleset"],
},
{
title: "ktlint",
description:
"This rule set provides wrappers for rules implemented by ktlint.",
repo: "https://github.com/detekt/detekt",
docs: "https://detekt.dev/docs/next/rules/formatting",
tags: ["ruleset"],
ruleset: "formatting",
rules: [
"AnnotationOnSeparateLine",
"AnnotationSpacing",
"ArgumentListWrapping",
"BlockCommentInitialStarAlignment",
"ChainWrapping",
"CommentSpacing",
"CommentWrapping",
"DiscouragedCommentLocation",
"EnumEntryNameCase",
"Filename",
"FinalNewline",
"FunKeywordSpacing",
"FunctionReturnTypeSpacing",
"FunctionSignature",
"FunctionStartOfBodySpacing",
"FunctionTypeReferenceSpacing",
"ImportOrdering",
"Indentation",
"KdocWrapping",
"MaximumLineLength",
"ModifierListSpacing",
"ModifierOrdering",
"MultiLineIfElse",
"NoBlankLineBeforeRbrace",
"NoBlankLinesInChainedMethodCalls",
"NoConsecutiveBlankLines",
"NoEmptyClassBody",
"NoEmptyFirstLineInMethodBlock",
"NoLineBreakAfterElse",
"NoLineBreakBeforeAssignment",
"NoMultipleSpaces",
"NoSemicolons",
"NoTrailingSpaces",
"NoUnitReturn",
"NoUnusedImports",
"NoWildcardImports",
"NullableTypeSpacing",
"PackageName",
"ParameterListSpacing",
"ParameterListWrapping",
"SpacingAroundAngleBrackets",
"SpacingAroundColon",
"SpacingAroundComma",
"SpacingAroundCurly",
"SpacingAroundDot",
"SpacingAroundDoubleColon",
"SpacingAroundKeyword",
"SpacingAroundOperators",
"SpacingAroundParens",
"SpacingAroundRangeOperator",
"SpacingAroundUnaryOperator",
"SpacingBetweenDeclarationsWithAnnotations",
"SpacingBetweenDeclarationsWithComments",
"SpacingBetweenFunctionNameAndOpeningParenthesis",
"StringTemplate",
"TrailingCommaOnCallSite",
"TrailingCommaOnDeclarationSite",
"TypeArgumentListSpacing",
"TypeParameterListSpacing",
"UnnecessaryParenthesesBeforeTrailingLambda",
"Wrapping",
],
usesTypeResolution: false,
},
{
title: "Kure",
description:
Expand All @@ -139,6 +270,7 @@ export const extensions = [
description:
"A ruleset to implement detection of violation of programming principles. detekt-hint offers also instructions on how to integrate with Danger and Github Actions",
repo: "https://github.com/mkohm/detekt-hint",
docs: "https://mkohm.github.io/detekt-hint/",
tags: ["plugin", "ruleset"],
ruleset: "detekt-hint",
rules: [
Expand Down Expand Up @@ -186,7 +318,7 @@ export const extensions = [
tags: ["ruleset"],
},
/*
Pro Tip: add your ruleset in alphabetical order.
Appending your ruleset here (at the end) is more likely to produce Git conflicts.
* Pro Tip: add your ruleset in alphabetical order.
* Appending your ruleset here (at the end) is more likely to produce Git conflicts.
*/
];
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function MarketplaceCard(input) {
</Link>
</div>
<div className={styles.marketplaceCardBody}>
<Link href={extension.repo}>{extension.repo}</Link>
<Link href={extension.docs ?? extension.repo}>{extension.docs ?? extension.repo}</Link>
<p>{extension.description}</p>
{extension.rules && (
<p>
Expand All @@ -38,7 +38,7 @@ function MarketplaceCard(input) {
Uses type resolution:{" "}
<strong>{extension.usesTypeResolution.toString()}</strong>
</p>
<p>
<p className={styles.marketplaceCardRules}>
<ul>
{extension.rules.map((rule) => (
<li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@
line-height: 1.66;
}

.marketplaceCardRules {
max-height: 300px;
overflow-y: scroll;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before After
image image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with overflow-y: auto I get this in some cases
image
what's wrong here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok with glitchy scrollbars? It might be a Chrome bug, or just me not knowing the whole CSS structure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, probably not worth blocking on this :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker for sure :)

}

.tagContainer {
display: flex;
flex-wrap: wrap;
list-style: none;
}
}