Skip to content

the Jackson Yaml linter removes code comments #1795

Open

Description

@bnorman405

If you are submitting a bug, please include the following:

  • summary of problem
    using spotlessApply with a the jackson yaml package included removes lines in yaml files that start with #.
  • gradle or maven version
    gradle 7.5
  • spotless version
    6.21.0
  • operating system and version
    osx Ventura
  • copy-paste your full Spotless configuration block(s)
    spotless {
    java {
    palantirJavaFormat()
    // Added target as spotless was having problems with the groovy files.
    target(project.fileTree(project.rootDir) {
    include 'src//java/**/.java'
    // Excluded Controller because spotless is making it very hard to read.
    exclude '/Controller.java'
    })
    }
    json {
    target(
    '.cicd/
    /.json',
    '.primer/**/
    .json',
    'src//.json'
    )
    gson().indentWithSpaces(2)
    }
    groovy {
    importOrder('
    ', 'spock')
    excludeJava(true)
    }
    yaml {
    target 'src/
    /.yml', 'src/**/.yaml'
    jackson().yamlFeature('MINIMIZE_QUOTES', true)
    }
    }
  • copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace
    no errors

Activity

  1. aldex32 commented on Oct 8, 2023

    @aldex32

    Any plan to fix this?

  2. henrikcaesar commented on Oct 20, 2023

    @henrikcaesar

    This is perhaps related to FasterXML/jackson-dataformats-text#36 and in the end SnakeYaml?

  3. OksiBlack commented on Nov 3, 2023

    @OksiBlack

    This is really unfortunate bug, I am considering the removal of yaml step because of it.

  4. asomov commented on Feb 15, 2024

    @asomov

    @henrikcaesar SnakeYAML supports the comments.

  5. tim-oe commented on Jul 4, 2024

    @tim-oe

    +100 for fix.i lost a lot of info when running this....

  6. blacelle commented on Sep 10, 2024

    @blacelle
    Contributor

    The lack of proper comments management in yaml was initially discussed in #910, and discussed with Jackson team in FasterXML/jackson-dataformats-text#372, itself referring FasterXML/jackson-dataformats-text#36 which is still open and active.

    One may consider contributing a SnakeYAML linter (vs current Jackson linter, based on SnakeYAML).

  7. MarcoMartins86 commented on Apr 14, 2026

    @MarcoMartins86

    @blacelle, it seems they implemented minimal support for YAML comments last week and closed the mentioned threads.
    Not sure if now this means it can also be implemented here.

  8. blacelle commented on Apr 15, 2026

    @blacelle
    Contributor

    This change comes with Jackson 3.2, which should not be a big issue given Spotless classpath management, and fact is Jackson3.X has different namespace than Jackson 2.X.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions