71 Commits

Author SHA1 Message Date
Matthew Haughton
1258c2fe82 Add dependency-analysis plugin and implement some recommendations (#4798)
Co-authored-by: schalkms <30376729+schalkms@users.noreply.github.com>
2022-06-02 13:19:44 +01:00
Matthew Haughton
a236d80919 Migrate detekt-sample-extensions tests to JUnit (#4525) 2022-01-26 00:55:52 +11:00
Brais Gabín
fc51b53879 Don't exclude the naming rules by default for tests (#4438)
* Improve code

* Allow camelCase in TopLevelPropertyNaming.constantPattern

* In general all the naming conventions apply too for test code
2022-01-03 22:19:28 +01:00
Brais Gabín
a7184d11a3 Allow plugins to contribute to the default configuration (#4315)
* Add missing tests

* Remove deprecated code

* Get Spec in DefaultConfigProvider

* Remove DefaultConfig

* Concat configurations

* Apply suggestions from code review

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>

* Apply suggestions from code review

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

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>
2022-01-02 18:55:30 +01:00
M Schalk
fac9d55a36 Formulate rule/sample-extensions descriptions consistently (#4412)
reference #4384
2021-12-28 02:14:36 +01:00
Brais Gabín
92433ea634 Enable ForbiddenMethodCall (#4334)
* Enable ForbiddenMethodCall on detekt code base

* Move Resources extensions from tooling to utils

* Forbid Url.openStream calls and Class.getResourceAsStream
2021-12-02 10:43:08 +01:00
Steven Jeuris
2f755ea904 ExplicitCollectionElementAccessMethod rule fixes (#4201)
* Include custom get/set operators to ExplicitCollectionElementAccessMethod rule

This actually simplifies code, since any get/set operator can be treated the same; no need to look up type names. `Map.put()` is a type-specific edge case, which can be replaced by `set`, and thus indexed access, when the return value is not needed.

Right now, no check is done whether the return value is use. For both `set` and `put` no code smell should be reported if this is the case.

* Fix #4122: false positive ExplicitCollectionElementAccessMethod for used return values

* Fix new issues raised due to more exhaustive ExplicitElementAccessMethod

Also fixed other tests that were failing on build server.

* Additional edge case tests for ExplicitCollectionElementAccessMethod

This also includes an early out in case types can't be resolved, rather than iterating over supertypes.

* ExplicitCollectionElementAccessMethod rule requires types resolution
2021-10-29 17:50:52 +02:00
Matthew Haughton
3e1d7c350d Drop junit-platform-launcher dependency (#4115)
Modern versions of IntelliJ and Gradle do not require this explicit
dependency to be added to the project.
2021-09-20 11:50:35 +10:00
Matthew Haughton
e0aed91293 Remove detekt-bom module (#4043) 2021-09-11 07:27:16 +10:00
Matthew Haughton
fd0cb9096e Migrate buildSrc to composite build (#4090)
This will help reduce build times when changes are made to the precompiled
script plugins used in the build. This is because a change in buildSrc
causes the whole project to become out-of-date [0]. Using an included build
instead works around this problem.

[0] https://docs.gradle.org/7.2/userguide/organizing_gradle_projects.html#sec:build_sources
2021-09-04 23:09:59 +10:00
marschwar
c356897858 Enable UseEmptyCounterpart for detekt code base (#4000)
Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2021-08-03 11:36:31 +02:00
marschwar
c5850c4f53 Add config delegate to public api (#3891)
* move ConfigProperty to public api

* add config to api

* use config property in example rule

* remove ThresholdRule from extension guide

* mark LazyRegex as deprecated

* suppress deprecation warning

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
2021-07-18 13:43:50 -07:00
M Schalk
3056e069a3 Rename Tests to Spec (#3906)
* Rename Tests to Spec

* Rename DetektMultiplatformSpecTest to Spec

* Use Spek memoization when declaring non trivial types

* Use Spek memoization when declaring non trivial types

* Apply correct code formatting

* Apply correct indentation
2021-06-28 17:10:02 +02:00
marschwar
bd45a051ed Make documentation more precise about how rules are enabled (#3889)
* Make documentation more precise about how rules are enabled

* Update docs/pages/extensions.md

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>

* Update docs/pages/extensions.md

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>

* Update docs/pages/extensions.md

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>

* remove examples that use an EmptyConfig

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
2021-06-24 22:50:44 +02:00
Matthew Haughton
dc2f3d801c Enable Gradle's type-safe project accessors (#3742) 2021-05-06 20:59:44 +02:00
Brais Gabín
92b6a01903 Apply more formatting rules to our code (#3615)
* Update formatting configuration

* Apply autocorrect to the project

* Format using ktlint 0.41 --experimental

* Minor manual improvements
2021-03-28 10:00:03 -07:00
Brais Gabín
b120ffb058 Don't use deprecated functions (#3452)
* Don't use deprecated api in our samples

* Don't use deprecated functions
2021-02-08 08:36:49 +01:00
Artur Bosch
a04171a1d8 Update Kotlin to 1.4.21 (#3254)
* Update Kotlin to 1.4.20

* Update assertj to 3.18.1

* Fix type V but V!! expected compilation errors with 1.4.20

* Remove workaround for old dokka plugin

* Update to Kotlin 1.4.21

* Use jdk8 compatible mockk version

* Update mock to version 1.10.4

* Specify source and target 1.8 java version for KotlinCompile tasks

* Remove shadowJarExecutable as it does not work with newest Kotlin compiler (1.4.20+)

* Simplify copying jars for CI by reusing copy task

* Update cli guide to always use the zip distribution

* fixup! Simplify copying jars for CI by reusing copy task

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
2021-01-19 21:17:58 +01:00
Brais Gabín
945f075af1 Simplify our buildSrc (#3322)
* Move cli gradle configuration to its build.gradle.kts

* Create plugin module so we can add it to each module
2021-01-05 00:06:10 +01:00
Artur Bosch
c45791768d Add bindingContext function to FileProcessListener - #2872 (#2900)
* Introduce binding context aware members for FileProcessListener

* Use FileProcessListener with binding context everywhere

* Move deprecation on function level
2020-07-28 08:05:16 +02:00
Artur Bosch
8c7e1865d6 Move config validation from cli to core (#2764)
* Move default config and config validation to core module

* Allow to load a yaml config from any Reader instance

 It's okay to open up this method as the YamlConfig is internal and will move to the core module soon.
 This change also allows to load yaml configurations from a string for tests.

* Move testing config validations to core module

* Provide sample test case on how to test ConfigValidator's

* Move checkConfiguration call to to core module

* Replace with new location of the default config file

* Make checkConfiguration again internal
2020-06-05 10:23:19 +02:00
Artur Bosch
e1f213b838 Move reporting logic to core module (#2754)
* Move console reports to core module

* Simplify cli test cases

* Move to console package

* Move core reporting logic from cli to core module
2020-05-31 22:52:30 +02:00
Artur Bosch
fdebbc475d Modularize test module (#2720)
* Extract KtCompiler to detekt-parser preparing a minimal test utils module

* Fix potential memory leak in tests not closing settings

* Move parsing and generic test utils to own module

* Do not depend on test module for metrics, gradle plugin and generator modules

* Exclude test-utils from coverage report as we do with test module

* Explicitly depend on core-module in tests
2020-05-23 19:51:26 +02:00
Artur Bosch
2ec2d5ac9b Improve issue reporting/report at identifiers and package declarations - #2699 (#2702)
* Report file specific code smells at package or first declaration - #2699

* Report function specific code smells at identifier - #2699

* Report LargeClass smells at identifier - #2699

* Improve reporting at identifier for Deprecation issues - #2699

* Improve reporting for MethodOverloading issues - #2699

* Improve reporting at property name - #2699
2020-05-18 12:10:41 +02:00
M Schalk
ae6492b342 Delete created temp dir automatically on JVM exit (#2536)
This ensures that the temp directory is not polluted with unused files.

A helper function was created.
The created directory in the returned path is automatically deleted on JVM exit.
2020-03-28 09:12:15 +01:00
Brais Gabín
bc620d1412 Remove default print stream (#2496)
* Remove default printers from JCommander#parseArguments()

* Remove default printers from Runner

* Remove default printers from Main.buildRunner
2020-03-23 20:10:46 +01:00
M Schalk
30442170f0 Unify yml strings (#2482)
* Unify yaml strings

* Unify yaml strings to use '' instead of ""
* Successor of #2472

* Unify yaml license.template
2020-03-22 17:25:41 +01:00
Artur Bosch
d0d41cf1c8 Introduce new ConfigValidator extensions - #2285 (#2356)
* Include default config validation excludes for plugin rule sets - #2285

* Allow to validate configuration by a new ConfigValidator extension - #2285
2020-02-21 23:42:12 +01:00
M Schalk
22216d3e01 Fix sample rules not properly calling the superclass (#2295)
This makes sure that the rule doesn't break any behaviour which the
superclasses might introduce in the future.

reference #2283
2020-01-28 21:46:59 +01:00
Artur Bosch
3275e8e124 Simplify test dependency setup in build files (#2278) 2020-01-19 21:00:07 +01:00
Artur Bosch
859676e137 Remove redundant build failure message - #2264 (#2266) 2020-01-19 13:44:52 +01:00
Artur Bosch
10f97d2f59 Add tests showing how to exclude custom config properties in plugins (#2192)
* Add tests showing how to exclude custom plugin properties in configuration files - #2169

* Mention config validation excludes in the website under extensions
2019-12-26 22:45:29 +01:00
M Schalk
0be10e81db Convert tabs in multiline strings to 4 spaces (#1960) 2019-09-29 22:33:26 +10:00
M Schalk
f714f6e276 Fix shared variable in detekt-extension rules (#1897)
* Fix shared variable in detekt-extension rules

* Use KtFile instead of PsiFile visitor
2019-09-12 23:51:14 +02:00
Artur Bosch
63c1d23dc4 Make samples more idiomatic (#1895) 2019-09-06 13:25:05 +02:00
Matthew Haughton
aabbcd8899 Tidy the build files (#1814)
* Remove explicit dependency on compiler-embeddable

* Remove unnneeded task dependency

* Tidy up setting the Bintray user/pass

* Use type-safe accessors where possible

* Use tidy syntax

* Remove unused lines

* Remove unused repositories

* Avoid task configuration
2019-08-13 19:54:07 +02:00
M Schalk
3543c2fe1a Remove author tags (#1771)
* Remove author tag in /detekt-test sources

* Remove author tag in /detekt-sample-extension sources

* Remove author tag in /detekt-generator sources

* Remove author tag in /detekt-gradle-plugin sources

* Remove author tag in /detekt-formatting sources

* Remove author tag in /detekt-rules source

* Remove consecutive new lines

* Remove extra new lines

* Remove author tag in /detekt-core sources

* Remove author tag in /detekt-cli sources

* Remove consecutive new lines

* Fix failed LOC test
2019-07-21 14:03:44 +10:00
Matthew Haughton
1a6ebbd45a Run all detekt tasks with project dependencies (#1718)
* Use project(detekt-cli) for detekt configuration

* Remove unused property

* Add required parameters to custom detekt tasks

* fix typos
2019-06-23 20:38:16 +02:00
Matthew Haughton
7bebc983ac AssertJ housekeeping (#1571)
* Tidy up AssertJ imports

* Don't use internal AssertJ API
2019-04-07 16:24:25 +02:00
Matthew Haughton
ecb4701ecb Migrate to Spek 2 (#1470) 2019-02-13 09:40:32 +01:00
Artur Bosch
445ffb0c55 Reformat code base with KtLint + IntelliJ (KDoc) 2019-02-09 19:52:48 +01:00
Marvin Ramin
479411fcca Update to Gradle v5 (#1350)
* update gradle to v5-rc3

* resolve API changes in Configurations

* remove feature preview from settings.gradle

* resolve deprecation warnings

* update gradle wrapper jar and scripts

* implement GradleCompat

* upgrade to Gradle 5.0-RC4

* add missing dependency

* update to gradle v5

* remove gradle plugin settings.gradle.kts

* add dependencies to kotlin-reflect
2018-12-12 20:44:26 +01:00
Matthew Haughton
712dedde7b Migrate JUnit tests to Spek (#1213) 2018-10-12 08:15:20 +02:00
Matthew Haughton
192bc3461d Remove unused dependencies 2018-09-24 21:01:20 +10:00
Matthew Haughton
2034259cc3 Remove redundant Kotlin plugin config 2018-09-24 19:31:42 +10:00
Matthew Haughton
7dc3457ae0 Use Gradle Kotlin DSL to apply Kotlin dependencies 2018-09-24 19:31:42 +10:00
Markus Schwarz
815a74558b Merge gradle-plugin rework by Marvin Ramin and marschwar 2018-09-09 08:34:21 +02:00
Artur Bosch
2f34f44020 Fix detekt issues 2018-07-22 22:56:53 +02:00
Artur Bosch
24935ee782 Format codebase with ktlint - #925 2018-07-08 17:31:38 +02:00
epeee
9d3a69e3d9 Use native junitPlatform from gradle 4.6 2018-06-23 00:07:26 +02:00