Zizzamia/perfume.js

View on GitHub

Showing 9 of 40 total issues

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

export function analyticsTracker(options) {
  const { metricName, data, navigatorInformation, vitalsScore, eventProperties } = 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 77 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 3 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 analyticsTracker has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          export function analyticsTracker(options) {
            const { metricName, data, navigatorInformation, vitalsScore, eventProperties } = 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 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 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 getNavigatorInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              export const getNavigatorInfo = function(): 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 constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                constructor(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/perfume.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

              Severity
              Category
              Status
              Source
              Language