cloudfoundry-incubator/stratos

View on GitHub
src/frontend/packages/core/src/features/home/home/home-page-endpoint-card/home-page-endpoint-card.component.ts

Summary

Maintainability
B
6 hrs
Test Coverage

Function ngOnInit has a Cognitive Complexity of 28 (exceeds 8 allowed). Consider refactoring.
Open

  ngOnInit() {
    this.hasFavEntities = this.userFavoriteManager.endpointHasEntitiesThatCanFavorite(this.endpoint.cnsi_type);
    // Favorites for this endpoint
    this.favorites$ = this.userFavoriteManager.getFavoritesForEndpoint(this.endpoint.guid);
    this.entity = entityCatalog.getEndpoint(this.endpoint.cnsi_type, this.endpoint.sub_type);

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 ngOnInit has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  ngOnInit() {
    this.hasFavEntities = this.userFavoriteManager.endpointHasEntitiesThatCanFavorite(this.endpoint.cnsi_type);
    // Favorites for this endpoint
    this.favorites$ = this.userFavoriteManager.getFavoritesForEndpoint(this.endpoint.guid);
    this.entity = entityCatalog.getEndpoint(this.endpoint.cnsi_type, this.endpoint.sub_type);

    Function links$ has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          map(([favs, layout]) => {
            // Get the list of shortcuts for the endpoint for the given endpoint ID
            const shortcutsFn = this.definition?.homeCard?.shortcuts;
            const allShortcuts = shortcutsFn ? shortcutsFn(this.endpoint.guid) || [] : [];
            let shortcuts = allShortcuts;

      There are no issues that match your filters.

      Category
      Status