Showing 119 of 121 total issues
File order.ts
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import {
daffAdd,
daffSubtract,
} from '@daffodil/core';
import { MagentoDiscount } from '@daffodil/driver/magento';
Function daffCustomerAddressEntitiesReducer
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function daffCustomerAddressEntitiesReducer<
T extends DaffCustomerAddress = DaffCustomerAddress,
>(
state = daffCustomerAddressEntitiesAdapter<T>().getInitialState(),
action: DaffCustomerAddressActions<T> | DaffCustomerActions): DaffOperationEntityState<T> {
Function constructor
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(private store: Store<DaffOrderStateRootSlice<T>>) {
const {
selectOrderIds,
selectOrderEntities,
selectOrders,
Function createCompositeProductAppliedOptionsEntitiesSelectors
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const createCompositeProductAppliedOptionsEntitiesSelectors = <T extends DaffProduct>(): DaffCompositeProductEntitiesMemoizedSelectors<T> => {
const {
selectCompositeProductState,
} = getDaffCompositeProductFeatureSelector();
const {
Function daffCustomerPaymentEntitiesReducer
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function daffCustomerPaymentEntitiesReducer<
TPayment extends DaffCustomerPayment = DaffCustomerPayment,
TRequest extends DaffCustomerPaymentRequest = DaffCustomerPaymentRequest,
>(
state = daffCustomerPaymentEntitiesAdapter<TPayment>().getInitialState(),
Function getBreadcrumbs
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private getBreadcrumbs(doc: ParentedDocument & KindedDocument): Array<DaffBreadcrumb> {
const segments = (<string>doc.path).split('/');
const breadcrumbs = segments
.map((segment, i) => getStaticBreadcrumb(segment, segments.slice(0, i).join('/')))
.filter((b, i, ary) => !!b && ary.findIndex((e) => e?.label === b.label) === i);
Function transformCartTotals
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function transformCartTotals(cart: Partial<MagentoCart>): {totals: DaffCart['totals']} {
const totalTax = cart.prices.applied_taxes ? cart.prices.applied_taxes.reduce((acc, tax) => (daffAdd(acc, tax.amount.value)), 0) : 0;
return {
totals: {
[DaffCartTotalTypeEnum.grandTotal]: {
Function cartReducer
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function cartReducer<T extends DaffCart = DaffCart>(
state = daffCartReducerInitialState,
action: ActionTypes<T>,
): DaffCartReducerState<T> {
switch (action.type) {
Function search
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
search(query: string, options: DaffSearchProductDriverOptions = {}): Observable<DaffSearchProductDriverResponse> {
const queryVariables = this.getVariables(options);
return combineLatest([
this.apollo.query<MagentoSearchForProductsResponse>({
Function cartCouponReducer
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function cartCouponReducer<T extends DaffCart = DaffCart>(
state = daffCartReducerInitialState,
action: ActionTypes<T>,
): DaffCartReducerState<T> {
switch (action.type) {
Function ngAfterContentChecked
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
ngAfterContentChecked() {
const nextShift = sidebarViewportContentShift(this.sidebars) + 'px';
if (this._shift !== nextShift) {
this._shift = nextShift;
- Read upRead up
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 createCategorySelectors
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const createCategorySelectors = <V extends DaffGenericCategory<V>, W extends DaffProduct>(): DaffCategoryMemoizedSelectors<V, W> => {
const { selectAllProducts,selectProductEntities } = getDaffProductSelectors<W>();
const {
selectCategoryEntities,
Function createCartOrderSelectors
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const createCartOrderSelectors = <
T extends DaffCart = DaffCart,
V extends DaffCartOrderResult = DaffCartOrderResult,
>(): DaffCartOrderMemoizedSelectors<T, V> => {
const selectCartFeatureState = getDaffCartFeatureSelector<T, V>().selectCartFeatureState;
Function getStaticBreadcrumb
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const getStaticBreadcrumb = (segment: string, parent: string): DaffBreadcrumb => {
switch (segment) {
case DAFF_DOCS_PATH:
return {
label: 'Docs',
Function daffCartInMemoryComputeCartTotals
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function daffCartInMemoryComputeCartTotals(cart: DaffCart, products: DaffProduct[]): DaffCart {
const shipping = cart.shipping_information ? faker.datatype.number({ min: 0, max: 99 }) : 0;
const subtotalExcludingTax = cart.items?.reduce((acc, { product_id }) =>
acc + (products.find(({ id }) => id === product_id)?.price || 0),
0,
Function daffCartOrderReducer
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function daffCartOrderReducer<T extends DaffCartOrderResult = DaffCartOrderResult>(
state = daffCartOrderInitialState,
action: ActionTypes<
DaffCart,
DaffCartItemInput,
Function slideAnimation
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
get slideAnimation(): any {
switch (this.toastPosition.config.horizontal + '-' + this.toastPosition.config.vertical) {
case 'left-top':
case 'left-bottom':
return {
Function daffCategoryPageMetadataReducer
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function daffCategoryPageMetadataReducer<U extends DaffGenericCategory<U>, W extends DaffProduct>(
state = daffCategoryPageMetadataInitialState,
action: DaffCategoryActions<U, W> | DaffCategoryPageActions<U, W> | DaffCategoryPageProductCollectionActions,
): DaffCategoryPageMetadataReducerState {
const adapter = getCollectionStateAdapter<DaffCategoryPageMetadataReducerState>();
Function daffCartStoreCreditCartReducer
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function daffCartStoreCreditCartReducer<T extends DaffCartWithStoreCredit = DaffCartWithStoreCredit>(
state = daffCartReducerInitialState,
action: DaffCartStoreCreditActions,
): DaffCartReducerState<T> {
switch (action.type) {
Function daffAuthReducer
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function daffAuthReducer(
state = daffAuthInitialState,
action: DaffAuthActions | DaffAuthLoginActions | DaffAuthRegisterSuccess | DaffAuthResetPasswordActions,
): DaffAuthReducerState {
switch (action.type) {