Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule 6.1.7: in case of using "implicit backing property" scheme, the name of real and back property should be the same #443

Closed
petertrr opened this issue Oct 23, 2020 · 0 comments · Fixed by #465
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@petertrr
Copy link
Member

Kotlin has a mechanism of backing properties.
In some cases implicit backing is not enough and it should be done explicitly:

private var _table: Map<String, Int>? = null
val table: Map<String, Int>
    get() {
        if (_table == null) {
            _table = HashMap() // Type parameters are inferred
        }
        return _table ?: throw AssertionError("Set to null by another thread")
    }

In this case the name of backing property (_table) should be the same to the name of real property (table), but should have underscore (_) prefix.
It is one of the exceptions from the identifier names rule

@petertrr petertrr added the enhancement New feature or request label Oct 23, 2020
@petertrr petertrr added this to the Chapter 6 milestone Oct 23, 2020
@aktsay6 aktsay6 self-assigned this Oct 29, 2020
aktsay6 added a commit that referenced this issue Oct 30, 2020
### What's done:
  * First logic
  * Added tests
aktsay6 added a commit that referenced this issue Oct 30, 2020
### What's done:
  * Logic made
  * Added warn tests
aktsay6 added a commit that referenced this issue Oct 30, 2020
aktsay6 added a commit that referenced this issue Oct 30, 2020
#443)

# Conflicts:
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt
#	info/available-rules.md
aktsay6 added a commit that referenced this issue Oct 30, 2020
aktsay6 added a commit that referenced this issue Nov 2, 2020
aktsay6 added a commit that referenced this issue Nov 3, 2020
aktsay6 added a commit that referenced this issue Nov 3, 2020
aktsay6 added a commit that referenced this issue Nov 20, 2020
aktsay6 added a commit that referenced this issue Nov 20, 2020
#443)

# Conflicts:
#	diktat-analysis.yml
#	diktat-rules/src/main/kotlin/generated/WarningNames.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt
#	diktat-rules/src/main/resources/diktat-analysis-huawei.yml
#	diktat-rules/src/main/resources/diktat-analysis.yml
#	info/available-rules.md
aktsay6 added a commit that referenced this issue Nov 23, 2020
#443)

# Conflicts:
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
aktsay6 added a commit that referenced this issue Nov 23, 2020
aktsay6 added a commit that referenced this issue Nov 23, 2020
aktsay6 added a commit that referenced this issue Nov 23, 2020
aktsay6 added a commit that referenced this issue Nov 23, 2020
aktsay6 added a commit that referenced this issue Nov 23, 2020
#443)

# Conflicts:
#	diktat-analysis.yml
#	diktat-rules/src/main/kotlin/generated/WarningNames.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	diktat-rules/src/main/resources/diktat-analysis-huawei.yml
#	diktat-rules/src/main/resources/diktat-analysis.yml
aktsay6 added a commit that referenced this issue Nov 23, 2020
…ing-property(#443)' into feature/rule-6.1.7-implicit-backing-property(#443)
aktsay6 added a commit that referenced this issue Nov 23, 2020
* feature/rule-6.1.7-implicit-backing-property(#443)

### What's done:
  * Logic made
  * Added warn tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants