Skip to content

feat(#1271): run Java lints from YAML packs via lint key - #1277

Open
VasilevNStas wants to merge 4 commits into
objectionary:masterfrom
VasilevNStas:fix/issue-1271-lint-packs
Open

feat(#1271): run Java lints from YAML packs via lint key#1277
VasilevNStas wants to merge 4 commits into
objectionary:masterfrom
VasilevNStas:fix/issue-1271-lint-packs

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

fix #1271

What

Adds support for running Java-implemented lints from the same YAML pack
format that XSL lints use, instead of requiring a bespoke Lt*Test.java
class per lint.

A pack can now reference a lint by name:

lint: ascii-only
asserts:
  - /defects[count(defect[@severity='warning'])=1]
document: |
  <object author="tests">
    <comments>
      <comment line="1">привет</comment>
    </comments>
  </object>

How

  • New XtLint (a Xtory): reads the lint: key from the pack YAML,
    resolves the lint via PkMono, runs defects(XML) and serializes the
    result into the <defects> document. It plugs into the existing
    Xsline/XtoryMatcher/DefectsMatcher machinery by returning a
    Shift that produces the defects, so XtDefects (the defects: N
    shorthand) and all existing assertions work unchanged.
  • LtByXslTest:
    • new testsAllLintsByLintName parameterized test runs packs with a
      lint: key;
    • testsAllLintsByEo and checksLocationsOfYamlPacks skip such packs
      (they have no sheets/XSL counterpart).

Demo packs

The following Java lints are now covered declaratively:

  • ascii-onlycatches-cyrillic-comment
  • reserved-nameallows-custom-name
  • incorrect-unlintcatches-unknown-lint
  • syntax-versioncatches-newer-syntax, allows-older-syntax

This is the pattern @volodya-lombrozo proposed for LtSyntaxVersion and
friends, so future Java lints (and the existing ones) can drop their
hand-written JUnit boilerplate.

Both mvn test (1011 tests) and mvn clean install -Pqulice pass.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 @volodya-lombrozo plz review

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

Successfully merging this pull request may close these issues.

YAML fixtures limited to XSL-based lints, leading to unnecessary JUnit classes for Java-implemented lints

1 participant