Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add alphabetical order check for use statements #7265
Thank you for your PR. Unfortunately, this can't land until we have all these failures fixed. Is that something you'd like to work on?
Reviewed 1 of 1 files at r1.
Comments from the review on Reviewable.io
Should be all good now ...
I started doing all the fixes manually ... then used this script (my 2nd python script ever!):
import os from tempfile import mkstemp from shutil import move from os import remove, close def replace_uses(file_path): #Create temp file fh, abs_path = mkstemp() with open(abs_path,'w') as new_file: with open(file_path) as old_file: uses =  for line in old_file: if line.lstrip().startswith("use "): uses.append(line[:len(line)-2]) else: if len(uses) > 0: new_file.write("".join([u + ";\n" for u in sorted(uses)])) uses =  new_file.write(line) close(fh) #Remove original file remove(file_path) #Move new file move(abs_path, file_path) # navigate the entire directories and replace uses for root, subdirs, files in os.walk("./"): for f in files: if f.endswith(".rs"): filePath = os.path.join(root, f) replace_uses(filePath)
@Ms2ger let me know if I must squash everything