Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DB637200C36 for ; Fri, 10 Mar 2017 09:26:11 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D9FBB160B79; Fri, 10 Mar 2017 08:26:11 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D8DF0160B69 for ; Fri, 10 Mar 2017 09:26:10 +0100 (CET) Received: (qmail 78850 invoked by uid 500); 10 Mar 2017 08:26:10 -0000 Mailing-List: contact commits-help@beam.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@beam.apache.org Delivered-To: mailing list commits@beam.apache.org Received: (qmail 78841 invoked by uid 99); 10 Mar 2017 08:26:10 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Mar 2017 08:26:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 91784C0912 for ; Fri, 10 Mar 2017 08:26:09 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.451 X-Spam-Level: * X-Spam-Status: No, score=1.451 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 8SrDJJ_LaZVM for ; Fri, 10 Mar 2017 08:26:07 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id E15605F295 for ; Fri, 10 Mar 2017 08:26:06 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1EC1AE095B for ; Fri, 10 Mar 2017 08:26:05 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 7D04D243B4 for ; Fri, 10 Mar 2017 08:26:04 +0000 (UTC) Date: Fri, 10 Mar 2017 08:26:04 +0000 (UTC) From: "Tibor Kiss (JIRA)" To: commits@beam.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (BEAM-1677) Extend automated PR check with PyCharm's code inspector for Python-SDK MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 10 Mar 2017 08:26:12 -0000 [ https://issues.apache.org/jira/browse/BEAM-1677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Tibor Kiss updated BEAM-1677: ----------------------------- Description: *Proposal:* Leverage PyCharm's static code analysis capabilities to detect possible errors if a Python-SDK related PR is submitted. *Problem statement:* The Python SDK test goal has linting phase, which utilizes {{pep8}} and {{pylint}} to validate PEP8 compliance and do static code analysis. These steps are helpful but {{pylint}}'s capabilities are somewhat limited compared to modern IDE's (like PyCharm). In particular: Unresolved attributes, unbound local variables and invalid calls (due to argument number mismatch) type of errors are not detected by pylint, but they do cause runtime error. See BEAM-1649 for problems not detected by pylint but reported by PyCharm. *Technical details:* PyCharm provides command line interface [1] to trigger code inspection. The results are created as entries in XML documents, containing their location, severity, category and textual description of the problem. Since the inspector reports back typos, warnings and errors it is required that the result XML files are properly parsed and filtered. A good signal-to-noise ratio is crucial for this improvement to be useful and accepted, therefore it is required to make good selection of events to minimize false positives. The filtered results shall be posted back to GitHub through Commit Status API [2] to notify the contributor and reviewer of the quality of the change. The static code analysis could be done on either Apache Build Jenkins servers or in Travis CI. *Alternatives considered:* - Eclipse's PyDev plugin [3] has similar code inspection capabilities as PyCharm. The lack of command line interface makes it difficult to integrate it with the current build system. - SonarQUBE's Python plugin [4] was briefly investigated. The number of rules seems very limited compared to PyCharm's code analysis. *Required changes:* - PyCharm to be installed in Jenkins Slave or Travis-CI's container - PyCharm project & inspection profile created for Python SDK - Result parser & poster application/script created - Trigger to run the result parser & poster set up *Example Code Analysis* run on OS X (given a PyCharm project is available in beam/sdks/python/.idea directory): {code} beam/sdks/python $ /Applications/PyCharm.app/Contents/MacOS/pycharm inspect $(pwd) $(pwd)/.idea/inspectionProfiles/Project_Default.xml $(pwd)/inspection-results -v2 -d $(pwd)/apache_beam {code} *Example result:* {code:title=PyUnresolvedReferencesInspection.xml} file://$PROJECT_DIR$/apache_beam/io/range_trackers.py 342 python Unresolved references Unresolved attribute reference '_end_position' for class 'OrderedPositionRangeTracker' {code} *References:* [1] PyCharm Command Line Interface: https://www.jetbrains.com/help/pycharm/2016.3/command-line-code-inspector.html [2] GitHub Commit Status API: https://developer.github.com/v3/repos/statuses/ [3] Eclipse PyDev Plugin: http://www.pydev.org/manual_adv_code_analysis.html [4] SonarQUBE Python plugin: https://www.sonarsource.com/why-us/products/codeanalyzers/sonarpython/rules.html CC: [~altay] / [~jbonofre] / [~jasonkuster] was: *Proposal:* Leverage PyCharm's static code analysis capabilities to detect possible errors if a Python-SDK related PR is submitted. *Problem statement:* The Python SDK test goal has linting phase, which utilizes {{pep8}} and {{pylint}} to validate PEP8 compliance and do static code analysis. These steps are helpful but {{pylint}}'s capabilities are somewhat limited compared to modern IDE's (like PyCharm). In particular: Unresolved attributes, unbound local variables and invalid calls (due to argument number mismatch) type of errors are not detected by pylint, but they do cause runtime error. See BEAM-1649 for problems not detected by pylint but reported by PyCharm. *Technical details:* PyCharm provides command line interface [1] to trigger code inspection. The results are created as entries in XML documents, containing their location, severity, category and textual description of the problem. Since the inspector reports back typos, warnings and errors it is required that the result XML files are properly parsed and filtered. A good signal-to-noise ratio is crucial for this improvement to be useful and accepted, therefore it is required to make good selection of events to minimize false positives. The filtered results shall be posted back to GitHub through Commit Status API [2] to notify the contributor and reviewer of the quality of the change. The static code analysis could be done on either Apache Build Jenkins servers or in Travis CI. *Alternatives considered:* - Eclipse's PyDev plugin [3] has similar code inspection capabilities as PyCharm. The lack of command line interface makes it difficult to integrate it with the current build system. - SonarQUBE's Python plugin [4] was briefly investigated. The number of rules seems very limited compared to PyCharm's code analysis. *Required changes:* - PyCharm to be installed in Jenkins Slave or Travis-CI's container - PyCharm project & inspection profile created for Python SDK - Result parser & poster application/script created - Trigger to run the result parser & poster set up *Example Code Analysis* run on OS X (given a PyCharm project is available in beam/sdks/python/.idea directory): {code} beam/sdks/python $ /Applications/PyCharm.app/Contents/MacOS/pycharm inspect $(pwd) $(pwd)/.idea/inspectionProfiles/Project_Default.xml $(pwd)/inspection-results -v2 -d $(pwd)/apache_beam {code} *Example result:* {code title="PyUnresolvedReferencesInspection.xml"} file://$PROJECT_DIR$/apache_beam/io/range_trackers.py 342 python Unresolved references Unresolved attribute reference '_end_position' for class 'OrderedPositionRangeTracker' {code} *References:* [1] PyCharm Command Line Interface: https://www.jetbrains.com/help/pycharm/2016.3/command-line-code-inspector.html [2] GitHub Commit Status API: https://developer.github.com/v3/repos/statuses/ [3] Eclipse PyDev Plugin: http://www.pydev.org/manual_adv_code_analysis.html [4] SonarQUBE Python plugin: https://www.sonarsource.com/why-us/products/codeanalyzers/sonarpython/rules.html CC: [~altay] / [~jbonofre] / [~jasonkuster] > Extend automated PR check with PyCharm's code inspector for Python-SDK > ---------------------------------------------------------------------- > > Key: BEAM-1677 > URL: https://issues.apache.org/jira/browse/BEAM-1677 > Project: Beam > Issue Type: Improvement > Components: build-system > Reporter: Tibor Kiss > > *Proposal:* > Leverage PyCharm's static code analysis capabilities to detect possible errors if a Python-SDK related PR is submitted. > *Problem statement:* > The Python SDK test goal has linting phase, which utilizes {{pep8}} and {{pylint}} to validate PEP8 compliance and do static code analysis. These steps are helpful but {{pylint}}'s capabilities are somewhat limited compared to modern IDE's (like PyCharm). > In particular: Unresolved attributes, unbound local variables and invalid calls (due to argument number mismatch) type of errors are not detected by pylint, but they do cause runtime error. See BEAM-1649 for problems not detected by pylint but reported by PyCharm. > *Technical details:* > PyCharm provides command line interface [1] to trigger code inspection. The results are created as entries in XML documents, containing their location, severity, category and textual description of the problem. > Since the inspector reports back typos, warnings and errors it is required that the result XML files are properly parsed and filtered. > A good signal-to-noise ratio is crucial for this improvement to be useful and accepted, therefore it is required to make good selection of events to minimize false positives. > > The filtered results shall be posted back to GitHub through Commit Status API [2] to notify the contributor and reviewer of the quality of the change. > > The static code analysis could be done on either Apache Build Jenkins servers or in Travis CI. > > *Alternatives considered:* > - Eclipse's PyDev plugin [3] has similar code inspection capabilities as PyCharm. The lack of command line interface makes it difficult to integrate it with the current build system. > - SonarQUBE's Python plugin [4] was briefly investigated. The number of rules seems very limited compared to PyCharm's code analysis. > > *Required changes:* > - PyCharm to be installed in Jenkins Slave or Travis-CI's container > - PyCharm project & inspection profile created for Python SDK > - Result parser & poster application/script created > - Trigger to run the result parser & poster set up > > *Example Code Analysis* run on OS X (given a PyCharm project is available in beam/sdks/python/.idea directory): > {code} > beam/sdks/python $ /Applications/PyCharm.app/Contents/MacOS/pycharm inspect $(pwd) $(pwd)/.idea/inspectionProfiles/Project_Default.xml $(pwd)/inspection-results -v2 -d $(pwd)/apache_beam > {code} > > *Example result:* > {code:title=PyUnresolvedReferencesInspection.xml} > > file://$PROJECT_DIR$/apache_beam/io/range_trackers.py > 342 > python > > Unresolved references > Unresolved attribute reference '_end_position' for class 'OrderedPositionRangeTracker' > > {code} > > *References:* > [1] PyCharm Command Line Interface: https://www.jetbrains.com/help/pycharm/2016.3/command-line-code-inspector.html > [2] GitHub Commit Status API: https://developer.github.com/v3/repos/statuses/ > [3] Eclipse PyDev Plugin: http://www.pydev.org/manual_adv_code_analysis.html > [4] SonarQUBE Python plugin: https://www.sonarsource.com/why-us/products/codeanalyzers/sonarpython/rules.html > > CC: [~altay] / [~jbonofre] / [~jasonkuster] -- This message was sent by Atlassian JIRA (v6.3.15#6346)