File modification checking multi-line support and cleanup

Review Request #10280 — Created Oct. 26, 2018 and updated

alextechcc
ReviewBot
master
10195
6034f4d...
reviewbot, students

Multiple TODOs have been addressed in _is_modified, so that tools
commenting on multiple lines have modifications properly checked. The
algorithm has been made more efficient, only checking relevant
(modified) chunks to see if they are in the range of modification.

A patch was also made to tools that 'globally comment' (I.E. make a
comment with a line of <=0). Previously, all this would do is round the
line number up to 1, (as the front-end does not support rendering
first_line=None), which had the unintended side-effect of tools
configured to only comment on modified code who make global comments, to
only have their comment go through if line 1 was modified. The
first_line=1 workaround is still used, and the file is assumed to be
modified.

I've tested _is_modified through my nyc plugin directly, and
tested File.comment() manually through a stub-plugin. Waiting on test
suite creation to mock up standalone tests.

  • 0
  • 0
  • 3
  • 0
  • 3
Description From Last Updated
david
  1. 
      
  2. bot/reviewbot/processing/review.py (Diff revision 1)
     
     

    "ReviewBoard" -> "Review Board"

  3. bot/reviewbot/processing/review.py (Diff revision 1)
     
     

    We generally avoid Python's ternary form because it's confusing and ugly.

  4. bot/reviewbot/processing/review.py (Diff revision 1)
     
     

    Can we have one blank line above this?

  5. 
      
alextechcc
alextechcc
Review request changed

Change Summary:

Accept negative line numbers also as global comments, assume files are modified if they're in the file diff.

Description:

   

Multiple TODOs have been addressed in _is_modified, so that tools

    commenting on multiple lines have modifications properly checked. The
    algorithm has been made more efficient, only checking relevant
    (modified) chunks to see if they are in the range of modification.

   
   

A patch was also made to tools that 'globally comment' (I.E. make a

~   comment with a line of 0). Previously, all this would do is round the
  ~ comment with a line of <=0). Previously, all this would do is round the
    line number up to 1, (as the front-end does not support rendering
    first_line=None), which had the unintended side-effect of tools
~   configured to only comment on modified code who make global comments,
~   to only have their comment go through if line 1 was modified. The
~   first_line=1 workaround is still used, but the modification check now
~   checks the whole file for modifications.

  ~ configured to only comment on modified code who make global comments, to
  ~ only have their comment go through if line 1 was modified. The
  ~ first_line=1 workaround is still used, and the file is assumed to be
  ~ modified.

Commit:

-2efa09d38cb47ee4029e6846b6eff887e45d7ce5
+6034f4d54405337210314ade90f65fe901aba48d

Diff:

Revision 3 (+23 -17)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
ilaw
  1. 
      
  2. bot/reviewbot/processing/review.py (Diff revision 3)
     
     

    Should the documentation for the line_num parameter also be changed to be re: checking and not comments?

  3. 
      
Loading...