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

Formatting results in duplicated top-level documentation #741

Open
tothambrus11 opened this issue May 11, 2024 · 2 comments
Open

Formatting results in duplicated top-level documentation #741

tothambrus11 opened this issue May 11, 2024 · 2 comments

Comments

@tothambrus11
Copy link

Hi, thanks for developing this tool. I have encountered a bug that I cannot seem to fix.

When I run swift-format using the following command, all of my top-level documentation comments are duplicated to all of the top-level declarations that previously had documentation comments.

swift run swift-format --in-place -r --configuration .swift-format.json -p Sources Tests Package.swift

My .swift-format.json:

{
    "fileScopedDeclarationPrivacy": {
        "accessLevel": "private"
    },
    "indentation": {
        "spaces": 2
    },
    "indentConditionalCompilationBlocks": true,
    "indentSwitchCaseLabels": false,
    "lineBreakAroundMultilineExpressionChainComponents": false,
    "lineBreakBeforeControlFlowKeywords": false,
    "lineBreakBeforeEachArgument": false,
    "lineBreakBeforeEachGenericRequirement": false,
    "lineLength": 100,
    "maximumBlankLines": 1,
    "prioritizeKeepingFunctionOutputTogether": false,
    "respectsExistingLineBreaks": true,
    "rules": {
        "AllPublicDeclarationsHaveDocumentation": false,
        "AlwaysUseLowerCamelCase": true,
        "AmbiguousTrailingClosureOverload": true,
        "BeginDocumentationCommentWithOneLineSummary": false,
        "DoNotUseSemicolons": true,
        "DontRepeatTypeInStaticProperties": true,
        "FileScopedDeclarationPrivacy": true,
        "FullyIndirectEnum": true,
        "GroupNumericLiterals": true,
        "IdentifiersMustBeASCII": true,
        "NeverForceUnwrap": false,
        "NeverUseForceTry": false,
        "NeverUseImplicitlyUnwrappedOptionals": false,
        "NoAccessLevelOnExtensionDeclaration": true,
        "NoAssignmentInExpressions": true,
        "NoBlockComments": true,
        "NoCasesWithOnlyFallthrough": true,
        "NoEmptyTrailingClosureParentheses": true,
        "NoLabelsInCasePatterns": true,
        "NoLeadingUnderscores": false,
        "NoParensAroundConditions": true,
        "NoVoidReturnOnFunctionSignature": true,
        "OneCasePerLine": true,
        "OneVariableDeclarationPerLine": true,
        "OnlyOneTrailingClosureArgument": true,
        "OrderedImports": true,
        "ReturnVoidInsteadOfEmptyTuple": true,
        "UseEarlyExits": false,
        "UseLetInEveryBoundCaseVariable": false,
        "UseShorthandTypeNames": true,
        "UseSingleLinePropertyGetter": true,
        "UseSynthesizedInitializer": true,
        "UseTripleSlashForDocumentationComments": true,
        "UseWhereClausesInForLoops": false,
        "ValidateDocumentationComments": false
    },
    "spacesAroundRangeFormationOperators": true,
    "tabWidth": 8,
    "version": 1
}

I used the following version inside my Package.swift:

    .package(url: "https://github.com/apple/swift-format", branch: "release/5.9"),
@ahoppen
Copy link
Contributor

ahoppen commented May 11, 2024

Synced to Apple’s issue tracker as rdar://127941004

@tothambrus11
Copy link
Author

I figured out the root issue that caused this bug: I had the git config core.autocrlf turned on in WSL, so my line endings were not the same as the tool expected, even inside devcontainers (maybe it inherited some git configurations?). It would be nice if the tool either gave errors about this or it was able to handle both CRLF and LF line endings correctly. Once I turned off core.autocrlf, the problem went away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants