325 Commits

Author SHA1 Message Date
Chao Zhang
273cee8eff Update dangling URLs pointing to the old website (#3400) 2021-01-24 01:18:45 +01:00
Nicola Corti
b0041fea94 Update documentations on snapshots (#3393)
* Update documentations on snapshots

* Add page link to the README

* Apply suggestions from code review

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

Co-authored-by: Brais Gabín <braisgabin@gmail.com>
Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
2021-01-21 00:05:43 +01:00
Sławomir Czerwiński
1164c34f1c Ignore actual functions in FunctionOnlyReturningConstant (#3388) (#3390)
* Ignore actual functions in FunctionOnlyReturningConstant (#3388)

* Enable builds for pull requests from grouped branches

* Remove redundant .trimIndent()

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
2021-01-19 22:03:16 +01:00
severn-everett
e5a694c557 Add new rule SleepInsteadOfDelay (#3335)
Added new SleepInsteadOfDelay rule for checking for whether Thread.sleep() is being used in suspend functions and coroutines.

* sleep instead of delay
Added SleepInsteadOfDelay rule

* sleep_instead_of_delay
Added entry to mention the new contribution in README.md

* sleep_instead_of_delay
Added positive unit test for SleepInsteadOfDelay rule

* sleep_instead_of_delay
Added check for CoroutineScope.async(); Added @requiresTypeResolution for documentation

* sleep_instead_of_delay
Removing active declaration for rule

* sleep_instead_of_delay
Added test for sleep() invocation when Thread.sleep is imported and executed in a Coroutine block; Fixed bug where sleepImported could be set to false after visiting other import statements in a file

* sleep_instead_of_delay
Reducing granularity of checks for Thread.sleep() invocations, just checking on all KtCallExpression instances

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
2021-01-14 16:13:34 +01:00
Adam Kobor
a17b7f93f3 Add MultilineLambdaItParameter rule (#3259)
* Add MultilineLambdaItParameter rule

* Make issue description more informative

Co-authored-by: Nicola Corti <corti.nico@gmail.com>

* Change rule behavior to report only for multiple statements

* Adjust documentation and issue message

* Use isEmpty() instead of hasSize(0) in tests

Co-authored-by: Nicola Corti <corti.nico@gmail.com>

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
2021-01-14 16:11:24 +01:00
Nicola Corti
735b3b3a6d Add setup-detekt action to README (#3373) 2021-01-13 21:19:08 +01:00
Chao Zhang
481dab918a Bundle new sarif output format by default (#3268)
* Hook up SARIF output

* Keep SARIF disabled by default
2020-12-14 16:14:46 +01:00
Thomas M. DuBuisson
abd1310037 Add MuseDev to the list of integrations (#3284) 2020-12-13 11:01:12 +01:00
M Schalk
fc5c993f5d Add IntelliJ platform plugin template integration to readme (#3270)
Detekt is part of the official JetBrains template for creating IntelliJ plugins.
2020-12-10 11:46:39 +01:00
Roman
178b0da4f0 Rule improvement: ReturnFromFinally (#3228)
* Rule improvement: ReturnFromFinally

* Fix class comment

* Changed the order of checks

* Changed the implementation of visitFinallySection with the binding context capability

* Code review fixes

Co-authored-by: ivanov_r <ivanov_r@bifit.com>
Co-authored-by: r.ivanov <r.ivanov@redmadrobot.com>
2020-11-19 12:01:06 +01:00
Chao Zhang
2705f09079 Fix rule LibraryCodeMustSpecifyReturnType (#3155)
* Fix rule LibraryCodeMustSpecifyReturnType

False positive: Members without visibility modifiers in an
internal class should not be reported.

False negative: Members with protected modifiers in a public
class should be reported.

* Create BaseRule.lintWithContext to skip KotlinScriptEngine compilation

* Add comment back

* Add @requiresTypeResolution and binding context check

* Complete the javadoc and build
2020-10-23 13:23:09 +02:00
Harold Martin
a714f540d9 ClassOrdering rule reports a list of errors (#3142)
* ClassOrdering rule reports a list of errors
Also report entity where error occurred not just parent class

* better testing

* added to readme
2020-10-15 11:45:56 +02:00
Marcelo Hernandez
cbbca8594b New rule: SuspendFunWithFlowReturnType (#3098)
* Add new coroutines rule - SuspendFunWithFlowReturnType

* Run generateDocumentation task

* Add Marcelo Hernandez to Contributors list

* Downgrade Coroutines from 1.3.9 to 1.3.8

* Remove Coroutines dependency declaration in detekt-test-utils

* Reformat CodeSmell instantiation

* Add test for non-suspend, Flow-returning functions

* Delete tests that fail when compile-test-snippets=true

* Revert changes to index.md files

* Add link to specific "Flows are cold" section in Flow documentation

* Extend the issue description by providing the 'why'

* Use apply when adding JvmClasspathRoots in KtTestCompiler

* Update documentation to reflect updated link

* Rename private isCoroutineFlow() extension to isCoroutinesFlow()

* Update issue description

Co-authored-by: Marcelo Hernandez <marcelo.hernandez@gotinder.com>
2020-09-26 09:35:03 +02:00
Nicola Corti
87d2fc29ee Move SNAPSHOT from artifactory to sonatype (#3076) 2020-09-21 22:06:14 +02:00
Artur Bosch
71853bf633 Update dependency badge to maven central (#3072)
* Update dependency badge to maven central

* Update README.md

Co-authored-by: Nicola Corti <corti.nico@gmail.com>

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
2020-09-19 11:28:55 +02:00
Chao Zhang
ab76be9f91 Fix ModifierOrder for false positive reported by ModifierOrder when using fun interfaces (#3051)
* Fix ModifierOrder for Kotlin SAM

* Remove the test cases that is not legal Kotlin code
2020-09-05 13:26:22 +02:00
Artur Bosch
ee49144114 Support Kotlin 1.4 (#2981)
* Update to Gradle 6.6

* Update to Kotlin 1.4

* Upgrade to prerelease of KtLint 0.38

* Fix testcase by unwrapping the original descriptor

* Increase max heap for dokka on Java 11

* Update minimal supported Gradle version to 5.3

* Do not run warningsAsErrors on CI due to Gradle not supporting Kotlin 1.4

* Remove new line testing as it fails on windows

* Require Gradle 5.4 to reflect Kotlin's required version from their website
2020-08-20 20:00:38 +02:00
M Schalk
8664cf6b96 Add custom rules from 3rd parties section to readme (#2984) 2020-08-18 22:42:56 +02:00
Volodymyr
3eba7f1a1e Add new rule: LibraryEntitiesCannotBePublic (#2959)
* Add new rule: LibraryEntitiesCannotBePublic

* add docs for rule: LibraryEntitiesCannotBePublic

* Update readMe

* Change .hasSize(0) to .isEmpty() in tests

* Fixed code review issues

* Add check for top funtion for rule LibraryEntitiesShouldNotBePublic and fixed detekt issues

* Added LibraryEntitiesShouldNotBePublic to default detekt config

* Fixed naming of test class

* Fixed default detekt config and doc for style

* Remove broken test
2020-08-11 12:39:57 +02:00
Veyndan Stuart
c6fa870d17 Flag listOfNotNull if all arguments are non-nullable (#2932)
* Flag listOfNotNull if all arguments are non-nullable

* Add test to verify that UselessCallOnNotNull reports with listOfNotNull()
2020-08-06 10:55:29 +02:00
Natig Babayev
65fd268718 Remove duplicate mention of Github Action (#2925) 2020-08-02 21:58:06 +02:00
M Schalk
20e8c67052 Add Github Action: Detekt All to readme (#2915) 2020-08-01 11:32:59 +02:00
Veyndan Stuart
e368d4c419 Add new rule UseEmptyCounterpart (#2864)
* Add new rule UseEmptyCounterpart

* Simplify UseEmptyCounterpartSpec fixture creation

* Add test for no-arg custom function invocation

* Fix failing test for no-arg custom function invocation

* Add test for no-arg instantiation with inferred type parameters

* Add support for empty instantiation of listOfNotNull()
2020-07-31 19:12:45 +02:00
Zachary Moore
539a010298 Fix UseDataClass to accept classes that implement interfaces (#2905)
* Fix UseDataClass to accept classes that implement interfaces

* Add test to cover interface property override

* Fix improper code in test

* Add additional tests

* Add myself to the readme contributors
2020-07-30 10:03:20 +02:00
Artur Bosch
265b217595 Mention bazel integration and a new blog article (#2867) 2020-07-13 20:12:33 +02:00
Artur Bosch
b57b3848ad Mention bazel and github actions integration (#2866) 2020-07-13 20:12:00 +02:00
Remco Mokveld
1e712757bb Rename Blacklist and Whitelist to be self explanatory (#2778)
* Rename Blacklist and Whitelist to be self explanatory

SuppressedFalsePositive and TemporarySuppressedIssue describe better what each list is meant for and are more culturally appropriate.

* Add backward compatibility for deprecated baseline attributes

* Use better names for tags that replace blacklist and whitelist

* Define constants for Blacklist and Whitelist

This was done to make it more clear why they still exist in code

* Fix documentation after replacing whitelist terminology

* Move documentation to WildcardRule so generator does not complain

Co-authored-by: Artur Bosch <arturbosch@gmx.de>
2020-06-11 12:49:34 +02:00
Artur Bosch
daa7f9cc23 State that speeding the detekt task just applies to version < 1.7.0 (#2730) 2020-05-25 11:21:59 +02:00
Volkan Şahin
6dd27429ef Extra documentation added to pitfalls section (#2675)
* Extra documentation added to pitfalls section

* Apply suggestions from code review

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
2020-05-11 22:05:18 +02:00
David Phillips
1288153b2c Add style rule for mandatory braces in for loop bodies (#2658)
* Add style rule for mandatory braces in for loops

* Unify code style in mandatory braces for loop and if statement rules

Extracted the description inside of 'MandatoryBracesIfStatements' to a
constant to match the structure of 'MandatoryBracesForLoops'.

Refactored the helper functions in 'MandatoryBracesIfStatements' to be
extention functions, again similar to 'MandatoryBracesForLoops'.

Refactored extension functions in both to explicitly use this to help
make clear the properties of the receiver.

* Add unit tests to verify MandatoryBracesForLoops

* Add daphil19 to contributors list in readme

* Reorder StyleGuideProvider list to be in alphabetical order

'MandatoryBracesIfStatements' and 'MandatoryBracesForloops' were not in
alphabetical order.

* Refactor MandatoryBracesForLoops tests to use compileAndLint

This change addresses some of the commends in PR #2658.

* Add additonal test to MandatoryBracesForLoops

These tests were mainly edge cases that were requested in PR #2658.

While writing these tests, the actual MandatoryBracesForLoops rule was
modified to add the apporpirate call to `super` in order to handle the
nested loop case

* Add while loop support for MandatoryBracesForLoops

The rule now checks for braces in both for and while loops.

This commit also added unit tests for the while loop portion.

* Rename MandatoryBracesLoops rule

Because the rule now supports both for and while loops, the rule should
be renamed from MandatoryBracesForLoops to MandatoryBracesLoops.

* Fix reference error in test code for MandatoryBracesLoops

One of the while loop tests referenced a var that wasn't present.

* Add a test for loop in if statement for MandatoryBracesLoops
2020-05-08 23:28:42 +02:00
M Schalk
dde0643ebb Add detekt GitHub action to readme (#2650) 2020-05-07 23:26:03 +02:00
Mygod
86343d4df3 Fix extra line in README (#2653) 2020-05-06 09:37:01 +02:00
Nicola Corti
cd0f6d0715 Update sample Gradle KTS integration link (#2649) 2020-05-01 18:52:12 +02:00
Brais Gabín
383d72bbf3 Fix a lot of links (#2638)
* Fix lot of links

* Update links from changelog

* Fix more links
2020-04-25 13:34:48 +02:00
Natig Babayev
b6b9728a38 Update urls (#2637) 2020-04-25 11:38:41 +02:00
Brais Gabín
b5338ed4b3 Update documentation (#2617)
* Update --help output

* Document the different ways to install detekt

* Update how to install the cli in the readme

* Use the current version of detekt in our documentation

* Don't use the java -jar way to run detekt as an example

* fix language metadata
2020-04-20 15:30:43 +02:00
Sebastiano Poggi
c2a794a2b5 Check jcenter repository present in Gradle plugin (#2550)
* Emit helpful errors in Gradle plugin

Whenever the plugin is applied to a project that doesn't have
jcenter() configured, the user would get a cryptic error message
from Gradle (see issue #2549). This simple change makes sure the
plugin will provide users with clear instructions on how to fix
their build so they don't get stumped when things don't work.

* Update contributions in README

* Fix ktlint name in docs: it's all lowercase

Also update repo URL to /pinterest/ktlint through out docs

* Update Gradle getting started in index.md

* Fix ktlint name in code too

* Address detekt warnings after plugin changes

* Only check for jCenter in afterEvaluate { }

This is necessary because we need to make sure it's there _somehow_,
and it may be added by other plugins, or blocks evaluated after this
plugin is applied.

* Apply suggestions from code review

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

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
2020-03-29 19:35:36 +02:00
Nicola Corti
4f768878b5 Setup GitHub Actions (#2512)
* Setup GH Actions

* Remove Trailing Spaces

* Do not cleanup before caching folders

* Update .buildscript/deploy_snapshot.sh

Co-Authored-By: Artur Bosch <arturbosch@gmx.de>

* Remove Build Scans

* Fixed Typo in buildscript

* Compile Scripts Test Snippets only on Java 8

* Stop Gradle

* Update Cache ID

* Add Comment on Gradle Stop step

Co-authored-by: Artur Bosch <arturbosch@gmx.de>
2020-03-28 07:46:28 +01:00
Marius Kohmann
3582a8a2e3 Add detekt-hint to integrations (#2441) 2020-03-16 23:29:17 +01:00
Artur Bosch
2237b0fa88 Add groovy dsl example for jvmTarget - Closes #2408 (#2422) 2020-03-09 18:02:07 +01:00
M Schalk
778054831d Add blog post about speeding up a detekt task (#2349)
in a multi-project Gradle build
2020-02-17 01:18:49 +01:00
Jonas Alves
8c0c994a3f Bugfix: MagicNumber with ignoreNamedArgument and a negative value (#2315)
* Rule fix: MagicNumber with ignoreNamedArgument and a negative value

* Adding contributor to README.md

* Rule fix: MagicNumber with ignoreNamedArgument and a negative value
2020-02-06 16:29:59 +01:00
Stanislav Myachenkov
952e5608d3 add new mention to README.md (#2293) 2020-01-26 18:12:47 +01:00
Artur Bosch
a16022ba68 Update readme promoting new properties of the gradle plugin (#2205) 2019-12-27 22:09:07 +01:00
M Schalk
ca5d549060 Add comment regarding type resolution to README (#2199)
* Add comment regarding type resolution to README

* Rename gradle to Gradle
2019-12-27 14:37:55 +01:00
Artur Bosch
a754335bc9 Mention needed library kotlinx.html from jcenter - #2146 (#2190) 2019-12-25 21:38:59 +01:00
Igor Manushin
6816da044a Extract common jvm target value, add jvmTarget into documentation. Close #2157 (#2183) 2019-12-17 23:10:13 +01:00
Matthew Haughton
b75cf4227a Migrate to Gradle 6 (#1902)
* Gradle 6

* Remove ProjectLayout.fileProperty usage

Removed in Gradle 6

* Remove deprecated inputs

* Fix validateTaskProperties issues

* Remove unnecessary extension

* Use new plugin validation task name

* Simplify docs
2019-11-25 20:11:08 +01:00
M Schalk
478cef70e0 Add license badge to README (#2080) 2019-11-11 19:34:06 +01:00
M Schalk
d907933ba9 Update readme to comply with GitHub flavored md (#2002) 2019-10-11 18:03:06 +10:00