Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
Nfsaavedra committed Apr 22, 2024
1 parent 8e21c24 commit 18fb1ac
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 17 deletions.
8 changes: 5 additions & 3 deletions glitch/analysis/design/duplicate_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ def check(self, element: CodeElement, file: str) -> List[Error]:
if i not in checked:
line = self.__get_line(i, lines)
error = Error(
"design_duplicate_block", element, element.path, self.code_lines[line - 1]
"design_duplicate_block",
element,
element.path,
self.code_lines[line - 1],
)
error.line = line
errors.append(error)
checked.update(range(i, i + 150))


return errors
return errors
7 changes: 6 additions & 1 deletion glitch/analysis/design/improper_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ def check(self, element: CodeElement, file: str) -> List[Error]:
errors: List[Error] = []
for i, line in enumerate(self.code_lines):
if "\t" in line:
error = Error("implementation_improper_alignment", element, element.path, repr(element))
error = Error(
"implementation_improper_alignment",
element,
element.path,
repr(element),
)
error.line = i + 1
errors.append(error)
return errors
Expand Down
3 changes: 1 addition & 2 deletions glitch/analysis/design/long_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class TooManyVariables(DesignSmellChecker):

def check(self, element: CodeElement, file: str) -> List[Error]:
if isinstance(element, AtomicUnit) and element.type in DesignVisitor.EXEC:
lines = 0
Expand All @@ -18,4 +17,4 @@ def check(self, element: CodeElement, file: str) -> List[Error]:
if lines > 7:
return [Error("design_long_resource", element, file, repr(element))]

return []
return []
8 changes: 5 additions & 3 deletions glitch/analysis/design/long_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ def check(self, element: CodeElement, file: str) -> List[Error]:
if isinstance(element, UnitBlock) and element.type != UnitBlockType.block:
for i, line in enumerate(self.code_lines):
if len(line) > 140:
error = Error("implementation_long_statement", element, element.path, line)
error = Error(
"implementation_long_statement", element, element.path, line
)
error.line = i + 1
errors.append(error)
return errors

return errors
14 changes: 10 additions & 4 deletions glitch/analysis/design/multifaceted_abstraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@


class TooManyVariables(DesignSmellChecker):

def check(self, element: CodeElement, file: str) -> List[Error]:
if isinstance(element, AtomicUnit) and element.type in DesignVisitor.EXEC:
if isinstance(element.name, str) and (
"&&" in element.name or ";" in element.name or "|" in element.name
):
return [
Error("design_multifaceted_abstraction", element, file, repr(element))
Error(
"design_multifaceted_abstraction", element, file, repr(element)
)
]
else:
for attribute in element.attributes:
value = repr(attribute.value)
if "&&" in value or ";" in value or "|" in value:
return [
Error("design_multifaceted_abstraction", element, file, repr(element))
Error(
"design_multifaceted_abstraction",
element,
file,
repr(element),
)
]

return []
return []
11 changes: 9 additions & 2 deletions glitch/analysis/design/too_many_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@ def check(self, element: CodeElement, file: str) -> List[Error]:
if (
self.__count_variables(element.variables) / max(len(self.code_lines), 1) > 0.3 # type: ignore
):
return [Error("implementation_too_many_variables", element, element.path, repr(element))]
return []
return [
Error(
"implementation_too_many_variables",
element,
element.path,
repr(element),
)
]
return []
7 changes: 5 additions & 2 deletions glitch/analysis/design/unguarded_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class UnguardedVariable(DesignSmellChecker):
def check(self, element: CodeElement, file: str) -> List[Error]:
errors: List[Error] = []

if isinstance(element, UnitBlock) and DesignVisitor.VAR_REFER_SYMBOL is not None:
if (
isinstance(element, UnitBlock)
and DesignVisitor.VAR_REFER_SYMBOL is not None
):
# FIXME could be improved if we considered strings as part of the model
for i, l in enumerate(self.code_lines):
for tuple in re.findall(
Expand All @@ -30,4 +33,4 @@ def check(self, element: CodeElement, file: str) -> List[Error]:
error.line = i + 1
errors.append(error)

return errors
return errors

0 comments on commit 18fb1ac

Please sign in to comment.