Correctly return line counts in the FileDiffCollectionMixin

Review Request #10099 — Created July 24, 2018 and submitted

Information

Review Board
release-4.0.x
b2f5893...

Reviewers

The FileDiffCollectionMixin incorrectly assumed that counts would
always be integers. However, before chunks are generated, some line
counts may be None. This patch works around that limitation and
returns the correct result for that case. Unit tests have been added to
test this behaviour.

Ran unit tests.

Description From Last Updated

E501 line too long (81 > 79 characters)

reviewbotreviewbot

F841 local variable 'filediffs' is assigned to but never used

reviewbotreviewbot

This would be nicer as: if value: if counts[key] is None: counts[key] = value else: counts[key] += value

chipx86chipx86

Missing a test docstring.

chipx86chipx86

Is this the start of a brand new set of tests? If so, it should be its own test.

chipx86chipx86

F821 undefined name 'commits'

reviewbotreviewbot

F821 undefined name 'commits'

reviewbotreviewbot

F821 undefined name 'diffset'

reviewbotreviewbot

F821 undefined name 'commits'

reviewbotreviewbot

F821 undefined name 'commits'

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

F821 undefined name 'diffset'

reviewbotreviewbot

F821 undefined name 'diffset'

reviewbotreviewbot

F821 undefined name 'commits'

reviewbotreviewbot

F821 undefined name 'commits'

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

brennie
chipx86
  1. 
      
  2. reviewboard/diffviewer/models/mixins.py (Diff revision 2)
     
     
     
     
     
     
    Show all issues

    This would be nicer as:

    if value:
        if counts[key] is None:
            counts[key] = value
        else:
            counts[key] += value
    
  3. Show all issues

    Missing a test docstring.

  4. reviewboard/diffviewer/tests/test_models_mixins.py (Diff revision 2)
     
     
     
     
     
     
     
     
     
     
    Show all issues

    Is this the start of a brand new set of tests? If so, it should be its own test.

  5. 
      
brennie
Review request changed
Change Summary:

Addressed feedback.

Commit:
35647a0eb4bd6008cd6ddd7c440847f04f1d75b6
fb4a24af3a0d32fe4e27cca790011e21b8e46756

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

brennie
chipx86
  1. Ship It!
  2. 
      
brennie
Review request changed
Status:
Completed
Change Summary:
Pushed to release-4.0.x (27146e0)