lf-lang / lingua-franca

Intuitive concurrent programming in any language
https://www.lf-lang.org
Other
228 stars 62 forks source link

VS Code extension reports an unreasonable number of warnings on generated code #2241

Open petervdonovan opened 6 months ago

petervdonovan commented 6 months ago

The solution is probably to clean up the generated code.

Incidentally, the LSP test also fails in addition to printing all of these extraneous warnings. It seems likely that these two problems are related because in general, failures in basic lints may prevent other lints from even running.

The following is an excerpt from CI logs:

    Cleaning /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/include/src/federate__a
    --- Current working directory: /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src-gen/federate__a
    --- Executing command: pylint --output-format=json federate__a.py
    MockReportProgress: Code generation complete. The executable is at "/home/runner/work/lingua-franca/lingua-franca/test/Python/bin/DistributedNoReact". [33 -> 100]
    Test client received diagnostic at line 0: ##### Generating code for federate federate__a in directory /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src
    Test client received diagnostic at line 0: ##### Generating code for federate federate__b in directory /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src
    Test client received diagnostic at line 0: ******** Using 1 threads to compile the program.
    Test client received diagnostic at line 0: Generating code for: file:/home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src/federate__a.lf
    Test client received diagnostic at line 0: Generation mode: LSP_MEDIUM
    Test client received diagnostic at line 0: Generating sources into: /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src-gen/federate__a
    Test client received diagnostic at line 0: Target Configuration:
          - _fed_setup: include/_federate__a_preamble.h
          - keepalive: true
          - single-threaded: false
          - compile-definitions: {EXECUTABLE_PREAMBLE=, FEDERATED=, FEDERATED_CENTRALIZED=, NUMBER_OF_FEDERATES=2, FEDERATE_ID=0}
          - timeout: 2 sec
          - docker: DockerOptions[enabled=false, from=, rti=lflang/rti:rti, preBuildCmd=]

LspTests > pythonValidationTest() STANDARD_ERROR
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:27:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:28:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:36:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:37:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:45:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:46:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:54:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:55:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:63:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:64:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:72:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:73:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:81:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:82:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:90:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:91:1]

LspTests > pythonValidationTest() STANDARD_OUT
    Test client received diagnostic at line 5: Missing class docstring [federate__a.py:26:1]
    Test client received diagnostic at line 5: Too few public methods (0/2) [federate__a.py:26:1]
    Test client received diagnostic at line 0: Import "import gc" should be placed at the top of the module [federate__a.py:29:1]
    Test client received diagnostic at line 0: Import "import atexit" should be placed at the top of the module [federate__a.py:30:1]
    Test client received diagnostic at line 5: Missing class docstring [federate__a.py:35:1]

LspTests > pythonValidationTest() STANDARD_ERROR
    Test client received diagnostic at line 5: class already defined line 26 [federate__a.py:35:1]

LspTests > pythonValidationTest() STANDARD_OUT
    Test client received diagnostic at line 5: Too few public methods (0/2) [federate__a.py:35:1]

    Test client received diagnostic at line 0: Imports from package atexit are not grouped [federate__a.py:75:1]
    Test client received diagnostic at line 0: Imports from package gc are not grouped [federate__a.py:83:1]
    Test client received diagnostic at line 0: Imports from package atexit are not grouped [federate__a.py:84:1]
    Test client received diagnostic at line 0: Imports from package gc are not grouped [federate__a.py:92:1]
    Test client received diagnostic at line 0: Imports from package atexit are not grouped [federate__a.py:93:1]
    Test client received diagnostic at line 0: Generating code for: file:/home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src/federate__b.lf
    Test client received diagnostic at line 0: Generation mode: LSP_MEDIUM
    Test client received diagnostic at line 0: Generating sources into: /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src-gen/federate__b
    Test client received diagnostic at line 0: Target Configuration:
          - _fed_setup: include/_federate__b_preamble.h
          - keepalive: true
          - single-threaded: false
          - compile-definitions: {EXECUTABLE_PREAMBLE=, FEDERATED=, FEDERATED_CENTRALIZED=, NUMBER_OF_FEDERATES=2, FEDERATE_ID=1}
          - timeout: 2 sec
          - docker: DockerOptions[enabled=false, from=, rti=lflang/rti:rti, preBuildCmd=]
    Test client received diagnostic at line 0: Script for launching the federation: /home/runner/work/lingua-franca/lingua-franca/test/Python/bin/DistributedNoReact

LspTests > pythonValidationTest() STANDARD_ERROR
    Test client received diagnostic at line 0: Failure during code generation of /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src/federate__a.lf
    Test client received diagnostic at line 0: Failure during code generation of /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src/federate__b.lf

LspTests > pythonValidationTest() STANDARD_OUT
    Expecting an error to be reported at line 18... but the expected error could not be found.
    /home/runner/work/lingua-franca/lingua-franca/test/Python/src/federated/DistributedNoReact.lf failed. Content of altered version of /home/runner/work/lingua-franca/lingua-franca/test/Python/src/federated/DistributedNoReact.lf:
    ------------------------------------------------------------------------------

        0 target Python {
        1   timeout: 2 sec
        2 }
        3 
        4 preamble {=
        5   class C:
        6     def __init__(self):
        7       pass
        8 =}
        9 
       10 reactor A {
       11   input o
       12 }
       13 
       14 reactor B {
       15   output o
       16 
       17   reaction(startup) -> o {=
    -> 18         ..
       19     o.set(C())
       20   =}
       21 }
       22 
       23 federated reactor {
       24   a = new A()
       25   b = new B()
       26   b.o -> a.o
       27 }
petervdonovan commented 3 months ago

The other day @lhstrh reported something similar here:

LspTests > pythonValidationTest() STANDARD_ERROR
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:27:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:28:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:36:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:37:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:45:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:46:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:54:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:55:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:63:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:64:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:72:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:73:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:81:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:82:1]
    Test client received diagnostic at line 6: Bad indentation. Found 2 spaces, expected 4 [federate__a.py:90:1]
    Test client received diagnostic at line 7: Bad indentation. Found 4 spaces, expected 8 [federate__a.py:91:1]

LspTests > pythonValidationTest() STANDARD_OUT
    Test client received diagnostic at line 5: Missing class docstring [federate__a.py:26:1]
    Test client received diagnostic at line 5: Too few public methods (0/2) [federate__a.py:26:1]
    Test client received diagnostic at line 0: Import "import gc" should be placed at the top of the module [federate__a.py:29:1]
    Test client received diagnostic at line 0: Import "import atexit" should be placed at the top of the module [federate__a.py:30:1]
    Test client received diagnostic at line 5: Missing class docstring [federate__a.py:35:1]

LspTests > pythonValidationTest() STANDARD_ERROR
    Test client received diagnostic at line 5: class already defined line 26 [federate__a.py:35:1]

LspTests > pythonValidationTest() STANDARD_OUT
    Test client received diagnostic at line 5: Too few public methods (0/2) [federate__a.py:35:1]

LspTests > pythonValidationTest() STANDARD_ERROR
    Test client received diagnostic at line 0: Reimport 'gc' (imported line 29) [federate__a.py:38:1]

    Test client received diagnostic at line 0: Imports from package gc are not grouped [federate__a.py:92:1]
    Test client received diagnostic at line 0: Imports from package atexit are not grouped [federate__a.py:93:1]
    Test client received diagnostic at line 0: Generating code for: file:/home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src/federate__b.lf
    Test client received diagnostic at line 0: Generation mode: LSP_MEDIUM
    Test client received diagnostic at line 0: Generating sources into: /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src-gen/federate__b
    Test client received diagnostic at line 0: Target Configuration:
          - _fed_setup: include/_federate__b_preamble.h
          - keepalive: true
          - single-threaded: false
          - compile-definitions: {EXECUTABLE_PREAMBLE=, NUMBER_OF_FEDERATES=2, FEDERATE_ID=1, FEDERATED=, FEDERATED_CENTRALIZED=, _LF_FEDERATE_NAMES_COMMA_SEPARATED=\"federate__a,federate__b\"}
          - timeout: 2 sec
          - docker: DockerOptions[enabled=false, from=, run=, rti=lflang/rti:rti]
    Test client received diagnostic at line 0: Script for launching the federation: /home/runner/work/lingua-franca/lingua-franca/test/Python/bin/DistributedNoReact

LspTests > pythonValidationTest() STANDARD_ERROR
    Test client received diagnostic at line 0: Failure during code generation of /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src/federate__a.lf
    Test client received diagnostic at line 0: Failure during code generation of /home/runner/work/lingua-franca/lingua-franca/test/Python/fed-gen/DistributedNoReact/src/federate__b.lf

LspTests > pythonValidationTest() STANDARD_OUT
    Expecting an error to be reported at line 18... but the expected error could not be found.
    /home/runner/work/lingua-franca/lingua-franca/test/Python/src/federated/DistributedNoReact.lf failed. Content of altered version of /home/runner/work/lingua-franca/lingua-franca/test/Python/src/federated/DistributedNoReact.lf:
    ------------------------------------------------------------------------------

        0 target Python {
        1   timeout: 2 sec
        2 }
        3 
        4 preamble {=
        5   class C:
        6     def __init__(self):
        7       pass
        8 =}
        9 
       10 reactor A {
       11   input o
       12 }
       13 
       14 reactor B {
       15   output o
       16 
       17   reaction(startup) -> o {=
    -> 18         +++++;
       19     o.set(C())
       20   =}
       21 }
       22 
       23 federated reactor {
       24   a = new A()
       25   b = new B()
       26   b.o -> a.o
       27 }

    ------------------------------------------------------------------------------

LspTests > pythonValidationTest() FAILED