Showing 110 of 118 total issues

Function interface has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def interface(self, method, url=None, *, summary=None, va_query=None, va_post=None, va_headers=None,
Severity: Major
Found in slim/base/route.py - About 1 hr to fix

    Function do_request has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def do_request(config, method, url, params=None, post_data=None, role=None, access_token=None, *,
    Severity: Major
    Found in slim/tools/request.py - About 1 hr to fix

      Function setup_extra_query_conditions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def setup_extra_query_conditions(self, user, table, query: 'SQLQueryInfo', view: "AbstractSQLView"):
              if table in self.query_condition_params:
                  # TODO: Check once
                  for items in self.query_condition_params[table]:
                      query.add_condition(*items)
      Severity: Minor
      Found in slim/base/permission.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

      Function _polyfill_post has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def _polyfill_post(request: 'web.Request', post):
          if post:
              if isinstance(post, bytes):
                  request._read_bytes = post
              else:
      Severity: Minor
      Found in slim/tools/test.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

      Function check_insert_permission has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_insert_permission(self, user: "BaseUser", table: str, ability: "Ability"):
              from .permission import A
              columns = self.keys()
              logger.debug('request permission as %r: [%s] of table %r, columns: %s' % (ability.role, A.CREATE, table, columns))
              is_empty_input = not columns
      Severity: Minor
      Found in slim/base/sqlquery.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

      Function post has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def post(self, url=None, *, summary=None, va_query=None, va_post=None, va_headers=None,
      Severity: Major
      Found in slim/base/route.py - About 1 hr to fix

        Function get has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get(self, url=None, *, summary=None, va_query=None, va_post=None, va_headers=None,
        Severity: Major
        Found in slim/base/route.py - About 1 hr to fix

          Function can_with_record has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def can_with_record(self, user, action, record: DataRecord, *, available=None) -> set:
                  """
                  进行基于 Record 的权限判定,返回可用列。
                  :param user:
                  :param action:
          Severity: Minor
          Found in slim/base/permission.py - About 55 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_order has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_order(text):
                  """
                  :param text: order=id.desc, xxx.asc
                  :return: [
                      [<column>, asc|desc|default],
          Severity: Minor
          Found in slim/base/sqlquery.py - About 55 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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def do_request(config, method, url, params=None, post_data=None, role=None, access_token=None, *,
                         request_func=requests.request):
              headers = {}
              if params is None:
                  params = {}
          Severity: Minor
          Found in slim/tools/request.py - About 55 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 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def new(cls, username, password, *, email=None, nickname=None, is_for_tests=False) -> Optional['User']:
          Severity: Major
          Found in slim_cli/template/model/user.py - About 50 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 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
                          Severity
                          Category
                          Status
                          Source
                          Language