audreyfeldroy / audreyfeldroy/complexity
Better handling of empty context/*.json files
- Dominant language
- Python
- Stars
- 118
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
If a context json file is empty, you get:
```
Traceback (most recent call last):
File "/home/travis/build/audreyr/complexity/tests/test_main.py", line 43, in test_conf_proj2_with_complexity
main.complexity('tests/conf_proj2')
File "/home/travis/build/audreyr/complexity/complexity/main.py", line 66, in complexity
context = generate_context(context_dir)
File "/home/travis/build/audreyr/complexity/complexity/generate.py", line 167, in generate_context
obj = json.load(f)
File "/usr/lib/python3.3/json/__init__.py", line 274, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib/python3.3/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.3/json/decoder.py", line 352, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.3/json/decoder.py", line 370, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
```
Contributor guide
Research direction
Start with tests/test_main.py, especially test_conf_proj2_with_complexity, and reproduce the failure using an empty context/*.json file. Read complexity/generate.py around generate_context and its json.load call. Done should be defined as handling the empty file without the shown ValueError, with a regression test covering that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100