Showing 110 of 118 total issues

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

    Avoid deeply nested control flow statements.
    Open

                            if i.builtin_interface == BuiltinInterface.BULK_INSERT:
                                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

      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

        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 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

          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

          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.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

              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

                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

                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

                  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

                    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
                                Severity
                                Category
                                Status
                                Source
                                Language