* 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
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
* 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
* Deprecate Location.file in favor of Location.filePath
* Fix warnings
* Enable warningsAsErrors again
This was removed in #2981 for an issue with kotlin 1.4 but that issue
is fixed now so it's safe to enable it again
* This is a first draft for enabling more detekt rules by default.
This way users can benefit from a good default config.
Closes#2838
* Regenerate default-detekt-config.yml
* Resolve SwallowedException with judgement calls
* Address ImplicitDefaultLocale
* Fix ImplicitDefaultLocale in tests
Co-authored-by: Artur Bosch <arturbosch@gmx.de>
Co-authored-by: Chao Zhang <cazhang@linkedin.com>
* Support relative output paths
* Enrich test spec description and add KDoc
* Update documentation
* Refactor FilePath
* Fix CI failures
* Fix detekt failures and restore defaults as absolute
* Renamed report base path back to base path
* 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
* Use max 4 workers, test discovery slows down parallel workers
* Use a spek snapshot to improve test discovery time
* Introduce an api test fixture for modules needing just an analysis result
* Use api test fixture in html module
* Use api test fixtures in report-xml module
* Use api test fixtures in metrics module
* Use api test fixtures in core module
* Use single-threaded classpath scanning
* Do not create a kotlin environment upfront
* Move mockk usage to execution phase
* Move KtCompiler creation to execution phase
* Move setup code to execution phase in api module
* Move setup code to execution phase in core module
* Move setup code to execution phase in rules-empty module
* Fix applying only the fileName to the created KtFile
* Remove complexity from calculating signatures
* Remove hack to find absolute path of a KtFile
* Use KtFile.name for absolute paths
* Declare fileName utilities on the interface PsiFile instead of KtFile
* Use a Path to be compliant with Windows
* Simplify whitespaces regex
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
* Prototype a configuration dsl
* Implement a service returning the default configuration
* Implement a service returning the runtime detekt version
* Add logging and issues specific configuration to ProcessingSpec
* Define interfaces to load detekt instances during runtime
* Use new DetektProvider in cli Runner for detekt analysis
* Rename IssuesSpec to RulesSpec
* Support to run chosen single or multiple rules via spec api
* Move logic to check for build error to core
Add tooling support for MaxIssuePolicy.
* Make Runner config validation testcases independent of possible build failure logic
* Simplify test runner creation
* Make KtFileModifier a FileProcessListener
Removes special treatment inside DetektFacade
* Allow to add a reason UnstableApi annotation
* Remove unnecessary DetektFacade.create factory functions
* Implement remaining DetektFacade functions based on a new Lifecycle class
* Fix using excludes
* Fix using given BindingContext instead of creating one
* Rename to AnalysisFacade and Analyzer for core classes
* Support running a single from core module
* Unwrap the unexpected error before throwing it
* Move LicenceHeader test to rules module where it is declared
* Finalize migration to loading Config from Spec instead of CliArgs by moving and reworking existing test cases
* Move --run-rule test cases to runner as there is no SingleRuleRunner anymore
* Implement a default configuration provider
* Deprecate obsolete methods to retrieve the default configuration
* Implement a default version provider
* Support excludeCorrectable for RulesSpec which should make the config property obsolete
* Simplify loading ConfigValidators
* Use ReportsSpec.Report in core and move ReportsPath to cli again
* Create an abstraction for build>maxIssues config part based on MaxIssuePolicy
* Remove core dependency for formatting by moving top level auto correct test
* Make local test-only rules private
* Extract measuring performance logic into a dedicated class
* Remove unnecessary side-effects from parsing arguments
* Reimplement cli logic based on new DetektCli interface
* Remove all trailing comma leftovers from testing with 1.4 language version
* Introduce NonSpecified MaxIssuePolicy to make it explicit when to use legacy build section from the config
* Change output and error channel types to Appendable
* Share ProcessingSpec in ProcessingSettings
This is the first step to migrate ProcessingSettings properties usages to spec.
* Move PathFilters out of ProcessingSettings
They were just referenced in KtTreeCompiler.
* Extract common logging logic from ProcessingSettings into a separate class
* Extract common properties logic from ProcessingSettings into a PropertiesFacade class
* Remove output and error channels from ProcessingSettings
* Extract Kotlin environment logic to a dedicated class
* Pass buildUponDefaultConfig from cli to core module
* Extract plugin and extension logic from ProcessingSettings
* Remove excludeDefaultRuleSets from ProcessingSettings
* Remove parallel property from ProcessingSettings
* Remove autoCorrect property from ProcessingSettings
* Remove executorService property from ProcessingSettings
* Remove inputPaths property from ProcessingSettings
* Move configUris outside the constructor
* Allow extensions to be disabled via their ids in ExtensionSpec
* Remove unused constructs
* Deprecate convenient print method only usable for PrintStreams
* Remove obsolete ExitCode enum
* Make core a runtimeOnly dependency
* Make all detekt-core dependencies implementation-dependencies
* Make DefaultConfig object internal
* Make AnalysisResult.exitCode an extension function
* Remove BindingTrace entry point
* Make using a parsing strategy explicit
* Use yml to be consistent with other naming
* Remove unnecessary factory method for KtTreeCompiler
* Make Throwable branch the else branch
* Close only self constructed URLClassloaders
* Test exit codes from AnalysisResult
* Test either plugin paths or a classloader is used
* Test loading a DetektCli instance
* 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
* Introduce parser module which handles setting up kotlin environment
* Introduce psi-utils module cleaning up api module from shared KtFile extensions
* Return Path object instead of wrapping on call site