Zizzamia/perfume.js

View on GitHub

Showing 15 of 54 total issues

Function analyticsTracker has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function analyticsTracker(options) {
  const { metricName, data, navigatorInformation, rating, attribution } = options;
  if (navigatorInformation && navigatorInformation.deviceMemory) {
    navigatorInformation$.next(navigatorInformation);
    isLowEndDevice$.next(navigatorInformation.isLowEndDevice);
Severity: Major
Found in docs/src/app/perfume.ts - About 3 hrs to fix

    Function ngAfterViewInit has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      ngAfterViewInit() {
        navigationTiming.subscribe(result => {
          this.navigationTiming = JSON.stringify(result, undefined, 2);
          this.ref.detectChanges();
        });
    Severity: Major
    Found in docs/src/app/app.component.ts - About 2 hrs to fix

      Function performance has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        performance: () => {
          delete (window as any).performance;
          const performance = {
            clearMarks: jest.fn(),
            // https://developer.mozilla.org/en-US/docs/Web/API/Performance/getEntriesByName
      Severity: Major
      Found in __tests__/_mock.ts - About 2 hrs to fix

        Function getEntriesByType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              getEntriesByType: (entryType: string) => {
                if (entryType === 'navigation') {
                  return [
                    {
                      connectEnd: 1.7850000876933336,
        Severity: Minor
        Found in __tests__/_mock.ts - About 1 hr to fix

          Function measureStep has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const measureStep = (
            step: string,
            startMark: string,
            endMark: string,
          ) => {
          Severity: Minor
          Found in src/steps/measureStep.ts - About 1 hr to fix

            Function analyticsTracker has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            export function analyticsTracker(options) {
              const { metricName, data, navigatorInformation, rating, attribution } = options;
              if (navigatorInformation && navigatorInformation.deviceMemory) {
                navigatorInformation$.next(navigatorInformation);
                isLowEndDevice$.next(navigatorInformation.isLowEndDevice);
            Severity: Minor
            Found in docs/src/app/perfume.ts - 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 initPerfume has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const initPerfume = (options: IPerfumeOptions = {}) => {
              // Extend default config with external options
              config.analyticsTracker = options.analyticsTracker;
              config.isResourceTiming = !!options.resourceTiming;
              config.isElementTiming = !!options.elementTiming;
            Severity: Minor
            Found in src/initPerfume.ts - About 1 hr to fix

              Function navigator has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                navigator: () => {
                  delete (window as any).navigator;
                  const navigator = {
                    connection: {
                      effectiveType: '4g',
              Severity: Minor
              Found in __tests__/_mock.ts - About 1 hr to fix

                Function recordEndMark has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const recordEndMark = (endMark: string) => {
                  const { navigationSteps, finalMarkToStepsMap } = steps;
                
                  const navigationLength = Object.keys(navigationSteps).length;
                  if (navigationLength === 0) {
                Severity: Minor
                Found in src/steps/navigationSteps.ts - About 1 hr to fix

                  Function exports has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function (config) {
                    config.set({
                      basePath: '',
                      frameworks: ['jasmine', '@angular-devkit/build-angular'],
                      plugins: [
                  Severity: Minor
                  Found in docs/src/karma.conf.js - About 1 hr to fix

                    Function initPerfume has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const initPerfume = (options: IPerfumeOptions = {}) => {
                      // Extend default config with external options
                      config.analyticsTracker = options.analyticsTracker;
                      config.isResourceTiming = !!options.resourceTiming;
                      config.isElementTiming = !!options.elementTiming;
                    Severity: Minor
                    Found in src/initPerfume.ts - 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 getNavigatorInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const getNavigatorInfo = (): INavigatorInfo => {
                      if (WN) {
                        return {
                          deviceMemory: getDM() || 0,
                          hardwareConcurrency: getHC() || 0,
                    Severity: Minor
                    Found in src/getNavigatorInfo.ts - 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 reportPerf has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const reportPerf = (
                      measureName: string,
                      data: any,
                      rating: IVitalsScore,
                      attribution: object,
                    Severity: Minor
                    Found in src/reportPerf.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 measureStep has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const measureStep = (
                      step: string,
                      startMark: string,
                      endMark: string,
                    ) => {
                    Severity: Minor
                    Found in src/steps/measureStep.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 setStepsMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const setStepsMap = () => {
                      if (!config.steps) {
                        return;
                      }
                      resetSteps();
                    Severity: Minor
                    Found in src/steps/setStepsMap.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