* Report KDoc comments that refer to encapsulated properties of a class
New rule to address the issue of breaking encapsulation principle when KDoc comments have references to encapsulated (private) properties.
Clients do not need to know the implementation details.
* Rename rule to 'KDocReferencesNonPublicProperty' and fix naming
* Set 'protected' modifier as allowed
* Improve tests
* Fix rule documentation
* Add ElseCaseInEnumOrSealedWhen rule
* Adapt to new rule by replacing else cases
* Change rule name, support booleans, improve docs
* Change variable name of boolean condition
* Rename rule to ElseCaseInsteadOfExhaustiveWhen
* Improve rule descriptions
* Suppress rule for outdated documentation method
* Not report sealed class subjects that have an expect modifier
* Fix sample code syntax and not compile mulitplatform code
* Introduce OutdatedDocumentation rule
Basic implementation covers:
- class primary constructor parameters
- class primary constructor property parameters
- function parameters
* OutdatedDocumentation rule - type parameters matching
* OutdatedDocumentation rule - refactor and add more tests
* OutdatedDocumentation rule - report for secondary constructors
* OutdatedDocumentation rule - do not report when KDoc does not contain any @param or @property tag
* OutdatedDocumentation rule - add description
* OutdatedDocumentation rule - add configuration for type parameters and declarations order
* OutdatedDocumentation rule - refactor
* OutdatedDocumentation rule - fix CI
* OutdatedDocumentation rule - additional test cases
* OutdatedDocumentation rule - fix rule reporting for incorrect declarations order
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
* Enable UnnecessaryLet rule for detekt code base
* baseline parser does not work with new lines
* replace let with private extension function to improve readability
Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
* Fix#3893 by only calling super.visit once
In #3660 the EndOfSentenceFormat rule got refactored.
The rule is called by the MultiRule 'KDocStyle'.
Both the called and calling visitor function execute a super.visit().
This can cause problems.
Hence, super.visit only called once with the changes made.
Suspicion:
Multiple KtDeclaration super.visit calls cause the crash in #3893.
* Update test case description
* UndocumentedPublicFunction: don't report when nested class is inside not public class
* Update detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicFunction.kt
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
* Format
* Add a test for objects
* Simplify
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
* 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>
* Add test cases for objects with an undocumented public function
* Check the containing class or object instead of just the class
The class returned was null for functions inside an object, resulting in a false negative, so we instead use containingClassOrObject to determine if the containing object is public or not.
* Add test cases for objects with an undocumented public property
* Check the containing class or object instead of just the class when determining eligibility for UndocumentedPublicProperty check
containingClass() returns null when checking an object not nested in another class, making it ineligible to check. Switching to containingClassOrObject allows properties in an obect to be checked.
* Add test cases for interfaces to property and function documentation rules
* Fixing invalid kotlin in interface test
* use annotations to configure AbsentOrWrongFileLicense
* use annotations to configure EndOfSentenceFormat
* use annotations to configure UndocumentedPublicClass
* make config properties private
Co-authored-by: Brais Gabín <braisgabin@gmail.com>
Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
Co-authored-by: Brais Gabín <braisgabin@gmail.com>
* Fix 2 spaces because the code block cannot be read
* Fix incomplete block
* Fix impossible case
* Fix annotation escape
* Use 4 spaces as indentation
Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
* Add DeprecatedBlockTag rule
* Refactor DeprecatedBlockTagSpec tests to remove Spek complexity
* Fix incorrect deprecation test snippets on property set/get
* Add link to official docs in DeprecatedBlockTag
* Extract KDocStyle class out of EndOfSentenceFormat.kt
* Fix EndOfSentenceFormat not visiting declarations on its own
* Add DeprecatedBlockTag to KDocStyle
* Fix code made useless by DeprecatedBlockTag move
* Add @ActiveByDefault annotation
* Add support for @ActiveByDefault annotation
* Use annotation for all activated in v1.2.0
* Use annotation for all activated after v1.2.0
* Use annotation for all activated in v1.0.0
* Update documentation with regard to RuleSetProvider
* Update documentation
* Remove leading 'v' from version in annotation
* Use named parameter 'since' for @ActiveByDefault
* check version matches semantic version pattern.
* Fix typo and correct version format
* Fix merge errors
Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>
Problem: different projects might impose different rules on license headers.
It's not uncommon, for example, that a year in the license header is the year when the source
file was created. This leads to a situation when different source files have different license
headers (at least some parts of them differ) making it impossible to use a single static
license header template to match against.
This change makes it possible to define license header templates as regexps.
An example of such template is:
\/\/ Copyright 20[0-9]{2} Artur Bosch & Contributors
which would match both
// Copyright 2020 Artur Bosch & Contributors
and
// Copyright 2021 Artur Bosch & Contributors
The way `AbsentOrWrongFileLicense` works now is controlled
by the new configuration option `licenseTemplateIsRegex`:
when `licenseTemplateIsRegex` is false the template is considered to be static
and the old matching rules apply.
If `licenseTemplateIsRegex` is set to true the new regexp based logic kicks in.
To avoid breakage of existing projects, the added configuration option
`licenseTemplateIsRegex` is disabled by default.
This commit implements a feature requested here #3100.
* Move internal config api to core module
* Move YamlConfig to core and remove all remaining references
* Remove yaml dependency from api module
* Revert visibility modifier change
* Improve description of AbsentOrWrongFileLicense rule
The new description states how the rule checks Kotlin source files
against the given license header.
Closes#3100
* Update grammar in description
* Regenerate docs
* Introduce binding context aware members for FileProcessListener
* Use FileProcessListener with binding context everywhere
* Move deprecation on function level
* 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