Showing 118 of 118 total issues

Avoid deeply nested control flow statements.
Open

                        if i.builtin_interface == BuiltinInterface.LIST:
                            page_info = deepcopy(paginate_schema)
                            page_info["properties"]["items"] = {
                                "type": "array",
                                "description": "数据项",
Severity: Major
Found in slim/ext/openapi/main.py - About 45 mins to fix

    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 __new__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def __new__(cls, val):
            if isinstance(val, (memoryview, bytes)):
                return val
            # FIX: 其实这可能有点问题,因为None是一个合法的值
            if val is None:
    Severity: Minor
    Found in slim/utils/__init__.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

    Avoid deeply nested control flow statements.
    Open

                            if route_info.names_varkw is not None:
                                for j in route_info.names_exclude:
                                    if j in call_kwargs:
                                        del call_kwargs[j]
    
    
    Severity: Major
    Found in slim/base/web.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if i.builtin_interface == BuiltinInterface.SET:
                                  if view_info['sql_cant_write']:
                                      continue
                                  add_bulk_header()
                                  add_returning_header()
      Severity: Major
      Found in slim/ext/openapi/main.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if isinstance(view, AbstractSQLView):
                                    view.current_interface = route_info.builtin_interface
        
                                # make the method bounded
                                handler = route_info.handler.__get__(view)
        Severity: Major
        Found in slim/base/web.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if sql_query:
                                      parameters.extend(view_info['sql_query_parameters'])
          
          
          Severity: Major
          Found in slim/ext/openapi/main.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if not view.is_finished:
                                        # user's validator check
                                        await view_validate_check(view, route_info.va_query, route_info.va_post, route_info.va_headers)
            
                                        ret_resp = None
            Severity: Major
            Found in slim/base/web.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if isinstance(items, (List, Tuple)):
                                      for i in items:
                                          write_values.append(do_validate(va_write_value, i, InvalidPostData))
                                  else:
                                      raise InvalidPostData("`items` from post data should be list")
              Severity: Major
              Found in slim/base/_view/validate.py - About 45 mins to fix

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

                def append_validate(va_query: Type[Model] = None, va_post: Type[Model] = None, va_write_value: Type[Model] = None,
                                    va_headers: Type[Model] = None):
                    """
                    :param va_query:
                    :param va_post:
                Severity: Minor
                Found in slim/ext/decorator.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

                Avoid deeply nested control flow statements.
                Open

                                        if i.builtin_interface == BuiltinInterface.DELETE:
                                            if view_info['sql_cant_delete']:
                                                continue
                                            add_bulk_header()
                                            request_body_schema = {
                Severity: Major
                Found in slim/ext/openapi/main.py - About 45 mins to fix

                  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 teardown_user_token has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def teardown_user_token(self: Union['BaseUserViewMixin', 'BaseView'], token=sentinel):
                          """ signout, invalidate the token here """
                          u = self.current_user
                          if u:
                              if token is None:
                  Severity: Minor
                  Found in slim_cli/template/api/user.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

                  Avoid deeply nested control flow statements.
                  Open

                                      if not i.startswith('_') and i.endswith('.py'):
                                          modname = os.path.relpath(fn, base_path)[:-3].replace(os.path.sep, '.')
                                          # modpath = os.path.abspath(fn)
                                          # logger.debug('Auto load module: %s from %r' % (modname, modpath))
                  
                  
                  Severity: Major
                  Found in slim/utils/autoload.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if i.builtin_interface == BuiltinInterface.LIST:
                                                parameters.extend([
                                                    {
                                                        "name": "page",
                                                        "in": "path",
                    Severity: Major
                    Found in slim/ext/openapi/main.py - About 45 mins to fix

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

                          def interface(self, method, url=None, *, summary=None, va_query=None, va_post=None, va_headers=None,
                                        va_resp=ResponseDataModel, deprecated=False):
                              """
                              Register interface
                              :param method:
                      Severity: Minor
                      Found in slim/base/route.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 do_request has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def do_request(self, method, rel_path, params=None, post_data=None, role=None, access_token=None):
                      Severity: Minor
                      Found in slim/tools/request.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if i.builtin_interface == BuiltinInterface.NEW:
                                                    if view_info['sql_cant_create']:
                                                        continue
                                                    add_returning_header()
                                                    request_body_schema = {
                        Severity: Major
                        Found in slim/ext/openapi/main.py - About 45 mins to fix

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

                              def __init__(self, *, cookies_secret: bytes = b'secret code', log_level=logging.INFO, session_cls=CookieSession,
                                           mountpoint: str = '/api', doc_enable=True, doc_info=ApplicationDocInfo(),
                                           permission: Optional['Permissions'] = None, client_max_size=100 * 1024 * 1024,
                                           cors_options: Optional[CORSOptions] = None):
                                  """
                          Severity: Minor
                          Found in slim/base/app.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

                          Avoid deeply nested control flow statements.
                          Open

                                                      if f:
                                                          doc = f.__doc__
                                                          if doc: doc = doc.strip()
                                                          if doc: break
                          
                          
                          Severity: Major
                          Found in slim/ext/openapi/main.py - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language