smok-serwis/smok-client

View on GitHub

Showing 24 of 24 total issues

File client.py has 685 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime
import io
import logging
import os
import tempfile
Severity: Major
Found in smok/client/client.py - About 1 day to fix

    File communicator.py has 336 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import logging
    import queue
    import time
    import typing as tp
    
    
    Severity: Minor
    Found in smok/threads/communicator.py - About 4 hrs to fix

      Function __init__ has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, cert: tp.Union[str, io.StringIO],
                       priv_key: tp.Union[str, io.StringIO],
                       evt_database: tp.Union[str, BaseEventDatabase],
                       pp_database: tp.Optional[BasePathpointDatabase] = None,
                       macro_database: tp.Optional[BaseMacroDatabase] = None,
      Severity: Major
      Found in smok/client/client.py - About 2 hrs to fix

        Function __init__ has 23 arguments (exceeds 15 allowed). Consider refactoring.
        Open

            def __init__(self, cert: tp.Union[str, io.StringIO],
        Severity: Major
        Found in smok/client/client.py - About 1 hr to fix

          Function process_orders has a Cognitive Complexity of 56 (exceeds 50 allowed). Consider refactoring.
          Open

              def process_orders(self, orders) -> tp.List[Order]:
                  """
                  Do some orders and return those that need to be retried
                  """
                  futures_to_complete = []
          Severity: Minor
          Found in smok/threads/executor.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Avoid deeply nested control flow statements.
          Open

                                      if not isinstance(fut, Future):
                                          if fut is not None:
                                              pathpoint.set_new_value(time_ms(), fut)
                                      else:
                                          fut.add_done_callback(on_read_completed_factory(pathpoint))
          Severity: Major
          Found in smok/threads/executor.py - About 45 mins to fix

            Avoid too many return statements within this function.
            Open

                                    return {}
            Severity: Major
            Found in smok/client/api.py - About 30 mins to fix

              Blank line at end of file
              Open

              Severity: Minor
              Found in smok/extras/event_database/null.py by pep8

              Trailing blank lines are superfluous.

              Okay: spam(1)
              W391: spam(1)\n
              
              However the last line should end with a new line (warning W292).

              Unexpected indentation (comment)
              Open

                                      # multiply it by a constant, just to be safe
              Severity: Minor
              Found in smok/threads/log_publisher.py by pep8

              Use indent_size (PEP8 says 4) spaces per indentation level.

              For really old code that you don't want to mess up, you can continue
              to use 8-space tabs.
              
              Okay: a = 1
              Okay: if a == 0:\n    a = 1
              E111:   a = 1
              E114:   # a = 1
              
              Okay: for item in items:\n    pass
              E112: for item in items:\npass
              E115: for item in items:\n# Hi\n    pass
              
              Okay: a = 1\nb = 2
              E113: a = 1\n    b = 2
              E116: a = 1\n    # b = 2

              Line too long (113 > 100 characters)
              Open

                      a persistent TLS connection instead of HTTP API. This is both more efficient and bandwidth-saving instead
              Severity: Minor
              Found in smok/client/client.py by pep8

              Limit all lines to a maximum of 79 characters.

              There are still many devices around that are limited to 80 character
              lines; plus, limiting windows to 80 characters makes it possible to
              have several windows side-by-side.  The default wrapping on such
              devices looks ugly.  Therefore, please limit all lines to a maximum
              of 79 characters. For flowing long blocks of text (docstrings or
              comments), limiting the length to 72 characters is recommended.
              
              Reports error E501.

              Line too long (106 > 100 characters)
              Open

                      Prefer to call this than :meth:`smok.client.Client.provide_unknown_pathpoint`. This will be called
              Severity: Minor
              Found in smok/client/client.py by pep8

              Limit all lines to a maximum of 79 characters.

              There are still many devices around that are limited to 80 character
              lines; plus, limiting windows to 80 characters makes it possible to
              have several windows side-by-side.  The default wrapping on such
              devices looks ugly.  Therefore, please limit all lines to a maximum
              of 79 characters. For flowing long blocks of text (docstrings or
              comments), limiting the length to 72 characters is recommended.
              
              Reports error E501.

              Line too long (101 > 100 characters)
              Open

                                                       None if self.device.dont_do_orders else self.process_orders)
              Severity: Minor
              Found in smok/sync_workers/ngtt.py by pep8

              Limit all lines to a maximum of 79 characters.

              There are still many devices around that are limited to 80 character
              lines; plus, limiting windows to 80 characters makes it possible to
              have several windows side-by-side.  The default wrapping on such
              devices looks ugly.  Therefore, please limit all lines to a maximum
              of 79 characters. For flowing long blocks of text (docstrings or
              comments), limiting the length to 72 characters is recommended.
              
              Reports error E501.

              Continuation line with same indent as next logical line
              Open

                      tp.Tuple[int, ValueOrExcept]]:
              Severity: Minor
              Found in smok/pathpoint/reparse.py by pep8

              Continuation lines indentation.

              Continuation lines should align wrapped elements either vertically
              using Python's implicit line joining inside parentheses, brackets
              and braces, or using a hanging indent.
              
              When using a hanging indent these considerations should be applied:
              - there should be no arguments on the first line, and
              - further indentation should be used to clearly distinguish itself
                as a continuation line.
              
              Okay: a = (\n)
              E123: a = (\n    )
              
              Okay: a = (\n    42)
              E121: a = (\n   42)
              E122: a = (\n42)
              E123: a = (\n    42\n    )
              E124: a = (24,\n     42\n)
              E125: if (\n    b):\n    pass
              E126: a = (\n        42)
              E127: a = (24,\n      42)
              E128: a = (24,\n    42)
              E129: if (a or\n    b):\n    pass
              E131: a = (\n    42\n 24)

              Trailing spaces
              Open

              a single pathpoint (W1) and allows defining other pathpoints, 
              Severity: Info
              Found in examples/skylab/README.md by markdownlint

              MD009 - Trailing spaces

              Tags: whitespace

              Aliases: no-trailing-spaces

              Parameters: br_spaces (number; default: 0)

              This rule is triggered on any lines that end with whitespace. To fix this, find the line that is triggered and remove any trailing spaces from the end.

              The brspaces parameter allows an exception to this rule for a specific amount of trailing spaces used to insert an explicit line break/br element. For example, set brspaces to 2 to allow exactly 2 spaces at the end of a line.

              Note: you have to set brspaces to 2 or higher for this exception to take effect - you can't insert a br element with just a single trailing space, so if you set brspaces to 1, the exception will be disabled, just as if it was set to the default of 0.

              Trailing spaces
              Open

              View the [docs](https://https://smok-client.readthedocs.io/) or 
              Severity: Info
              Found in examples/skylab/README.md by markdownlint

              MD009 - Trailing spaces

              Tags: whitespace

              Aliases: no-trailing-spaces

              Parameters: br_spaces (number; default: 0)

              This rule is triggered on any lines that end with whitespace. To fix this, find the line that is triggered and remove any trailing spaces from the end.

              The brspaces parameter allows an exception to this rule for a specific amount of trailing spaces used to insert an explicit line break/br element. For example, set brspaces to 2 to allow exactly 2 spaces at the end of a line.

              Note: you have to set brspaces to 2 or higher for this exception to take effect - you can't insert a br element with just a single trailing space, so if you set brspaces to 1, the exception will be disabled, just as if it was set to the default of 0.

              Continuation line with same indent as next logical line
              Open

                      tp.Tuple[int, ValueOrExcept]]:
              Severity: Minor
              Found in smok/pathpoint/pathpoint.py by pep8

              Continuation lines indentation.

              Continuation lines should align wrapped elements either vertically
              using Python's implicit line joining inside parentheses, brackets
              and braces, or using a hanging indent.
              
              When using a hanging indent these considerations should be applied:
              - there should be no arguments on the first line, and
              - further indentation should be used to clearly distinguish itself
                as a continuation line.
              
              Okay: a = (\n)
              E123: a = (\n    )
              
              Okay: a = (\n    42)
              E121: a = (\n   42)
              E122: a = (\n42)
              E123: a = (\n    42\n    )
              E124: a = (24,\n     42\n)
              E125: if (\n    b):\n    pass
              E126: a = (\n        42)
              E127: a = (24,\n      42)
              E128: a = (24,\n    42)
              E129: if (a or\n    b):\n    pass
              E131: a = (\n    42\n 24)

              Continuation line with same indent as next logical line
              Open

                      tp.Tuple[int, SVTOrExcept]]:
              Severity: Minor
              Found in smok/sensor/sensor.py by pep8

              Continuation lines indentation.

              Continuation lines should align wrapped elements either vertically
              using Python's implicit line joining inside parentheses, brackets
              and braces, or using a hanging indent.
              
              When using a hanging indent these considerations should be applied:
              - there should be no arguments on the first line, and
              - further indentation should be used to clearly distinguish itself
                as a continuation line.
              
              Okay: a = (\n)
              E123: a = (\n    )
              
              Okay: a = (\n    42)
              E121: a = (\n   42)
              E122: a = (\n42)
              E123: a = (\n    42\n    )
              E124: a = (24,\n     42\n)
              E125: if (\n    b):\n    pass
              E126: a = (\n        42)
              E127: a = (24,\n      42)
              E128: a = (24,\n    42)
              E129: if (a or\n    b):\n    pass
              E131: a = (\n    42\n 24)

              Line too long (115 > 100 characters)
              Open

                      This will be called by the user. Note that :meth:`smok.sensor.Sensor.write` does not automatically generate
              Severity: Minor
              Found in smok/client/client.py by pep8

              Limit all lines to a maximum of 79 characters.

              There are still many devices around that are limited to 80 character
              lines; plus, limiting windows to 80 characters makes it possible to
              have several windows side-by-side.  The default wrapping on such
              devices looks ugly.  Therefore, please limit all lines to a maximum
              of 79 characters. For flowing long blocks of text (docstrings or
              comments), limiting the length to 72 characters is recommended.
              
              Reports error E501.

              Line too long (104 > 100 characters)
              Open

                  Read carefully. If the documentation states that a particular thread invokes this method, this means
              Severity: Minor
              Found in smok/client/client.py by pep8

              Limit all lines to a maximum of 79 characters.

              There are still many devices around that are limited to 80 character
              lines; plus, limiting windows to 80 characters makes it possible to
              have several windows side-by-side.  The default wrapping on such
              devices looks ugly.  Therefore, please limit all lines to a maximum
              of 79 characters. For flowing long blocks of text (docstrings or
              comments), limiting the length to 72 characters is recommended.
              
              Reports error E501.

              Line too long (115 > 100 characters)
              Open

                      To be invoked by any thread, as well as the user. Use this to inject sections into device's execution loop.
              Severity: Minor
              Found in smok/client/client.py by pep8

              Limit all lines to a maximum of 79 characters.

              There are still many devices around that are limited to 80 character
              lines; plus, limiting windows to 80 characters makes it possible to
              have several windows side-by-side.  The default wrapping on such
              devices looks ugly.  Therefore, please limit all lines to a maximum
              of 79 characters. For flowing long blocks of text (docstrings or
              comments), limiting the length to 72 characters is recommended.
              
              Reports error E501.
              Severity
              Category
              Status
              Source
              Language