Showing 110 of 118 total issues

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

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

                                      for j in call_kwargs.keys() - route_info.names_include:
                                          del call_kwargs[j]
              
                                      # build a view instance
                                      view = await route_info.view_cls._build(app, request)
              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

                  Avoid deeply nested control flow statements.
                  Open

                                              if not ignore_exists:
                                                  raise e
                                      return items
                  Severity: Major
                  Found in slim/support/peewee/sqlfuncs.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 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
                          Severity
                          Category
                          Status
                          Source
                          Language