Opt-in doesn't need to be propogated in test code, or in detekt-core which
is not public API.
https://kotlinlang.org/docs/opt-in-requirements.html#non-propagating-opt-in
> In modules that don't expose their own API, such as applications, you can
> opt in to using APIs without propagating the opt-in requirement to your
> code. In this case, mark your declaration with @OptIn passing the opt-in
> requirement annotation as its argument.
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
* 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
* Use structural equality (==) instead of referential equality (===), use safe access instead of null check, cleanup test comments
* Reinstate referential equality for node comparison for guard clauses, rename test case as per MR review comment
* Remove code duplication and use common code for ELVIS guard clause for ThrowsCount, add test case for the same in ThrowsCountSpec
* Revert wildcard imports
* Add internal to the guard clause extension methods
* Use compileAndLint
* Improve documentation
* Add more tests
* Fix false positive
* Extract receiverIsUsed and make it positive
* Fix more false negatives
* Fix more false negatives
* minor improvement
* update docs
* refactor
* Reduce complexity
* Add one more case of false negative
* Test the message
* Fix false positive
* rename count
* failing tests for #2804 LongMethod with params
* fix test
* skipTrees for KtParameterList for linesOfCode
* use test snippets that compile
* [ci ckip] use fun body for LongMethod
- revert changes in LinesOfCode.kt
- still need to update nested methods
* remove unused import
* add functionToBodyLinesCache to track fun body length
* remove spaces from test asserts
* 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>
* Fix two MaxLineLength issues
* Remove dependency on core.rules
* Move test helper for ProcessingSettings to core module
Besides of one usage in formatting it is only used by the core module.
Custom rule sets (formatting is treated as one) should not depend on core.
* Move FileProcessListener service registration to their respective modules
We merge the service loaders when constructing the cli shadowJar.
When combining jars dynamically this is not an issue as each jar has it's own services file.
* Move other test configuration into the configs folder
* Fixup after merging
* Let DetektFacade execute OutputFacade
* Implement generic properties storage
Allows to pass arbitrary data to detekt extensions.
* Implement Baseline feature as an ReportingExtension
Reporting extensions provide interception points to filter findings and execute logic on detekt's result container.
* Share common processing settings creation logic between runners
* Implement OutputFacade as ReportingExtensions
* Run OutputFacade always last
* Describe why output reports needs to be run first
* Apply PR feedback
* Concert OutputFacade back to a core class instead of a ReportingExtension
An extensions which loads other extensions feels kind of wrong.
Reporting is a core logic and shouldn't be optional.
* add better documentation for the LongParameterList ignoreAnnotated
* make LongParameterList doc changes in the right place
* Checkin documentation
Co-authored-by: Ken Yee <kyee@wayfair.com>
Co-authored-by: Artur Bosch <arturbosch@gmx.de>
* Adding NumberFormatException as default for SwallowedException rule
* Adding InterruptedException as default for SwallowedException rule
* Adding ParseException as default for SwallowedException rule
* Adding MalformedURLException as default for SwallowedException rule
* Refactoring code to use enum
* Fixing enum class name
* Using String instead of enum class
* Using generic Exception instead of custom exception
* Simplify ignored by default testcases by using dynamic tests
Co-authored-by: Artur Bosch <arturbosch@gmx.de>
* Add default print methods to ForbiddenMethodCall
Adding all the variations of print/println from Java and Kotlin
to the ForbiddenMethodCall.
The rationale is to encourage the usage of a Logger.
Moreover this fixes the rule that was not catching all the method
calls due to overriding visitQualifiedExpression rather than visitCallExpression
Fixes#2678
* Fixing indentation
* Fixed assert location
* Cleanup tests in ProtectedMemberInFinalClass
* Remove extra `reports` comments
* Improve the test description
Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
* Get rid of cli and core dependency for generator
* Remove generic argument parsing made for sharing but introduced complexity
* Do not use expensive shadow plugin on internal generator module
* Apply shadow plugin for cli in packaging
* Generate documentation after compilation of rules
* Trigger generateDocumentation when formatting rules are changed
* Further reduce complexity of parsing args
* Start generateDocumentation directly from gradle
* Test additional error paths of CliArgs
* 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