mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-23 21:25:50 +00:00
chore: Fix pre commit hook failing on empty file (#2766)
This commit is contained in:
@@ -49,6 +49,7 @@ IndentFunctionDeclarationAfterType: false
|
|||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
IndentWrappedFunctionNames: false
|
IndentWrappedFunctionNames: false
|
||||||
IndentRequiresClause: true
|
IndentRequiresClause: true
|
||||||
|
InsertNewlineAtEOF: true
|
||||||
RequiresClausePosition: OwnLine
|
RequiresClausePosition: OwnLine
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
MaxEmptyLinesToKeep: 1
|
MaxEmptyLinesToKeep: 1
|
||||||
|
|||||||
@@ -44,8 +44,13 @@ def fix_colon_spacing(cpp_content: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def fix_indentation(cpp_content: str) -> str:
|
def fix_indentation(cpp_content: str) -> str:
|
||||||
|
if "JSON(" not in cpp_content:
|
||||||
|
return cpp_content
|
||||||
|
|
||||||
lines = cpp_content.splitlines()
|
lines = cpp_content.splitlines()
|
||||||
|
|
||||||
|
ends_with_newline = cpp_content.endswith('\n')
|
||||||
|
|
||||||
def find_indentation(line: str) -> int:
|
def find_indentation(line: str) -> int:
|
||||||
return len(line) - len(line.lstrip())
|
return len(line) - len(line.lstrip())
|
||||||
|
|
||||||
@@ -66,7 +71,11 @@ def fix_indentation(cpp_content: str) -> str:
|
|||||||
break
|
break
|
||||||
lines[i] = lines[i][by_how_much:] if by_how_much > 0 else " " * (-by_how_much) + lines[i]
|
lines[i] = lines[i][by_how_much:] if by_how_much > 0 else " " * (-by_how_much) + lines[i]
|
||||||
|
|
||||||
return "\n".join(lines) + "\n"
|
result = "\n".join(lines)
|
||||||
|
|
||||||
|
if ends_with_newline:
|
||||||
|
result += "\n"
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def process_file(file_path: Path, dry_run: bool) -> bool:
|
def process_file(file_path: Path, dry_run: bool) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user