de-jcup / eclipse-jenkins-editor

Jenkins Editor - A eclipse plugin to edit "Jenkinsfile" files
https://marketplace.eclipse.org/content/jenkins-editor
Apache License 2.0
45 stars 5 forks source link

Source formatter fails for more than one variable in one line #104

Closed de-jcup closed 1 month ago

de-jcup commented 1 month ago

Situation

With V1.11.0 a source formatter was introduced, which does ignore curly brackets in variables. But it has a problem when it comes to multiple occurrences in one line:

callGradleWrapper("ensureLocalhostCertificate build generateOpenapi buildDeveloperAdminUI -x :sechub-cli:build -Psechub.test.wiremock.https_port=${env.SECHUB_TEST_WIREMOCK_HTTPS_PORT} -Psechub.test.wiremock.http_port=${env.SECHUB_TEST_WIREMOCK_HTTP_PORT} --console=plain")

is currently formatted to

   callGradleWrapper("ensureLocalhostCertificate build generateOpenapi buildDeveloperAdminUI -x :sechub-cli:build -Psechub.test.wiremock.https_port=________START_VARESCAPE____env.SECHUB_TEST_WIREMOCK_HTTPS_PORT
                              }
                              -Psechub.test.wiremock.http_port=$ {
                                   env.SECHUB_TEST_WIREMOCK_HTTP_PORT________END___VARESCAPE___ --console=plain")

which means

  1. the source code has handled varaibles like blocks
  2. also does try to format them as well!
  3. is not able to remove old escape sequences

Analyze

The problem is the used regular expression.

Wanted

No matter how many variables are in one line, the escaping/unescaping must work always correct.

Solution

  1. Do not use a regular expression here, implement logic inside instead.
  2. Create more unit tests