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

Properties itemPrefix and lineSeparator of class org.jetbrains.changelog.Changelog.Item are unused #181

Closed
rybak opened this issue Jul 7, 2023 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@rybak
Copy link

rybak commented Jul 7, 2023

Describe the bug
Class org.jetbrains.changelog.Changelog.Item has two unused properties: itemPrefix and lineSeparator. They are only used by private function copy to pass the value to the constructor.

To Reproduce

  1. Add the following code to src/test/kotlin/org/jetbrains/changelog/ChangelogTesting.kt in the repository:
package org.jetbrains.changelog

fun main() {
    val changelog = Changelog(
        "", null, null, null, ChangelogPluginConstants.UNRELEASED_TERM, ChangelogPluginConstants.GROUPS,
        ChangelogPluginConstants.SEM_VER_REGEX,
        "+ This prefix from Changelog is used: ",
        null, { _, _, _, _ -> "" },
        "\n\n" // <---- this line separator is used
    )

    println(
        changelog.renderItem(
            Changelog.Item(
                "", "", "", false, mapOf("Example section" to setOf("Example", "of", "list")),
                " this itemPrefix is ignored", " the line separator from Item is ignored too"
            ),
            Changelog.OutputType.MARKDOWN
        )
    )
}
  1. Launch function main()

Actual behavior
Output of the program uses the values of itemPrefix and lineSeparator from class Changelog:

## 



### Example section

+ This prefix from Changelog is used:  Example

+ This prefix from Changelog is used:  of

+ This prefix from Changelog is used:  list


though user of class Item might expect the values passed into the constructor to be used.

Expected behavior
Class Changelog.Item doesn't have the unused properties. Even though I'm experimenting with using the class Item directly, I'm OK with just dropping these properties, which would lead to a compilation error on upgrade, if the class is used directly.

Starting to use the properties doesn't seem useful. It might break changelog formatting unexpectedly after an upgrade, unlike a compilation error if they were just removed.

Maybe a deprecation period could be used, with eventual removal.

Additional context
Even though function renderItem() calls with(item), properties itemPrefix and lineSeparator are private in class Item, so properties with the same name of the class Changelog get used in lines:

                yield(lineSeparator)
// [...]
                            .map { "$itemPrefix $it" }
@rybak rybak added the bug Something isn't working label Jul 7, 2023
@hsz hsz added this to the 2.2.2 milestone Jul 10, 2023
hsz added a commit that referenced this issue Jul 10, 2023
…brains.changelog.Changelog.Item` constructor #181
@hsz
Copy link
Member

hsz commented Jul 10, 2023

Thank you for highlighting that, Andrei. I set them deprecated.

@hsz hsz closed this as completed Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants