DOI: 10.17587/prin.14.12-23
PEP 8 Compliance Analysis for Python Open Source Projects
D. A. Kapustin, Associate Professor, kap-kapchik@mail.ru, V. V. Shvyrov, Associate Professor, slsh@i.ua, E. Yu. Suvorova, Senior Lecturer, suvorova.itstep@ya.ru, T. I. Shulyka, Assistant, shulika-tatyana@mail.ru,
Lugansk State Pedagogical University, Lugansk, 91011, Lugansk Peoples Republic
Corresponding author: Denis A. Kapustin, Associate Professor, Lugansk State Pedagogical University, Lugansk, 91011, Lugansk Peoples Republic E-mail: kap-kapchik@mail.ru
Received on October 09, 2022
Accepted on October 20, 2022
The use of the Python language in large projects in combination with modern development methodologies entails a number of tasks for checking and standardizing program code in order to improve its quality. For the Python language, PEP 8 is the current standard. Verification procedures are performed by specialized software tools — linters that use static analysis methods. This paper investigates the main violations of the PEP 8 standard in Python open source projects. In addition, an analysis was made of the effectiveness of automatic formatting of program code using the Black and YAPF formatters.
Keywords: automatic formatting, software quality, linter, static analysis, Autopep8, Black, Flake8, PEP 8, Python, YAPF
pp. 12–23
For citation:
Kapustin D. A., Shvyrov V. V., Suvorova E. Yu., Shulyka T. I. PEP 8 Compliance Analysis for Python Open Source Projects, Programmnaya Ingeneria, 2023, vol. 14, no. 1, pp. 12—23.
References:
- Agile-manifest razrabotki programmnogo obespecheniya, available at: http://agilemanifesto.org/iso/ru/manifesto.html (date of access 25.09.2022) (in Russian).
- Humble J., Farley D. Continuous Delivery: Reliable Software Releases Through Build, Test, and Deployment Automation, Addison-Wesley Professional, 2010, 512 p.
- Shahin M., Ali Babar M., Zhu L. Continuous Integration, Delivery and Deployment: A Systematic Review on Approaches, Tools, Challenges and Practices, IEEE Access, 2017, vol. 5, pp. 3909-3943. DOI: 10.1109/ACCESS.2017.2685629.
- Fowler M. Refactoring: Improving the Design of Existing Code. Boston, MA, USA, Addison-Wesley, 1999, 448 p.
- Moha N., Gueheneuc Y.-G., Duchien L., Le Meur A.-F. Decor: A method for the specification and detection of code and design smells, IEEE Transactions on Software Engineering, 2009, vol. 36, no. 1, pp. 20–36. DOI:10.1109/TSE.2009.50.
- Tahir A., Dietrich J., Counsell S., Licorish S., Yamashita A. A large scale study on how developers discuss code smells and anti-pattern in stack exchange sites // Information and Software Technology, 2020. Vol. 125. DOI: 10.1016/j.infsof.2020.106333.
- Tsantalis N., Chatzigeorgiou A. Identification of move method refactoring opportunities, IEEE Transactions on Software Engineering, 2009, vol. 35, no. 3, pp. 347-367, DOI: 10.1109/TSE.2009.1.
- Zhang M., Hall T., Baddoo N. Code bad smells: A review of current knowledge, Journal of Software Maintenance and Evolution: Research and Practice, 2011, vol. 23, no. 3, pp. 179–202. DOI: 10.1002/smr.521.
- Cousot P., Cousot R. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints, Proceedings of the 4th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, 1977, pp. 238–252. DOI:10.1145/512950.512973
- PEP 8 – Style Guide for Python Code, available at: https://peps.python.org/pep-0008/ (date of access 25.09.2022).
- Lint, available at: https://ru.wikipedia.org/wiki/Lint (date of access 25.09.2022) (in Russian).
- Johnson S. C., Hill M. Lint, C Program Checker, COMP. SCI. TECH. REP., 1978, pp. 78–90.
- Oort B., Cruz L., Aniche M., Deursen A. The Prevalence of Code Smells in Machine Learning projects, In 2021 IEEE/ACM 1st Workshop on AI Engineering - Software Engineering for AI (WAIN), 2021, IEEE, Madrid, Spain, 2021, pp. 1-8. DOI: 10.1109/WAIN52551.2021.00011.
- Oort B., Cruz L., Loni B., Deursen A. “Project smells” - Experiences in Analysing the Software Quality of ML Projects with mllint, IEEE/ACM 44th International Conference on Software Engineering: Software Engineering in Practice (ICSE-SEIP), 2022, pp. 211–220. DOI: 10.1109/ICSE-SEIP55303.2022.9794115.
- Pylint 2.15.3, available at: https://pypi.org/project/pylint/ (date of access 25.09.2022).
- Simmons A. J., Barnett S., Rivera-Villicana J., Bajaj A., Vasa R. A Large-Scale Comparative Analysis of Coding Standard Conformance in Open-Source Data Science Projects, Proceedings of the 14th ACM / IEEE International Symposium on Empirical Software Engineering and Measurement (ESEM), ser. ESEM ’20, 2020. DOI: 10.48550/arXiv.2007.08978.
- Tómasdóttir K., Aniche M., Deursen A. The Adoption of JavaScript Linters in Practice: A Case Study on ESLint, IEEE Transactions on Software Engineering, 2020, vol. 46, no. 8, pp. 863–891, DOI: 10.1109/TSE.2018.2871058.
- Bafatakis N., Boecker N., Boon W., Cabello Salazar M., Krinke J., Oznacar G., WhiteR. Python Coding Style Compliance on Stack Overflow, 2019 IEEE/ACM 16th International Conference on Mining Software Repositories (MSR), 2019, pp. 210–214. DOI: 10.1109/MSR.2019.00042.
- Stack Overflow, available at: https://stackoverflow.com/ (date of access 25.09.2022).
- Wang J., Li L., Zeller A. Better Code, Better Sharing: On the Need of Analyzing Jupyter Notebooks, 2020 IEEE/ACM 42nd International Conference on Software Engineering: New Ideas and Emerging Results (ICSE-NIER), Seoul, Korea (South), 2020, pp. 53–56. DOI: 10.48550/arXiv.1906.05234.
- flake8 5.0.4, available at: https://pypi.org/project/flake8/ (date of access 25.09.2022).
- Welcome to the Bandit documentation!, available at: https://bandit.readthedocs.io/en/latest/ (date of access 25.09.2022).
- Welcome to mypy documentation! — Mypy 0.971 documentation, available at: https://mypy.readthedocs.io/en/stable/# (date of access 25.09.2022).
- Prospector - Python Static Analysis — prospector documentation, available at: https://prospector.landscape.io/en/master/ (date of access 25.09.2022).
- pycodestyle 2.9.1, available at: https://pypi.org/project/pycodestyle/ (date of access 25.09.2022).
- Scalpel: The Python Static Anaysis Framework, available at: https://github.com/SMAT-Lab/Scalpel (date of access 25.09.2022).
- Solar appScreener, available at: https://rt-solar.ru/products/solar_appscreener/ (date of access 25.09.2022) (in Russian).
- Infowatch Appercut, available at: https://www.infowatch.ru/products/appercut (date of access 25.09.2022) (in Russian).
- АК-ВС 2, available at: https://npo-echelon.ru/production/65/4243 (date of access 25.09.2022) (in Russian).
- 150k Python Dataset, available at: https://www.sri.inf.ethz.ch/py150 (date of access 25.09.2022).
- Secure, Reliable, and Intelligent Systems Lab | SRI Group Website, available at: https://www.sri.inf.ethz.ch/ (date of access 25.09.2022).
- Kapustin D. A., Shvyrov V. V., Shulika T. I. Static Analysis of the Source Code of Python Applications, Programmnaya Ingeneria, 2022, vol. 13, no. 8, pp. 394-403. DOI: 10.17587/prin.13.394-403 (in Russian).
- E203: False positive "whitespace before : " on list slice. #373 available at: https://github.com/PyCQA/pycodestyle/issues/373?ysclid=l9g05q9uo3208795529 (date of access 25.09.2022).
- Awesome Python Code Formatters, available at: https://github.com/life4/awesome-python-code-formatters?ysclid=l9spxzn6fa971450890 (date of access 25.09.2022).
- The uncompromising code formatter, available at: https://black.readthedocs.io/en/stable/index.html (date of access 25.09.2022).
- YAPF. available at: https://github.com/google/yapf?ysclid=l6lwmy08nc686895040
- The uncompromising code formatter#Used by, available at: https://github.com/psf/black#used-by (date of access 25.09.2022).
- Soglasheniya ob imenah v Python, available at: https://docs-python.ru/tutorial/pep-rukovodstvo-stilju-koda-python/soglashenija-imenah/ (date of access 25.09.2022) (in Russian).
- GitHub Copilot available at: https://github.com/features/copilot/?ysclid=l9fx7m1bdc52707849 (date of access 25.09.2022).