code: def _snippet_ranges(cls, num_src_lines, violation_lines):
          
          current_range = (None, None)
          lines_since_last_violation = 0
          snippet_ranges = []
          for line_num in range(1, num_src_lines + 1):
  
              # If we have not yet started a snippet,
              # check if we can (is this line a violation?)
              if current_range[0] is None:
                  if line_num in violation_lines:
  
                      # Expand to include extra context, but not before line 1
                      snippet_start = max(1, line_num - cls.NUM_CONTEXT_LINES)
                      current_range = (snippet_start, None)
                      lines_since_last_violation = 0
  
              # If we are within a snippet, check if we
              # can end the snippet (have we gone enough
              # lines without hitting a violation?)
              elif current_range[1] is None:
                  if line_num in violation_lines:
                      lines_since_last_violation = 0
  
                  elif lines_since_last_violation > cls.MAX_GAP_IN_SNIPPET:
  
                      # Expand to include extra context, but not after last line
                      snippet_end = line_num - lines_since_last_violation
                      snippet_end = min(
                          num_src_lines,
                          snippet_end + cls.NUM_CONTEXT_LINES
                      )
                      current_range = (current_range[0], snippet_end)
  
                      # Store the snippet and start looking for the next one
                      snippet_ranges.append(current_range)
                      current_range = (None, None)
  
              # Another line since the last violation
              lines_since_last_violation += 1
  
          # If we started a snippet but didn't finish it, do so now
          if current_range[0] is not None and current_range[1] is None:
              snippet_ranges.append((current_range[0], num_src_lines))
  
          return snippet_ranges
docs: Given the number of source file lines and list of
          violation line numbers, return a list of snippet
          ranges of the form `(start_line, end_line)`.
  
          Each snippet contains a few extra lines of context
          before/after the first/last violation.  Nearby
          violations are grouped within the same snippet.