Skip to content

#5651 [core] add IDE agnostic configuration with editorconfig.org - editorconfig-maven-plugin#5635

Closed
Pankraz76 wants to merge 1 commit into
pmd:mainfrom
Pankraz76:editorconfig
Closed

#5651 [core] add IDE agnostic configuration with editorconfig.org - editorconfig-maven-plugin#5635
Pankraz76 wants to merge 1 commit into
pmd:mainfrom
Pankraz76:editorconfig

Conversation

@Pankraz76

@Pankraz76 Pankraz76 commented Mar 25, 2025

Copy link
Copy Markdown
Contributor

#5651 [core] add IDE agnostic configuration with editorconfig.org - editorconfig-maven-plugin

implement IDE agnostic configuration with editorconfig.org

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

[INFO] --- editorconfig:0.1.3:check (editorconfig-check) @ pmd-dist ---

happy test:
image

negative test: indent_style = tab
image

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for PMD 7.14.0-SNAPSHOT:
[INFO] 
[INFO] PMD ................................................ SUCCESS [ 19.087 s]
[INFO] PMD Core ........................................... SUCCESS [ 17.330 s]
[INFO] PMD Test Schema .................................... SUCCESS [  2.410 s]
[INFO] PMD Ant Integration ................................ SUCCESS [  2.340 s]
[INFO] PMD Test Framework ................................. SUCCESS [  2.748 s]
[INFO] PMD language module testing utilities .............. SUCCESS [ 10.017 s]
[INFO] PMD Apex ........................................... SUCCESS [ 17.840 s]
[INFO] PMD Coco ........................................... SUCCESS [ 36.114 s]
[INFO] PMD C++ ............................................ SUCCESS [  4.413 s]
[INFO] PMD C# ............................................. SUCCESS [  2.341 s]
[INFO] PMD Dart ........................................... SUCCESS [  5.498 s]
[INFO] PMD Fortran ........................................ SUCCESS [  9.789 s]
[INFO] PMD Gherkin ........................................ SUCCESS [  3.755 s]
[INFO] PMD Go ............................................. SUCCESS [  2.424 s]
[INFO] PMD Groovy ......................................... SUCCESS [  2.032 s]
[INFO] PMD HTML ........................................... SUCCESS [  2.350 s]
[INFO] PMD Java ........................................... SUCCESS [ 46.460 s]
[INFO] PMD JavaScript ..................................... SUCCESS [  9.371 s]
[INFO] PMD JSP ............................................ SUCCESS [  4.018 s]
[INFO] PMD Julia .......................................... SUCCESS [  4.122 s]
[INFO] PMD Kotlin ......................................... SUCCESS [  6.604 s]
[INFO] PMD Lua ............................................ SUCCESS [  2.122 s]
[INFO] PMD Matlab ......................................... SUCCESS [  2.134 s]
[INFO] PMD Modelica ....................................... SUCCESS [  6.303 s]
[INFO] PMD Objective-C .................................... SUCCESS [  2.493 s]
[INFO] PMD Perl ........................................... SUCCESS [  1.787 s]
[INFO] PMD PHP ............................................ SUCCESS [  1.724 s]
[INFO] PMD PL/SQL ......................................... SUCCESS [ 18.654 s]
[INFO] PMD Python ......................................... SUCCESS [  2.436 s]
[INFO] PMD Ruby ........................................... SUCCESS [  1.946 s]
[INFO] PMD Rust ........................................... SUCCESS [  2.140 s]
[INFO] PMD Scala Common Source and Settings ............... SUCCESS [  0.522 s]
[INFO] PMD Scala for Scala 2.13 ........................... SUCCESS [  4.733 s]
[INFO] PMD Swift .......................................... SUCCESS [  5.991 s]
[INFO] PMD TSql ........................................... SUCCESS [  2.498 s]
[INFO] PMD Visualforce .................................... SUCCESS [  7.848 s]
[INFO] PMD Velocity Template Language (VTL) ............... SUCCESS [  4.973 s]
[INFO] PMD XML and XSL .................................... SUCCESS [  3.128 s]
[INFO] PMD Languages Dependencies ......................... SUCCESS [  1.085 s]
[INFO] PMD Documentation Generator (internal) ............. SUCCESS [  5.815 s]
[INFO] PMD Scala for Scala 2.12 ........................... SUCCESS [  4.523 s]
[INFO] PMD CLI ............................................ SUCCESS [  2.122 s]
[INFO] PMD Distribution Packages .......................... SUCCESS [  4.088 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  05:00 min
[INFO] Finished at: 2025-04-25T13:28:41+02:00
[INFO] ------------------------------------------------------------------------

@Pankraz76 Pankraz76 changed the title add .Editorconfig implement IDE agnostic configuration with editorconfig.org Mar 25, 2025
@Pankraz76

Copy link
Copy Markdown
Contributor Author

This is just to reconsider this generic config.
It won't break anything, in my opinion, as my local setup only works when this is applied.
Otherwise, Checkstyle will tell me what is wrong. This is the config to align Checkstyle rules with an out-of-the-box working configuration.

@Pankraz76 Pankraz76 changed the title implement IDE agnostic configuration with editorconfig.org implement IDE agnostic configuration with editorconfig.org Mar 25, 2025
@github-actions

github-actions Bot commented Mar 25, 2025

Copy link
Copy Markdown

Documentation Preview

No regression tested rules have been changed.

@Pankraz76

Copy link
Copy Markdown
Contributor Author

POC: #5636

[INFO] --- editorconfig:0.1.3:check (default-cli) @ pmd-dist ---
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'pom.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/ant-it/build.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-modelica.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-plsql.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-html.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-visualforce.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-velocity.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-apex.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-javascript.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-xsl.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/sample-ruleset.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-java.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-pom.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-xml.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/rulesets/all-jsp.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/test/resources/sample-source/xml/samplecode.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/main/resources/assemblies/pmd-src.xml'
[WARNING] org.ec4j.linters.XmlLinter expects both indent_style and indent_size to be set for file 'src/main/resources/assemblies/pmd-bin.xml'
[INFO] Checked 49 files
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for PMD 7.12.0-SNAPSHOT:
[INFO] 
[INFO] PMD ................................................ SUCCESS [  0.620 s]
[INFO] PMD Core ........................................... SUCCESS [  0.147 s]
[INFO] PMD Test Schema .................................... SUCCESS [  0.007 s]
[INFO] PMD Ant Integration ................................ SUCCESS [  0.008 s]
[INFO] PMD Test Framework ................................. SUCCESS [  0.008 s]
[INFO] PMD language module testing utilities .............. SUCCESS [  0.009 s]
[INFO] PMD Apex ........................................... SUCCESS [  0.091 s]
[INFO] PMD Coco ........................................... SUCCESS [  0.016 s]
[INFO] PMD C++ ............................................ SUCCESS [  0.014 s]
[INFO] PMD C# ............................................. SUCCESS [  0.012 s]
[INFO] PMD Dart ........................................... SUCCESS [  0.010 s]
[INFO] PMD Fortran ........................................ SUCCESS [  0.006 s]
[INFO] PMD Gherkin ........................................ SUCCESS [  0.011 s]
[INFO] PMD Go ............................................. SUCCESS [  0.013 s]
[INFO] PMD Groovy ......................................... SUCCESS [  0.008 s]
[INFO] PMD HTML ........................................... SUCCESS [  0.022 s]
[INFO] PMD Java ........................................... SUCCESS [  0.373 s]
[INFO] PMD JavaScript ..................................... SUCCESS [  0.047 s]
[INFO] PMD JSP ............................................ SUCCESS [  0.019 s]
[INFO] PMD Julia .......................................... SUCCESS [  0.007 s]
[INFO] PMD Kotlin ......................................... SUCCESS [  0.011 s]
[INFO] PMD Lua ............................................ SUCCESS [  0.006 s]
[INFO] PMD Matlab ......................................... SUCCESS [  0.008 s]
[INFO] PMD Modelica ....................................... SUCCESS [  0.021 s]
[INFO] PMD Objective-C .................................... SUCCESS [  0.006 s]
[INFO] PMD Perl ........................................... SUCCESS [  0.003 s]
[INFO] PMD PHP ............................................ SUCCESS [  0.002 s]
[INFO] PMD PL/SQL ......................................... SUCCESS [  0.080 s]
[INFO] PMD Python ......................................... SUCCESS [  0.006 s]
[INFO] PMD Ruby ........................................... SUCCESS [  0.004 s]
[INFO] PMD Rust ........................................... SUCCESS [  0.004 s]
[INFO] PMD Scala Common Source and Settings ............... SUCCESS [  0.038 s]
[INFO] PMD Scala for Scala 2.13 ........................... SUCCESS [  0.002 s]
[INFO] PMD Swift .......................................... SUCCESS [  0.021 s]
[INFO] PMD TSql ........................................... SUCCESS [  0.006 s]
[INFO] PMD Visualforce .................................... SUCCESS [  0.022 s]
[INFO] PMD Velocity Template Language (VTL) ............... SUCCESS [  0.014 s]
[INFO] PMD XML and XSL .................................... SUCCESS [  0.013 s]
[INFO] PMD Languages Dependencies ......................... SUCCESS [  0.001 s]
[INFO] PMD Documentation Generator (internal) ............. SUCCESS [  0.008 s]
[INFO] PMD Scala for Scala 2.12 ........................... SUCCESS [  0.001 s]
[INFO] PMD CLI ............................................ SUCCESS [  0.014 s]
[INFO] PMD Distribution Packages .......................... SUCCESS [  0.013 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.291 s
[INFO] Finished at: 2025-03-25T10:15:53+01:00
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

@Pankraz76 Pankraz76 marked this pull request as ready for review March 25, 2025 09:33
@Pankraz76

Pankraz76 commented Mar 25, 2025

Copy link
Copy Markdown
Contributor Author

note/question: ij_continuation_indent_size

this should fail:
ij_continuation_indent_size = 6
image

this seems correct as no format change:
ij_continuation_indent_size = 4
image

Comment thread .editorconfig
@adangel adangel changed the title implement IDE agnostic configuration with editorconfig.org Fix #5651: Implement IDE agnostic configuration with editorconfig.org Apr 25, 2025
@adangel

adangel commented Apr 25, 2025

Copy link
Copy Markdown
Member

as my local setup only works when this is applied.

Can you elaborate on what is not working? Do we need to update the documentation https://docs.pmd-code.org/latest/pmd_devdocs_building_intellij.html ?

@Pankraz76

Pankraz76 commented Apr 25, 2025

Copy link
Copy Markdown
Contributor Author

ATM its configuration over convention, but actually we want the opposite approach convention over configuration.

The setting-up-checkstyle file is needed, as it will evolve into the new .editorconfig - as the keys are 1o1 the same, like discussed in: checkstyle/checkstyle#16349 (comment)

@Pankraz76 Pankraz76 changed the title Fix #5651: Implement IDE agnostic configuration with editorconfig.org #5651 [java] Implement IDE agnostic configuration with editorconfig Apr 25, 2025
Comment thread .editorconfig

[*]
charset = utf-8
# end_of_line = lf

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be revised later or before merge, if possible.

[ERROR] docs/assets/fontawesome-free-5.15.4-web/webfonts/fa-brands-400.woff2@567,93: Replace 'cr' with 'lf' - violates end_of_line = lf, reported by org.ec4j.linters.TextLinter
[ERROR] docs/assets/fontawesome-free-5.15.4-web/webfonts/fa-brands-400.woff2@568,111: Replace 'cr' with 'lf' - violates end_of_line = lf, reported by org.ec4j.linters.TextLinter
[ERROR] docs/assets/fontawesome-free-5.15.4-web/webfonts/fa-brands-400.woff2@575,24: Delete 1 character - violates end_of_line = lf, reported by org.ec4j.linters.TextLinter
[ERROR] docs/assets/fontawesome-free-5.15.4-web/webfonts/fa-brands-400.woff2@576,349: Insert lf - violates insert_final_newline = true, reported by org.ec4j.linters.TextLinter
[ERROR] docs/assets/anchorjs-4.2.2/anchor.min.js@9,16: Insert lf - violates insert_final_newline = true, reported by org.ec4j.linters.TextLinter
[ERROR] docs/assets/navgoco-0.2.1/src/jquery.navgoco.min.js@8,3373: Insert lf - violates insert_final_newline = true, reported by org.ec4j.linters.TextLinter
[ERROR] docs/assets/navgoco-0.2.1/src/jquery.navgoco.css@69,2: Insert lf - violates insert_final_newline = true, reported by org.ec4j.linters.TextLinter

Some of our files need to be raw and violating; therefore excluded:

  • <exclude>src/test/resources/com/puppycrawl/tools/checkstyle/grammar/InputAstRegressionNewlineCrAtEndOfFile.java</exclude>
  • <exclude>src/test/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/**/*</exclude>

@Pankraz76 Pankraz76 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kindly request some feedback.

Comment thread .editorconfig
ij_java_doc_preserve_line_breaks = true
ij_java_imports_layout = $*, |, java.**, |, javax.**, |, org.**, |, com.**, |, *
ij_java_line_comment_add_space = true
ij_java_line_comment_at_first_column = false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />

Comment thread .editorconfig
ij_java_doc_do_not_wrap_if_one_line = true
ij_java_doc_preserve_line_breaks = true
ij_java_imports_layout = $*, |, java.**, |, javax.**, |, org.**, |, com.**, |, *
ij_java_line_comment_add_space = true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<option name="LINE_COMMENT_ADD_SPACE" value="true" />

Comment thread .editorconfig
ij_java_line_comment_at_first_column = false
ij_java_names_count_to_use_import_on_demand = 999
ij_java_packages_to_use_import_on_demand = unset
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />

Comment thread .editorconfig
ij_java_class_count_to_use_import_on_demand = 999
ij_java_doc_do_not_wrap_if_one_line = true
ij_java_doc_preserve_line_breaks = true
ij_java_imports_layout = $*, |, java.**, |, javax.**, |, org.**, |, com.**, |, *

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<option name="IMPORT_LAYOUT_TABLE">

Comment thread .editorconfig
ij_java_imports_layout = $*, |, java.**, |, javax.**, |, org.**, |, com.**, |, *
ij_java_line_comment_add_space = true
ij_java_line_comment_at_first_column = false
ij_java_names_count_to_use_import_on_demand = 999

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500" />

Comment thread .editorconfig
ij_java_line_comment_add_space = true
ij_java_line_comment_at_first_column = false
ij_java_names_count_to_use_import_on_demand = 999
ij_java_packages_to_use_import_on_demand = unset

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
      <value />
    </option>

its the same keys, @Anmol202005, if not to much special stuff done here, its a easy job to adapt:
image

Pankraz76 added a commit to Pankraz76/build-tools that referenced this pull request Apr 25, 2025
@Pankraz76 Pankraz76 changed the title #5651 [java] Implement IDE agnostic configuration with editorconfig #5651 [java] Implement IDE agnostic configuration with editorconfig Apr 25, 2025
@Pankraz76 Pankraz76 changed the title #5651 [java] Implement IDE agnostic configuration with editorconfig #5651 [core] add IDE agnostic configuration with editorconfig.org - editorconfig-maven-plugin Apr 25, 2025
@Pankraz76

Copy link
Copy Markdown
Contributor Author

its nice to have things work out of the box, so this is still a benefit but double trouble to keep config in sync.

Rewrite has ability to dominate this so lets.

might reopen.

@Pankraz76 Pankraz76 closed this May 14, 2025
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.

[core] add IDE agnostic configuration

2 participants