Skip to content

Commit

Permalink
Modernising dodgy to be a bit more python3 now that python2 is proper…
Browse files Browse the repository at this point in the history
…ly dead (tomorrow) and cleaning up some old fixes and added two PRs
  • Loading branch information
Carl Crowder committed Dec 31, 2019
1 parent d614ff8 commit fc283be
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 38 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ nosetests.xml
.mr.developer.cfg
.project
.pydevproject

# localdev helpers
env.txt
.env
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
install:
- "pip install nose coverage coveralls"
- "pip install --editable ."
Expand Down
11 changes: 0 additions & 11 deletions bin/dodgy

This file was deleted.

2 changes: 1 addition & 1 deletion dodgy/__pkginfo__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (0, 1, 10)
VERSION = (0, 2, 0)


def get_version():
Expand Down
12 changes: 0 additions & 12 deletions dodgy/configuration.py

This file was deleted.

27 changes: 17 additions & 10 deletions dodgy/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ def run_checks(directory, ignore_paths=None):
return warnings


def run(ignore_paths=None):
def run(ignore_paths=None, zero_exit=False):
warnings = run_checks(os.getcwd(), ignore_paths=ignore_paths)

if warnings:
output = json.dumps({"warnings": warnings}, indent=2)
sys.stdout.write(output + "\n")
return 1
output = json.dumps({"warnings": warnings}, indent=2)
sys.stdout.write(output + "\n")

return 0
if zero_exit:
sys.exit(0)
sys.exit(1 if warnings else 0)


def main(argv=sys.argv):
def main(argv=None):
argv = argv or sys.argv
desc = (
'A very basic tool to run against your codebase to search for "dodgy" looking values. '
"It is a series of simple regular expressions designed to detect things such as "
Expand All @@ -90,10 +90,17 @@ def main(argv=sys.argv):
metavar="IGNORE_PATH",
help="Paths to ignore",
)
args, _ = parser.parse_known_args(argv)
parser.add_argument(
"--zero-exit",
"-0",
dest="zero_exit",
help="Dodgy will exit with a code of 1 if problems are found. This flag ensures that it always returns with 0 unless an exception is raised.",
action="store_true",
)

run(ignore_paths=args.ignore)
args, _ = parser.parse_known_args(argv)

run(ignore_paths=args.ignore, zero_exit=args.zero_exit)

if __name__ == "__main__":
main()
12 changes: 9 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@
_install_requires = []

_classifiers = (
'Development Status :: 2 - Pre-Alpha',
'Development Status :: 7 - Inactive',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: Unix',
'Topic :: Software Development :: Quality Assurance',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
)

setup(
Expand All @@ -31,7 +33,11 @@
author_email='[email protected]',
description=_short_description,
install_requires=_install_requires,
scripts=['bin/dodgy'],
entry_points={
'console_scripts': [
'dodgy = dodgy.run:main',
],
},
version=__pkginfo__.get_version(),
packages=_packages,
license='MIT',
Expand Down

0 comments on commit fc283be

Please sign in to comment.