airbnb/caravel

View on GitHub

Showing 2,441 of 6,157 total issues

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

    def build_sqlalchemy_uri(
        self, data: dict[str, Any], **kwargs: Any
    ) -> dict[str, Any]:
        """
        Build SQLAlchemy URI from separate parameters.
Severity: Minor
Found in superset/databases/schemas.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 _get_content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_content(self) -> EmailContent:
        if self._content.text:
            return EmailContent(body=self._error_template(self._content.text))
        # Get the domain from the 'From' address ..
        # and make a message id without the < > in the end
Severity: Minor
Found in superset/reports/notifications/email.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 idx, key in enumerate(value[relation]):
                            if key in mapping:
                                value[relation][idx] = mapping[key]

        # Remove the filter-box charts from the dashboard/slice mapping.
Severity: Major
Found in superset/migrations/shared/native_filters.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if col + size_x <= current_col:
                            lower.append(position)
                            continue
                        elif col >= current_col:
                            upper.append(position)

      Avoid deeply nested control flow statements.
      Open

                              for parent_id in fltr.get("cascadeParentIds", [])[:]:
                                  if parent_id not in filter_ids:
                                      fltr["cascadeParentIds"].remove(parent_id)
                                      updated = True
      
      

        Avoid deeply nested control flow statements.
        Open

                            if new_pvm not in role.permissions:
                                logger.info(f"Add {new_pvm} to {role}")
                                role.permissions.append(new_pvm)
        
            # Delete old permissions
        Severity: Major
        Found in superset/migrations/shared/security_converge.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if len(lower) == 1:
                                  chart_holder = get_chart_holder(lower[0])
                                  root[chart_holder["id"]] = chart_holder
                                  row_container["children"].append(chart_holder["id"])
                              else:

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

            def upgrade():
                bind = op.get_bind()
                session = db.Session(bind=bind)
            
                for slc in paginated_update(

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

            def upgrade_comparison_params(slice_params: dict[str, Any]) -> dict[str, Any]:
                params = deepcopy(slice_params)
            
                # Update time_comparison to time_compare
                if "time_comparison" in params:

            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 import_from_dict has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def import_from_dict(
            Severity: Minor
            Found in superset/models/helpers.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if key in query:
                                          del query[key]
                                          updated = True
              
              

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

                def validate_adhoc_subquery(
                    sql: str,
                    database_id: int,
                    engine: str,
                    default_schema: str,
                Severity: Minor
                Found in superset/models/helpers.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 eq:
                                            cond = or_(is_null_cond, sqla_col.in_(eq_without_none))
                                        else:
                                            cond = is_null_cond
                                    else:
                Severity: Major
                Found in superset/models/helpers.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if column_name := column_.get("column_name"):
                                              column_names.add(column_name)
                  
                              # Columns used in query filters
                              column_names.update(
                  Severity: Major
                  Found in superset/connectors/sqla/models.py - About 45 mins to fix

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

                    def get_permissions(
                        user: User,
                    ) -> tuple[dict[str, list[tuple[str]]], DefaultDict[str, list[str]]]:
                        if not user.roles:
                            raise AttributeError("User object does not have roles")
                    Severity: Minor
                    Found in superset/views/utils.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 downgrade has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def downgrade():
                        bind = op.get_bind()
                        session = db.Session(bind=bind)
                    
                        for slc in session.query(Slice).filter(Slice.viz_type == "pie").all():

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

                        def _delete(self: BaseView, primary_key: int) -> None:
                            """
                            Delete function logic, override to implement different logic
                            deletes the record with primary_key = primary_key
                    
                    
                    Severity: Minor
                    Found in superset/views/base.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 target_generic_type != GenericDataType.STRING:
                                                sqla_col = sa.cast(sqla_col, sa.String)
                    
                    
                    Severity: Major
                    Found in superset/models/helpers.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          for key in keys:
                                              val = filter_immune_slice_fields[key]
                                              if "__from" in val:
                                                  val.remove("__from")
                                              if "__to" in val:

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

                        def downgrade():
                            bind = op.get_bind()
                            metadata = sa.MetaData(bind=bind)
                        
                            op.add_column(

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language