Skip to content

Commit

Permalink
Enable checking of line length
Browse files Browse the repository at this point in the history
  • Loading branch information
treiher committed Aug 17, 2023
1 parent 33b0c51 commit e00eee9
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ VSIX ?= ide/vscode/recordflux.vsix
GENERATED_DIR = generated
BUILD_GENERATED_DIR := $(MAKEFILE_DIR)/$(BUILD_DIR)/$(GENERATED_DIR)
PYTHON_PACKAGES = bin doc/language_reference/conf.py doc/user_guide/conf.py examples/apps ide language rflx tests tools stubs setup.py
DEVUTILS_HEAD = ee74c35d71f4153aa58ab2b7efc8342c97d8ce31
DEVUTILS_HEAD = 838aa808eab2ca88799182875934376f4c77dcfc
GNATCOLL_HEAD = 25459f07a2e96eb0f28dcfd5b03febcb72930987
LANGKIT_HEAD = 65e2dab678b2606e3b0eada64b7ef4fd8cae91bb
ADASAT_HEAD = f948e2271aec51f9313fa41ff3c00230a483f9e8
Expand Down
2 changes: 1 addition & 1 deletion doc/language_reference/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
""",
""", # noqa: E501
"class": "",
},
],
Expand Down
2 changes: 1 addition & 1 deletion doc/user_guide/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
""",
""", # noqa: E501
"class": "",
},
],
Expand Down
2 changes: 1 addition & 1 deletion ide/gnatstudio/recordflux.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
</contextual>
</GNAT_Studio>
"""
""" # noqa: E501

GPS.parse_xml(XML)

Expand Down
2 changes: 1 addition & 1 deletion rflx/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -3735,7 +3735,7 @@ def to_ir(self, variable_id: Generator[ID, None, None]) -> ir.ComplexExpr:

for choice, expr in self.choices:
e_stmts, e_expr = _to_ir_basic_expr(expr, variable_id)
# TODO(eng/recordflux/RecordFlux#633): Add check for unsupported case expressions to model
# TODO(eng/recordflux/RecordFlux#633): Check for unsupported case expressions in model
assert not e_stmts
cs: list[ir.BasicExpr]
if isinstance(self.expr.type_, rty.Enumeration):
Expand Down
3 changes: 2 additions & 1 deletion rflx/generator/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2422,7 +2422,8 @@ def _assign_to_field_access(
)

fatal_fail(
f'unexpected type ({field_access.type_}) for "{field_access}" in assignment of "{target}"',
f'unexpected type ({field_access.type_}) for "{field_access}"'
f' in assignment of "{target}"',
Subsystem.GENERATOR,
location=target.location,
)
Expand Down
6 changes: 4 additions & 2 deletions rflx/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,8 @@ def substituted(self, mapping: Mapping[ID, ID]) -> IntCall:
)

def to_z3_expr(self) -> z3.ArithRef:
# TODO(eng/recordflux/RecordFlux#1338): Return value need not to be identical for identical arguments
# TODO(eng/recordflux/RecordFlux#1338): Return value need not to be identical
# The return value may be different even if the arguments are the same.
expression = z3.Int(str(self.identifier))
return -expression if self.negative else expression

Expand All @@ -1229,7 +1230,8 @@ def substituted(self, mapping: Mapping[ID, ID]) -> BoolCall:
)

def to_z3_expr(self) -> z3.BoolRef:
# TODO(eng/recordflux/RecordFlux#1338): Return value need not to be identical for identical arguments
# TODO(eng/recordflux/RecordFlux#1338): Return value need not to be identical
# The return value may be different even if the arguments are the same.
return z3.Bool(str(self.identifier))


Expand Down
10 changes: 6 additions & 4 deletions rflx/ls/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ class Token:
----------
symbol: The symbol referenced by this token.
lexeme: A string representation of the token in the file.
line_number: An integer indicating the line at which the token is located in the file starting from 1.
character_offset: An integer indicating the character offset from the begining of the line at which the first character of the lexeme is located starting from 1.
line_number: An integer indicating the line at which the token is located in the file
starting from 1.
character_offset: An integer indicating the character offset from the begining of the line
at which the first character of the lexeme is located starting from 1.
"""

symbol: Optional[Symbol]
Expand Down Expand Up @@ -52,7 +54,7 @@ def tokens(self) -> list[Token]:
return self._tokens

def search_token(self, line_number: int, character_offset: int) -> Optional[Token]:
"""Return the token located at (line_numer, character_offset) if it exists, otherwise return None."""
"""Return the token at the given location if it exists, otherwise return None."""

if len(self._tokens) == 0:
return None
Expand Down Expand Up @@ -98,7 +100,7 @@ def search_token(self, line_number: int, character_offset: int) -> Optional[Toke
return None

def tokenize(self, source: str, path: str = "<stdin>") -> None:
"""Take a source string and turn it into a list of tokens accessible via the LSLexer.tokens() method."""
"""Convert a string into a list of tokens that can be accessed via the tokens property."""

unit = rflx_lang.AnalysisContext().get_from_buffer(
path,
Expand Down
3 changes: 2 additions & 1 deletion rflx/ls/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class Symbol:
Arguments:
---------
identifier: The unique identifier associated to the symbol.
category: A SymbolCategory indicating the type (message, session, numeric, enumeration...) of the symbol.
category: A SymbolCategory indicating the type (message, session, numeric, enumeration...)
of the symbol.
definition_location: A Location indicating where the symbol is defined.
parent: A optional ID indicating if the cur
"""
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def test_parse_no_subsequent_errors_caused_by_style_errors(tmp_path: Path) -> No

with pytest.raises(
RecordFluxError,
match=rf"^{a}:12:0: style: error: unexpected keyword indentation \(expected 3, 12 or 15\) \[indentation\]$",
match=(
r"^"
rf"{a}:12:0: style: error: unexpected keyword indentation \(expected 3, 12 or 15\)"
r" \[indentation\]"
r"$"
),
):
cli.parse([a])
2 changes: 1 addition & 1 deletion tests/unit/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def generator_mock(
monkeypatch.setattr(
generator.Generator,
"generate",
lambda self, model, integration, directory, library_files, top_level_package: None, # noqa: ARG005
lambda self, model, integration, directory, library_files, top_level_package: None, # noqa: ARG005, E501
)
assert (
cli.main(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/generator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ def _update_str(self) -> None:
pragma Finalization;
goto Finalize_S;
end if;\
""",
""", # noqa: E501
),
(
ir.Assign(
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/graph_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def test_dot_graph_with_condition(tmp_path: Path) -> None:
)
expected = """
digraph "P::M" {
graph [bgcolor="#00000000", pad="0.1", ranksep="0.1 equally", splines=true, truecolor=true];
graph [bgcolor="#00000000", pad="0.1", ranksep="0.1 equally", splines=true,
truecolor=true];
edge [color="#6f6f6f", fontcolor="#6f6f6f", fontname="Fira Code", penwidth="2.5"];
node [color="#6f6f6f", fillcolor="#009641", fontcolor="#ffffff", fontname=Arimo,
shape=box, style="rounded,filled", width="1.5"];
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/specification/parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ def test_parse_ethernet_spec() -> None:
"_kind": "ID",
"name": {
"_kind": "UnqualifiedID",
"_value": "Type_Length_TPID",
"_value": "Type_Length_TPID", # noqa: E501
},
"package": None,
},
Expand Down Expand Up @@ -1510,7 +1510,7 @@ def test_parse_ethernet_spec() -> None:
"_kind": "ID",
"name": {
"_kind": "UnqualifiedID",
"_value": "Type_Length_TPID",
"_value": "Type_Length_TPID", # noqa: E501
},
"package": None,
},
Expand Down Expand Up @@ -1718,7 +1718,7 @@ def test_parse_ethernet_spec() -> None:
"identifier": {
"_kind": "ID",
"name": {
"_kind": "UnqualifiedID",
"_kind": "UnqualifiedID", # noqa: E501
"_value": "Payload",
},
"package": None,
Expand Down Expand Up @@ -1756,7 +1756,7 @@ def test_parse_ethernet_spec() -> None:
"identifier": {
"_kind": "ID",
"name": {
"_kind": "UnqualifiedID",
"_kind": "UnqualifiedID", # noqa: E501
"_value": "Payload",
},
"package": None,
Expand Down

0 comments on commit e00eee9

Please sign in to comment.