4341 Commits

Author SHA1 Message Date
Nicola Corti
74d3b6f1e3 Move the website to detekt.dev (#4544) 2022-02-04 00:50:26 +00:00
Raman Gupta
c854a2ec1f Make DoubleMutabilityForCollection configurable and set a DoubleMutability alias (#4541)
* Configurable double mutability rule

Resolves #4501

* Update default config

* Additional tests via factory and calculation functions

* Add property delegation double mutability negative tests

* Fix import order in dbl mutability test

* Fix code snippet compilation
2022-02-01 23:50:04 +01:00
marschwar
c34f5faec1 Migrate tests in detekt-rules-errorprone to junit (#4523)
* Migrate tests in detekt-rules-errorprone to junit

* change names of classes and function that may be a problem on windows

* WIP: remove test class that is causing issues

* re-add IgnoredReturnValueSpec.kt

* Fix merge

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-02-01 07:24:31 +01:00
M Schalk
fb1b6041b3 Fix performance issue for regexp in Reporting.kt (#4550)
A regexp object is compiled into an internal data structure during initialization.
This could to a potential performance impact, if the `Regex()` constructor is called multiple times for the same pattern.
Since the private function `truncatedMessage()` could be called a lot, this PR fixes this potential performance issue.

Because of the overhead of object instantiation and regular expression compilation, reusing the initialized object is the recommended way.
2022-01-31 23:25:18 +01:00
Brais Gabín
1fbe3b83d6 Revert "trim values when parsing the baseline (#4335)" (#4548) 2022-01-31 20:44:01 +00:00
Gabriel Freitas Vasconcelos
0b36ff0ea9 Adds issue details to findings on FindingsReport and FileBasedFindingsReporter (#4464)
* Changes FindingsReporter detail level

Achieved different levels of detailing by changing the format in the
implementation of compact() method for CodeSmell and
ThresholdedCodeSmell.

* Updates docs with reporting changes

* Adapts tests to findings reporter changes

* Creates extension method for console report

Reverts changes to `CodeSmell::compact` method to keep other reports
untouched.

* Truncates long messages for console reports

Prevents line breaks and long messages from breaking report structure
2022-01-31 13:02:31 +01:00
Brais Gabín
2d00cab368 Fix AnnotationExcluder (#4518)
* Implement FullQualifiedNameGuesser

* Remove bad test

* Refactor tests

* Fix AnnotationExcluder

* More exhaustive list of default import classes

* Handle PR comments
2022-01-31 10:19:08 +01:00
marschwar
1ca3ab586e Fix error during snippet compilation (#4536) 2022-01-30 23:07:50 +01:00
Goooler
10e9e4c60d Code cleanups (#4542) 2022-01-30 17:12:03 +00:00
marschwar
a6a26142c5 [MaxLineLength] Fix signature in for blank characters in the Baseline (#4504) 2022-01-30 13:36:33 +00:00
marschwar
5176e41200 Fix MaxLineLength violation in IgnoredReturnValue rule (#4539)
Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-29 00:38:13 +01:00
Artem Zinnatullin :slowpoke
90ae9ecb07 Add list of functions to skip in IgnoredReturnValue rule (#4434)
* Add list of functions to skip in IgnoredReturnValue rule

* Fix formatting

* Regenerate default detekt config

* Switch to FunctionMatcher, rename property to ignoreFunctionCall

* Update test

* style

* Damn it IJ

* remove testing version

* Update detekt-rules-errorprone/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValue.kt

Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>

Co-authored-by: Brais Gabín <braisgabin@gmail.com>
Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>
2022-01-28 17:43:48 +01:00
severn-everett
8a39d2a172 [VarCouldBeVal] Override vars will not be flagged if bindingContext is not set (#4477) 2022-01-28 01:36:39 +00:00
Brais Gabín
d0732ab2fd Add how to exclude source files from BaselineTask (#4490) 2022-01-28 01:33:26 +00:00
Matthew Haughton
58e95e6402 Re-enable warnings as errors (#4533)
* Suppress version warnings

Disables these warnings:
* Experimental language version being used (e.g. Kotlin compiler is 1.6,
  but language version 1.7 was specified)
* Deprecated or unsupported lanuage/API version is used (e.g. Kotlin
  compiler is 1.6, deprecated language version 1.4 is specified)
* Misconfiguration of `-progressive` flag, which only makes sense if latest
  supported language version is being used

https://github.com/JetBrains/kotlin/blob/v1.6.10/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt#L562-L568

* Re-enable failure when compiler warnings found

Applies to all modules except detekt-gradle-plugin, see
https://github.com/detekt/detekt/pull/3835

* Don't manually specify language version

This should instead automatically track the language version used by the
compiler, as source compatibility is not a requirement for detekt.

This also avoids potential misconfiguration that will no longer be
identified by use of `-Xsuppress-version-warnings`.

* Fix warnings
2022-01-27 23:42:05 +01:00
renovate[bot]
f18644db92 Update dependency com.android.tools.build:gradle to v7.1.0 (#4530)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-01-27 23:41:20 +01:00
Goooler
e1dc93ed1d Disable deployment jobs in forked repository (#4528)
* Disable deploy-website job in forked repository

* Check repo on deploy-snapshot job
2022-01-26 08:45:52 +01:00
marschwar
3c12be91f2 Migrate tests in detekt-api to junit (#4521)
* migrate tests in detekt-api to junit

* remove spek from build dependencies

* change class names that are invalid on windows

* fix HasPlatformType violation

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-25 21:36:20 +01:00
Matthew Haughton
291590bc4e Use Java 17 for all CI jobs (#4526) 2022-01-26 07:31:07 +11:00
Matthew Haughton
77204be660 Migrate detekt-tooling tests to JUnit 5 (#4524) 2022-01-26 00:56:20 +11:00
Matthew Haughton
a236d80919 Migrate detekt-sample-extensions tests to JUnit (#4525) 2022-01-26 00:55:52 +11:00
Brais Gabín
c536107feb Use the new configure config for formatting (#4352)
* Improve

* Don't include formatting config inside default-detekt-config.yml

* Extract code from ConfigPrinter

* Create config file for detekt-formatting
2022-01-25 14:55:42 +01:00
marschwar
4a0076f164 Migrate tests in detekt-rules-empty to junit (#4522) 2022-01-26 00:19:43 +11:00
Brais Gabín
576ae5f540 Match functions signatures with lambdas on it (#4458)
* Match functions signatures with lambdas on it

* Improve code
2022-01-25 09:41:04 +01:00
marschwar
3c9f0e98c7 Migrate tests in detekt-cli to junit (#4519) 2022-01-24 20:12:26 +01:00
marschwar
743706fb45 Clean up gradle files for modules migrated to junit (#4516)
Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-24 09:21:24 +01:00
marschwar
67ba876bb0 Migrate detekt-psi-utils to junit (#4515)
Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-24 09:17:10 +01:00
Matthew Haughton
c74d714f6b Migrate detekt-rules tests to JUnit (#4514) 2022-01-23 22:09:33 -08:00
marschwar
ad270ef4f1 migrate tests in detekt-parser to junit (#4512)
Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-24 09:43:46 +11:00
marschwar
f997fe0ef5 Migrate tests in detekt-report-xxx to junit (#4513)
* migrate tests in detekt-report-html to junit

* migrate tests in detekt-report-txt to junit

* migrate tests in detekt-report-sarif to junit

* migrate tests in detekt-report-xml to junit

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-24 09:30:24 +11:00
marschwar
a1823e6b09 Migrate tests in detekt-metrics to junit (#4511)
* migrate tests in detekt-metrics to junit

* fix compiler warning about possible problems on windows

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-23 22:48:02 +01:00
marschwar
50352f7e8b migrate tests in detekt-formatting to junit (#4508)
* migrate tests in detekt-formatting to junit

* remove internal modifier

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-23 12:26:57 -08:00
marschwar
d5c1708d7e migrate tests in detekt-core to junit (#4507)
* migrate tests in detekt-core to junit

* remove internal modifier

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-23 11:36:33 -08:00
Brais Gabín
a6c84354e6 Improve AnnotationExcluder tests (#4368)
* Add missing deprecation

* Simplify AnnotationExcluder

* Improve tests making them more exhaustive

* Handle the globbing inside AnnotationExcluder

* Update detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/AnnotationExcluder.kt

Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>

Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>
2022-01-23 10:47:23 -08:00
Chao Zhang
ca9a3fa0bb Fix false positive of UnnecessaryInnerClass (#4509)
* Fix false positive of UnncessaryInnerClass

* Exclude Nested annotation because junit test requires @Nested test class to be inner

* Fix test code snippet
2022-01-23 10:17:44 -08:00
marschwar
8a69676534 Introduce DefaultValue type (#3928)
* Introduce DefaultValue type

* reuse createDefaultValueIfLiteral in RuleSetProviderCollector.kt

* use DefaultValue.of() explicitly

* default getAsPlainString to toString

* rename ListDefault to StringListDefault

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-22 21:45:19 -08:00
severn-everett
31520dadf2 Added rule UnnecessaryInnerClass (#4394)
* Added rule UnnecessaryInnerClass

* Addressed Detekt issues; Added test case

* Removed unnecessary code

* Addressing PR comment

* Enabled rule for self-tests on the Detekt library

* Fixing inner class issue in CognitiveComplexity

* Updated code comment
2022-01-22 17:53:01 -08:00
Brais Gabín
69ffb05612 Remove old false-positive from baseline (#4286)
Co-authored-by: Chao Zhang <chao.zhang@instacart.com>
2022-01-22 10:38:35 +01:00
Matthew Haughton
9471385e0b Update JUnit dependencies (#4505)
* Use consistent JUnit version in all project configurations

* Remove explicit junit-params dependency

This is already added as a dependency by useJunitJupiter()

* Remove unused Spek dependencies from projects migrated to JUnit
2022-01-22 17:30:48 +11:00
Matthew Haughton
2f7a925a59 Drop unused dependencies (#4506)
* Remove unused dependencies

* Use more specific dependency where possible

* Use more specific configuration where possible
2022-01-22 17:29:40 +11:00
marschwar
6d1517ad33 Transform tests in detekt-generator to junit (#4494)
* transform tests to junit

* Ignore ClassNaming rule for test classes

* Fix UnnecessaryLet violation

* rename all test classes back to xxxSpec

* remove internal modifier from test class

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2022-01-21 09:57:01 +01:00
renovate[bot]
259c9de1ab Update plugin pluginPublishing to v0.20.0 (#4502)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-01-20 08:12:41 +11:00
Vasily Maleev
bf698f01de Fix overridden function reporting for CanBeNonNullable rule (#4497) 2022-01-19 11:02:13 +01:00
Brais Gabín
c965a8d2a6 Parse Baseline in a secure way (#4499) 2022-01-18 18:21:06 +01:00
Chao Zhang
08eac68caa Upgrade AGP to 7 (#4133)
* Upgrade AGP to 7.0.4

* Run Android tests on JDK 11 and above only

* Skip Android report merging test if Android requirements unmet

* Update skip reason

Co-authored-by: Matthew Haughton <3flex@users.noreply.github.com>
2022-01-16 08:33:15 +11:00
Matthew Haughton
a627da97c9 Migrate custom-checks tests to JUnit 5 (#4467)
* Setup JUnit 5

* Migrate custom-checks tests to JUnit

* Set the default JUnit 5 test instance lifecycle mode to "per_class"

* Use extension instead of base class to inject KotlinCoreEnvironment

Co-authored-by: marschwar <marschwar@users.noreply.github.com>

* Update contributor guidelines to reflect usage of JUnit 5

* Fix style issues

* Update detekt-test-utils API definition

* Update .github/CONTRIBUTING.md

Co-authored-by: marschwar <marschwar@users.noreply.github.com>
Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>
2022-01-16 08:32:21 +11:00
Brais Gabín
116b2a1b10 Set the name of functions and paramenters between ` to improve the readability (#4488) 2022-01-15 12:41:39 +11:00
Brais Gabín
bd525fb990 Fix issue raised by detekt (#4491) 2022-01-13 19:42:21 -08:00
severn-everett
27205a13f8 Extend CanBeNonNullable rule to check function params (#4431) 2022-01-12 09:54:37 +00:00
Gabriel Freitas Vasconcelos
56e7fa94a4 Fixes test for LiteFindingsReport (#4479) 2022-01-11 13:19:39 +00:00