From f38ce8bca67e45b48127d973633a5fd28037ec99 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Mon, 11 Jan 2021 10:18:22 +0300 Subject: [PATCH] Years in copyright examples updated to 2021 (#687) ### What's done: * Years updated in examples for tests --- .../src/main/resources/diktat-analysis-huawei.yml | 2 +- diktat-rules/src/main/resources/diktat-analysis.yml | 2 +- .../diktat/ruleset/chapter2/HeaderCommentRuleFixTest.kt | 8 ++++++-- .../cqfn/diktat/ruleset/chapter2/HeaderCommentRuleTest.kt | 8 ++++---- .../org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt | 5 +++-- .../test/paragraph2/header/AutoCopyrightExpected.kt | 2 +- .../paragraph2/header/CopyrightDifferentYearExpected.kt | 2 +- .../MisplacedHeaderKdocAppendedCopyrightExpected.kt | 2 +- .../test/paragraph2/header/MisplacedHeaderKdocExpected.kt | 4 +++- .../test/paragraph2/header/MultilineCopyrightExample.kt | 2 +- .../paragraph2/header/NewlineAfterHeaderKdocExpected.kt | 3 ++- .../test/smoke/src/main/kotlin/Example5Expected.kt | 2 +- examples/gradle-groovy-dsl/diktat-analysis.yml | 2 +- .../gradle-kotlin-dsl-multiproject/diktat-analysis.yml | 2 +- examples/gradle-kotlin-dsl/diktat-analysis.yml | 2 +- examples/maven/diktat-analysis.yml | 2 +- 16 files changed, 29 insertions(+), 21 deletions(-) diff --git a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml index 799177837d..2681f665db 100644 --- a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml +++ b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml @@ -126,7 +126,7 @@ enabled: true configuration: isCopyrightMandatory: true - copyrightText: ' Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved.' + copyrightText: ' Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.' # Checks that header kdoc is located before package directive - name: HEADER_NOT_BEFORE_PACKAGE enabled: true diff --git a/diktat-rules/src/main/resources/diktat-analysis.yml b/diktat-rules/src/main/resources/diktat-analysis.yml index dd70b9560b..cf353c0ce0 100644 --- a/diktat-rules/src/main/resources/diktat-analysis.yml +++ b/diktat-rules/src/main/resources/diktat-analysis.yml @@ -125,7 +125,7 @@ enabled: true configuration: isCopyrightMandatory: true - copyrightText: 'Copyright (c) Your Company Name Here. 2010-2020' + copyrightText: 'Copyright (c) Your Company Name Here. 2010-2021' # Checks that header kdoc is located before package directive - name: HEADER_NOT_BEFORE_PACKAGE enabled: true diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/HeaderCommentRuleFixTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/HeaderCommentRuleFixTest.kt index a7b01d7684..65628ffe74 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/HeaderCommentRuleFixTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/HeaderCommentRuleFixTest.kt @@ -11,6 +11,7 @@ import generated.WarningNames.WRONG_COPYRIGHT_YEAR import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Tags import org.junit.jupiter.api.Test +import java.time.LocalDate class HeaderCommentRuleFixTest : FixTestBase( "test/paragraph2/header", @@ -19,7 +20,7 @@ class HeaderCommentRuleFixTest : FixTestBase( RulesConfig("HEADER_MISSING_OR_WRONG_COPYRIGHT", true, mapOf( "isCopyrightMandatory" to "true", - "copyrightText" to "Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.") + "copyrightText" to "Copyright (c) Huawei Technologies Co., Ltd. 2020-${LocalDate.now().year}. All rights reserved.") ), RulesConfig("HEADER_WRONG_FORMAT", true, emptyMap()) ) @@ -36,6 +37,9 @@ class HeaderCommentRuleFixTest : FixTestBase( fixAndCompare("AutoCopyrightExpected.kt", "AutoCopyrightTest.kt") } + /** + * Fixme there shouldn't be an additional blank line after copyright + */ @Test @Tag(WarningNames.HEADER_NOT_BEFORE_PACKAGE) fun `header KDoc should be moved before package`() { @@ -74,7 +78,7 @@ class HeaderCommentRuleFixTest : FixTestBase( listOf(RulesConfig(HEADER_MISSING_OR_WRONG_COPYRIGHT.name, true, mapOf( "isCopyrightMandatory" to "true", "copyrightText" to """ - | Copyright 2018-2020 John Doe. + | Copyright 2018-${LocalDate.now().year} John Doe. | | Licensed under the Apache License, Version 2.0 (the "License"); | you may not use this file except in compliance with the License. diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/HeaderCommentRuleTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/HeaderCommentRuleTest.kt index 6d8c213181..a427a349f8 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/HeaderCommentRuleTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/HeaderCommentRuleTest.kt @@ -35,11 +35,11 @@ class HeaderCommentRuleTest : LintTestBase(::HeaderCommentRule) { ) private val rulesConfigListYear: List = listOf( RulesConfig("HEADER_MISSING_OR_WRONG_COPYRIGHT", true, - mapOf("copyrightText" to "Copyright (c) 2020 My Company, Ltd. All rights reserved.")) + mapOf("copyrightText" to "Copyright (c) $curYear My Company, Ltd. All rights reserved.")) ) private val rulesConfigListCn: List = listOf( RulesConfig("HEADER_MISSING_OR_WRONG_COPYRIGHT", true, - mapOf("copyrightText" to "版权所有 (c) 华为技术有限公司 2012-2020")) + mapOf("copyrightText" to "版权所有 (c) 华为技术有限公司 2012-$curYear")) ) private val curYearCopyright = "Copyright (c) My Company, Ltd. 2012-$curYear. All rights reserved." private val copyrightBlock = """ @@ -75,7 +75,7 @@ class HeaderCommentRuleTest : LintTestBase(::HeaderCommentRule) { lintMethod( """ /* - * 版权所有 (c) 华为技术有限公司 2012-2020 + * 版权所有 (c) 华为技术有限公司 2012-$curYear */ /** * Very useful description, why this file has two classes @@ -191,7 +191,7 @@ class HeaderCommentRuleTest : LintTestBase(::HeaderCommentRule) { lintMethod( """ /* - * Copyright (c) 2020 My Company, Ltd. All rights reserved. + * Copyright (c) $curYear My Company, Ltd. All rights reserved. */ /** * Very useful description, why this file has two classes diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt index 6b8cf166bf..8492b01a95 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt @@ -4,7 +4,6 @@ import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.RulesConfigReader import org.cqfn.diktat.ruleset.constants.Warnings import org.cqfn.diktat.ruleset.constants.Warnings.EMPTY_BLOCK_STRUCTURE_ERROR -import org.cqfn.diktat.ruleset.constants.Warnings.FILE_NAME_INCORRECT import org.cqfn.diktat.ruleset.constants.Warnings.FILE_NAME_MATCH_CLASS import org.cqfn.diktat.ruleset.constants.Warnings.HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE import org.cqfn.diktat.ruleset.constants.Warnings.KDOC_NO_EMPTY_TAGS @@ -25,6 +24,8 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test +import java.time.LocalDate + import kotlinx.serialization.encodeToString typealias ruleToConfig = Map> @@ -110,7 +111,7 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", mapOf( Warnings.HEADER_MISSING_OR_WRONG_COPYRIGHT to mapOf( "isCopyrightMandatory" to "true", - "copyrightText" to """|Copyright 2018-2020 John Doe. + "copyrightText" to """|Copyright 2018-${LocalDate.now().year} John Doe. | Licensed under the Apache License, Version 2.0 (the "License"); | you may not use this file except in compliance with the License. | You may obtain a copy of the License at diff --git a/diktat-rules/src/test/resources/test/paragraph2/header/AutoCopyrightExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/header/AutoCopyrightExpected.kt index 08a3bd963a..65ed8fbd98 100644 --- a/diktat-rules/src/test/resources/test/paragraph2/header/AutoCopyrightExpected.kt +++ b/diktat-rules/src/test/resources/test/paragraph2/header/AutoCopyrightExpected.kt @@ -1,5 +1,5 @@ /* - Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. */ package test.paragraph2.header diff --git a/diktat-rules/src/test/resources/test/paragraph2/header/CopyrightDifferentYearExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/header/CopyrightDifferentYearExpected.kt index 1cf706e046..a344438ff6 100644 --- a/diktat-rules/src/test/resources/test/paragraph2/header/CopyrightDifferentYearExpected.kt +++ b/diktat-rules/src/test/resources/test/paragraph2/header/CopyrightDifferentYearExpected.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) My Company., Ltd. 2012-2020. All rights reserved. + * Copyright (c) My Company., Ltd. 2012-2021. All rights reserved. */ /** * Lorem ipsum diff --git a/diktat-rules/src/test/resources/test/paragraph2/header/MisplacedHeaderKdocAppendedCopyrightExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/header/MisplacedHeaderKdocAppendedCopyrightExpected.kt index ffe144f469..aaed183d0e 100644 --- a/diktat-rules/src/test/resources/test/paragraph2/header/MisplacedHeaderKdocAppendedCopyrightExpected.kt +++ b/diktat-rules/src/test/resources/test/paragraph2/header/MisplacedHeaderKdocAppendedCopyrightExpected.kt @@ -1,5 +1,5 @@ /* - Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. */ /** * Lorem ipsum diff --git a/diktat-rules/src/test/resources/test/paragraph2/header/MisplacedHeaderKdocExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/header/MisplacedHeaderKdocExpected.kt index ffe144f469..44ca966073 100644 --- a/diktat-rules/src/test/resources/test/paragraph2/header/MisplacedHeaderKdocExpected.kt +++ b/diktat-rules/src/test/resources/test/paragraph2/header/MisplacedHeaderKdocExpected.kt @@ -1,6 +1,8 @@ /* - Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. */ + + /** * Lorem ipsum * dolor sit amet diff --git a/diktat-rules/src/test/resources/test/paragraph2/header/MultilineCopyrightExample.kt b/diktat-rules/src/test/resources/test/paragraph2/header/MultilineCopyrightExample.kt index 1b474cbc28..db771bc4f3 100644 --- a/diktat-rules/src/test/resources/test/paragraph2/header/MultilineCopyrightExample.kt +++ b/diktat-rules/src/test/resources/test/paragraph2/header/MultilineCopyrightExample.kt @@ -1,5 +1,5 @@ /* - Copyright 2018-2020 John Doe. + Copyright 2018-2021 John Doe. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/diktat-rules/src/test/resources/test/paragraph2/header/NewlineAfterHeaderKdocExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/header/NewlineAfterHeaderKdocExpected.kt index 6b968b81f8..17d54923d7 100644 --- a/diktat-rules/src/test/resources/test/paragraph2/header/NewlineAfterHeaderKdocExpected.kt +++ b/diktat-rules/src/test/resources/test/paragraph2/header/NewlineAfterHeaderKdocExpected.kt @@ -1,6 +1,7 @@ /* - Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. */ + /** * This is a file used in unit test */ diff --git a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Expected.kt b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Expected.kt index 9a8c5546fc..e1f8ad1003 100644 --- a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Expected.kt +++ b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Expected.kt @@ -1,5 +1,5 @@ /* - Copyright 2018-2020 John Doe. + Copyright 2018-2021 John Doe. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/examples/gradle-groovy-dsl/diktat-analysis.yml b/examples/gradle-groovy-dsl/diktat-analysis.yml index a043d1d4d5..81489088da 100644 --- a/examples/gradle-groovy-dsl/diktat-analysis.yml +++ b/examples/gradle-groovy-dsl/diktat-analysis.yml @@ -81,7 +81,7 @@ enabled: true configuration: isCopyrightMandatory: true - copyrightText: 'Copyright (c) Your Company Name Here. 2010-2020' + copyrightText: 'Copyright (c) Your Company Name Here. 2010-2021' - name: HEADER_NOT_BEFORE_PACKAGE enabled: true - name: HEADER_CONTAINS_DATE_OR_AUTHOR diff --git a/examples/gradle-kotlin-dsl-multiproject/diktat-analysis.yml b/examples/gradle-kotlin-dsl-multiproject/diktat-analysis.yml index 4dfef1b0e3..1dff285a5f 100644 --- a/examples/gradle-kotlin-dsl-multiproject/diktat-analysis.yml +++ b/examples/gradle-kotlin-dsl-multiproject/diktat-analysis.yml @@ -81,7 +81,7 @@ enabled: true configuration: isCopyrightMandatory: true - copyrightText: 'Copyright (c) Your Company Name Here. 2010-2020' + copyrightText: 'Copyright (c) Your Company Name Here. 2010-2021' - name: HEADER_NOT_BEFORE_PACKAGE enabled: true - name: HEADER_CONTAINS_DATE_OR_AUTHOR diff --git a/examples/gradle-kotlin-dsl/diktat-analysis.yml b/examples/gradle-kotlin-dsl/diktat-analysis.yml index a043d1d4d5..81489088da 100644 --- a/examples/gradle-kotlin-dsl/diktat-analysis.yml +++ b/examples/gradle-kotlin-dsl/diktat-analysis.yml @@ -81,7 +81,7 @@ enabled: true configuration: isCopyrightMandatory: true - copyrightText: 'Copyright (c) Your Company Name Here. 2010-2020' + copyrightText: 'Copyright (c) Your Company Name Here. 2010-2021' - name: HEADER_NOT_BEFORE_PACKAGE enabled: true - name: HEADER_CONTAINS_DATE_OR_AUTHOR diff --git a/examples/maven/diktat-analysis.yml b/examples/maven/diktat-analysis.yml index a043d1d4d5..81489088da 100644 --- a/examples/maven/diktat-analysis.yml +++ b/examples/maven/diktat-analysis.yml @@ -81,7 +81,7 @@ enabled: true configuration: isCopyrightMandatory: true - copyrightText: 'Copyright (c) Your Company Name Here. 2010-2020' + copyrightText: 'Copyright (c) Your Company Name Here. 2010-2021' - name: HEADER_NOT_BEFORE_PACKAGE enabled: true - name: HEADER_CONTAINS_DATE_OR_AUTHOR