rapid7 / nexpose-client-python

DEPRECATED : Rapid7 Nexpose API client library written in Python
https://www.rapid7.com/
BSD 3-Clause "New" or "Revised" License
25 stars 20 forks source link

Make Python files more PEP8 compliant #14

Closed derpadoo closed 7 years ago

derpadoo commented 7 years ago

Description

Really excited for this project! After reviewing the code using a Atom's linter-pycodestyle 2.0.2 linter, I noticed there were quite a few PEP8 violations (https://www.python.org/dev/peps/pep-0008/). There is a mix of tabs/spaces for indentations, 1-2 new lines after classes/functions, testing conditional to None using "=" instead of none, and one-line if statements.

Motivation and Context

Standardizes files and makes them easier to read and debug. This is OCD, but it's better to address this early on in the project than later. In my linter config, I ignore error codes: E265, E266, E501 (http://pep8.readthedocs.io/en/release-1.7.x/intro.html). I addressed the cosmetic ones and didn't touch functional ones that I am not sure what they do, like line 1380 in nexpose.py

requestor = lambda: self.RequestSiteScanHistory(site_or_id)

I also didn't touch imports that were not at the top of the file.

How Has This Been Tested?

Ran pytest

python -m pytest
================================================== test session starts ==================================================
platform linux2 -- Python 2.7.13, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /home/user/nexpose-client-python, inifile: 
collected 27 items 

tests/test_LoadFixture.py ...
tests/test_NexposeNode.py .
tests/test_NexposeReportConfigurationSummary.py ..
tests/test_NexposeSession.py ...........
tests/test_NexposeTag.py .....
tests/test_NexposeUserAuthenticatorSummary.py .
tests/test_NexposeVulnerability.py ....

=============================================== 27 passed in 0.94 seconds ===============================================

Types of changes

Replaced tabs with 4 spaces, added new lines after functions/classes, removed one-line if statements, added/removed spaces around variables, and added two spaces after end of lines that contained comments.

Checklist:

gschneider-r7 commented 7 years ago

Thanks for this! I need to setup travis-ci to run tests and a linter as well at some point.

By the way your git config seems to have an issue based on the user associated to your commits. I'll wait for you to decide if you want to fix that or not before merging. Fixing it might involve re-playing the commits to a new branch and opening a new pull request.

derpadoo commented 7 years ago

Are you referring to the "invalid-email-address"? I'll probably create a new branch.

derpadoo commented 7 years ago

Created a new PR: https://github.com/rapid7/nexpose-client-python/pull/16

This one can be closed.