galCohen88 / pycharm-jenkinsfile

PyCharm Jenkinsfile highlighting
39 stars 13 forks source link

Incorrect braces highlighting in Jenkins file #6

Open oleg-kondaurov opened 3 years ago

oleg-kondaurov commented 3 years ago

What steps will reproduce the issue?

  1. Create the Jenkins file with attached code block
  2. Move the cursor to the first opening brace

What is the expected result? The first opening and the last closing braces are highlighted together

What happens instead? The first opening brace and brace somewhere inside the inner shell script are highlighted together

        stage('Linter') {
            dir('kyiv-qa-tests') {
                sh """
                    . ./venv/bin/activate
                    export CORE_ROOT=${WORKSPACE}/kyiv-qa-core
                    export TESTS_ROOT=${WORKSPACE}/kyiv-qa-tests
                    export PYTHONPATH=${WORKSPACE}/kyiv-qa-core:${WORKSPACE}/kyiv-qa-tests
                    export TEST_LOG_ROOT=${WORKSPACE}/kyiv-qa-tests/test_results
                    set -x # enable echo
                    ../kyiv-qa-core/bin/lint ../kyiv-qa-core/lib/ > framework_core_lint.txt
                    ./bin/lint plugins/ tests/ setup_config/ tools/ > framework_tests_lint.txt
                    echo "Total Core Linter Warnings:" >> framework_report.txt
                    cat framework_core_lint.txt | wc -l >> framework_report.txt
                    echo "Total Tests Linter Warnings:" >> framework_report.txt
                    cat framework_tests_lint.txt | wc -l >> framework_report.txt
                """
                CORE_LINT_ERR = sh(script:"""cat ../kyiv-qa-core/framework_core_lint.txt | wc -l""", returnStdout: true).trim()
                TESTS_LINT_ERR = sh(script:"""cat framework_tests_lint.txt | wc -l""", returnStdout: true).trim()
                //TODO Compare with the same values from the last successful artifacts
            }
        }

image image

galCohen88 commented 3 years ago

@oleg-kondaurov This will not reproduce with pycharm professional 2019.1:

image

What version are you using?

oleg-kondaurov commented 3 years ago

@galCohen88

PyCharm 2020.3.3 (Community Edition)
Build #PC-203.7148.72, built on January 27, 2021
Runtime version: 11.0.9.1+11-b1145.77 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-67-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 1914M
Cores: 12
Non-Bundled Plugins: GrepConsole, String Manipulation, bundled-pycharm-help, com.intellij.ideolog, com.jetbrains.plugins.ini4idea, mobi.hsz.idea.gitignore, name.kropp.intellij.makefile, Docker, com.millennialmedia.intellibot, ru.meanmail.plugin.requirements
Current Desktop: KDE

Try to place the cursor after the stage('Linter') { brace.

galCohen88 commented 3 years ago

Screen Shot 2021-03-26 at 16 23 27

Looks fine to me, can you please post the entire Jenkins file?

galCohen88 commented 3 years ago

@oleg-kondaurov ^

oleg-kondaurov commented 3 years ago

@galCohen88

node('TB2') {
    try {
        stage('Linter') {
            dir('kyiv-qa-tests') {
                sh """
                    . ./venv/bin/activate
                    export CORE_ROOT=${WORKSPACE}/kyiv-qa-core
                    export TESTS_ROOT=${WORKSPACE}/kyiv-qa-tests
                    export PYTHONPATH=${WORKSPACE}/kyiv-qa-core:${WORKSPACE}/kyiv-qa-tests
                    export TEST_LOG_ROOT=${WORKSPACE}/kyiv-qa-tests/test_results
                    set -x # enable echo
                    ../kyiv-qa-core/bin/lint ../kyiv-qa-core/lib/ > framework_core_lint.txt
                    ./bin/lint plugins/ tests/ setup_config/ tools/ > framework_tests_lint.txt
                    echo "Total Core Linter Warnings:" >> framework_report.txt
                    cat framework_core_lint.txt | wc -l >> framework_report.txt
                    echo "Total Tests Linter Warnings:" >> framework_report.txt
                    cat framework_tests_lint.txt | wc -l >> framework_report.txt
                """
                CORE_LINT_ERR = sh(script:"""cat ../kyiv-qa-core/framework_core_lint.txt | wc -l""", returnStdout: true).trim()
                TESTS_LINT_ERR = sh(script:"""cat framework_tests_lint.txt | wc -l""", returnStdout: true).trim()
                //TODO Compare with the same values from the last successful artifacts
            }
        }
    } catch(e) {
            currentBuild.result = 'FAILURE'
            throw e
    }  finally {
        if (fileExists("kyiv-qa-tests/framework_core_lint.txt") || fileExists("kyiv-qa-tests/framework_core_lint.txt")) {
              LINT_ERR = CORE_LINT_ERR.toInteger() + TESTS_LINT_ERR.toInteger()
        } else {
              LINT_ERR = "N/A"
        }
        TOTAL_ERRORS = "lint=${LINT_ERR}"

        currentBuild.description =  "[${TOTAL_ERRORS}]"
    }
}
galCohen88 commented 3 years ago

@oleg-kondaurov I'll try installing CE, and see if it reproduce.

Screen Shot 2021-03-26 at 21 19 35

galCohen88 commented 3 years ago

@oleg-kondaurov I tried it on CE and managed reproducing the issue. It looks like CE problem since we have <option name="HAS_BRACES" value="true" /> && <option name="HAS_BRACKETS" value="true" /> in place. All the rest is out of our hands (especially considering this is working fine with other PC versions).

oleg-kondaurov commented 3 years ago

@galCohen88 Do you need any other help to solve this issue?

galCohen88 commented 3 years ago

@oleg-kondaurov if you have any idea how to solve it / have investigation lead, feel free creating a PR and I'll merge it