graycoreio/daffodil

View on GitHub

Showing 119 of 121 total issues

Function getRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  getRequest(queryParamMap: ParamMap): DaffCollectionRequest {
    const request = DAFF_PRODUCT_COLLECTION_REQUEST_FIELDS.reduce<DaffCollectionRequest>((acc, field) => {
      const qp = this.config.params[field] || field;
      if (queryParamMap.has(qp)) {
        const qpVal = queryParamMap.get(qp);
Severity: Minor
Found in libs/product/routing/src/services/get-request-from-route.service.ts - About 35 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 locationOf has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const locationOf = <T>(element: T, array: T[], comparer, start = 0, end = array.length) => {

  if (array.length === 0) {
    return -1;
  }
Severity: Minor
Found in tools/dgeni/src/utils/sorted-array-insert.ts - About 35 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 transformMagentoCartGraphQlError has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function transformMagentoCartGraphQlError(error: GraphQLError, requestPayload?: unknown): DaffError {
  // TODO: readdress this when we move to eslint
  // eslint-disable-next-line
  for (const code in DaffCartMagentoErrorMessageRegexMap) {
    const matchIndex = error.message.search(DaffCartMagentoErrorMessageRegexMap[code]);
Severity: Minor
Found in libs/cart/driver/magento/src/errors/transform.ts - About 35 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 constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  constructor(
    private cartFacade: DaffCartFacade,
  ) {
    this.currentStep$ = combineLatest([
      this._currentStep$,
Severity: Minor
Found in apps/demo/src/app/checkout/step/step.service.ts - About 35 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 too many return statements within this function.
Open

    return 'open';
Severity: Major
Found in libs/design/sidebar/src/animation/sidebar-animation-state.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return 'closed';
    Severity: Major
    Found in libs/design/sidebar/src/animation/sidebar-animation-state.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return this.resetPassword(reqInfo);
      Severity: Major
      Found in libs/auth/driver/in-memory/src/backend/auth.service.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return 'under-closed';
        Severity: Major
        Found in libs/design/sidebar/src/animation/sidebar-animation-state.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return this.sendResetEmail(reqInfo);
          Severity: Major
          Found in libs/auth/driver/in-memory/src/backend/auth.service.ts - About 30 mins to fix

            Function validateGetBlocksResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export const validateGetBlocksResponse = (response: ApolloQueryResult<MagentoGetBlocksResponse>) => {
              if (response.data?.cmsBlocks?.items) {
                if (response.data.cmsBlocks.items.reduce((acc, block) => acc && !!(
                  block.identifier
                    && block.content
            Severity: Minor
            Found in libs/content/driver/magento/src/validators/get-blocks.ts - About 25 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 isOpening has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export const isOpening = (fromState: DaffSidebarAnimationState, toState: DaffSidebarAnimationState): boolean => {
              if(fromState === 'under-open' && toState === 'open' || fromState === 'open' && toState === 'under-open') {
                return false;
              }
            
            
            Severity: Minor
            Found in libs/design/sidebar/src/sidebar/is-opening.ts - About 25 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 validateGetOrdersResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export const validateGetOrdersResponse = (response: ApolloQueryResult<MagentoGetGuestOrdersResponse>) => {
              if (response.data?.graycoreGuestOrders?.items) {
                if (response.data.graycoreGuestOrders.items.reduce((acc, order) => acc && !!(
                  order.billing_address
                    && order.shipping_address
            Severity: Minor
            Found in libs/order/driver/magento/2-4-1/src/validators/get-orders.ts - About 25 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 list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              list(cartId?: string, request: DaffCollectionRequest = {}): Observable<DaffOrderCollection> {
                const variables: MagentoCustomerOrderListQueryVariables = {
                  currentPage: request.currentPage,
                  pageSize: request.pageSize,
                };
            Severity: Minor
            Found in libs/customer-order/driver/magento/2-4-6/src/order.service.ts - About 25 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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              post(reqInfo) {
                if (reqInfo.id === 'login') {
                  return this.login(reqInfo);
                } else if (reqInfo.id === 'register') {
                  return this.register(reqInfo);
            Severity: Minor
            Found in libs/auth/driver/in-memory/src/backend/auth.service.ts - About 25 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 getVariables has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              private getVariables(options: DaffSearchProductDriverOptions = {}) {
                const queryVariables = {
                  filter: this.productFilterRequestsTransformer.transform(options.filterRequests),
                };
                if (options.pageSize || options.limit) {
            Severity: Minor
            Found in libs/search-product/driver/magento/src/product-search.service.ts - About 25 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 validateGetOrdersResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export const validateGetOrdersResponse = (response: ApolloQueryResult<MagentoGetGuestOrdersResponse>) => {
              if (response.data?.graycoreGuestOrders?.orders) {
                if (response.data.graycoreGuestOrders.orders.reduce((acc, order) => acc && !!(
                  order.billing_address
                    && order.shipping_address
            Severity: Minor
            Found in libs/order/driver/magento/2-4-0/src/validators/get-orders.ts - About 25 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 traverseRouteTree has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            const traverseRouteTree = (routes: Routes = [], matcher: (route: Route) => boolean, operate: RouteOperator): Routes => {
              if(routes.length === 0) {
                return routes;
              }
            
            
            Severity: Minor
            Found in libs/external-router/src/router/strategies/insert-data-path.ts - About 25 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 ngOnChanges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              ngOnChanges(changes: SimpleChanges): void {
                if(!changes.tree.currentValue) {
                  this._tree = undefined;
                  this.flatTree = [];
                  return;
            Severity: Minor
            Found in libs/design/tree/src/tree/tree.component.ts - About 25 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 $process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              $process(docs: Document[]) {
                const ret = docs.map((doc) => {
                  if (this.docTypes.includes(doc.docType)) {
                    doc[this.contentKey] = this.marked.parse(doc.content);
                    if (doc.kind === DaffDocKind.PACKAGE || doc.kind === DaffDocKind.COMPONENT) {
            Severity: Minor
            Found in tools/dgeni/src/processors/markdown.ts - About 25 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

            Severity
            Category
            Status
            Source
            Language