Showing 118 of 118 total issues

Function _interface_solve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _interface_solve(self, beacon_info: RouteInterfaceInfo, method, parameters, request_body_schema):
        if beacon_info.va_query:
            for k, v in beacon_info.va_query._fields.items():
                parameters.append(self._schematics_field_to_parameter(k, v))

Severity: Minor
Found in slim/ext/openapi/main.py - About 45 mins 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

Function current_user has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def current_user(self) -> BaseUser:
        if not self.can_get_user:
            raise NoUserViewMixinException("Current View should inherited from `BaseUserViewMixin` or it's subclasses")
        if not self._current_user:
            func = getattr(self, 'get_current_user', None)
Severity: Minor
Found in slim/base/_view/base_view.py - About 45 mins 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

Function set_secure_cookie has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def set_secure_cookie(self, name, value, *, httponly=True, max_age=30 * 24 * 60 * 60):
Severity: Minor
Found in slim/base/_view/base_view.py - About 35 mins to fix

    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, title='slim application', description='', license=None, version='1.0.0',
    Severity: Minor
    Found in slim/base/types/doc.py - About 35 mins to fix

      Function make_mocked_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def make_mocked_request(method, path: str, *, headers: Dict[str, str] = None, body: bytes = None):
      Severity: Minor
      Found in slim/tools/test.py - About 35 mins to fix

        Function doRequest has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            async function doRequest (url, method, params, data = null, role = null) {
        Severity: Minor
        Found in slim_cli/template/tools/netapi.js - About 35 mins to fix

          Function check_is_me has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def check_is_me(ability, user, action, record: DataRecord, available_columns: list):
          Severity: Minor
          Found in slim_cli/template/permissions/tables/user.py - About 35 mins to fix

            Function check_query_permission_full has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def check_query_permission_full(self, user: "BaseUser", table: str, ability: "Ability", view: "AbstractSQLView", ignore_error=True):
            Severity: Minor
            Found in slim/base/sqlquery.py - About 35 mins to fix

              Function can_with_record has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def can_with_record(self, user, action, record: DataRecord, *, available=None) -> set:
              Severity: Minor
              Found in slim/base/permission.py - About 35 mins to fix

                Function finish_raw has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def finish_raw(self, data: Union[bytes, str, StreamReadFunc] = b'', status: int = 200, content_type: str = 'text/plain', *,
                Severity: Minor
                Found in slim/base/_view/base_view.py - About 35 mins to fix

                  Function cooldown has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def cooldown(interval_value_or_func, redis_key_template, *, unique_id_func=default_unique_id_func, cd_if_unsuccessed=None):
                  Severity: Minor
                  Found in slim/ext/decorator.py - About 35 mins to fix

                    Function finish has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def finish(self, code: int, data=sentinel, msg=sentinel, *, headers=None):
                    Severity: Minor
                    Found in slim/base/_view/base_view.py - About 35 mins to fix

                      Function timer has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def timer(interval_seconds, app: 'Application', *, exit_when, loop=None):
                      Severity: Minor
                      Found in slim/ext/decorator.py - About 35 mins to fix

                        Function _parse_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _parse_id(self, custom_id):
                                if type(custom_id) == str:
                                    if len(custom_id) != 24:
                                        raise TypeError
                                    custom_id = binascii.unhexlify(bytes(custom_id, 'utf-8'))
                        Severity: Minor
                        Found in slim/utils/customid.py - About 35 mins 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

                        Function _parse_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _parse_id(self, object_id):
                                if type(object_id) == str:
                                    if len(object_id) != 24:
                                        raise TypeError
                                    object_id = binascii.unhexlify(bytes(object_id, 'utf-8'))
                        Severity: Minor
                        Found in slim/utils/myobjectid.py - About 35 mins 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

                        Function request_role has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def request_role(self, user: Optional[BaseUser], role) -> Optional[Ability]:
                                # '' 视为 None 的等价角色
                                if role == '':
                                    role = None
                        
                        
                        Severity: Minor
                        Found in slim/base/permission.py - About 35 mins 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

                        Function query_ws_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def query_ws_path(self, path) -> Tuple[Union[RouteWebsocketInfo, None], Optional[Dict]]:
                                ret = self._url_ws_mappings.get(path)
                                if ret:
                                    return ret, {}
                        
                        
                        Severity: Minor
                        Found in slim/base/route.py - About 35 mins 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

                        Function require_role has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def require_role(role: Union[str, Iterable[str]]):
                            """
                            Current user should have specified role
                            :param role:
                            :return:
                        Severity: Minor
                        Found in slim/ext/decorator.py - About 35 mins 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

                        Function cookie_parser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def cookie_parser(cookie_string: str) -> typing.Dict[str, str]:
                            """
                            This function parses a ``Cookie`` HTTP header into a dict of key/value pairs.
                            It attempts to mimic browser cookie parsing behavior: browsers and web servers
                            frequently disregard the spec (RFC 6265) when setting and reading cookies,
                        Severity: Minor
                        Found in slim/utils/cookies.py - About 35 mins 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 too many return statements within this function.
                        Open

                                return DateType(**kwargs)
                        Severity: Major
                        Found in slim/support/peewee/validate.py - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language