jiahaog/nativefier

View on GitHub
app/src/helpers/helpers.test.ts

Summary

Maintainability
C
1 day
Test Coverage

File helpers.test.ts has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { shell } from 'electron';
jest.mock('./windowHelpers');

import {
  cleanupPlainText,
Severity: Minor
Found in app/src/helpers/helpers.test.ts - About 3 hrs to fix

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      test('potentially-malicious urls *should* be blocked', async () => {
        await openExternal('https://hello.com/wor%00ld');
    
        expect(mockShowNavigationBlockedMessage).toHaveBeenCalledTimes(1);
        expect(mockShellOpenExternal).not.toHaveBeenCalled();
    Severity: Major
    Found in app/src/helpers/helpers.test.ts and 2 other locations - About 1 hr to fix
    app/src/helpers/helpers.test.ts on lines 328..333
    app/src/helpers/helpers.test.ts on lines 342..347

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 55.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      test('urls with non-allowlisted scheme *should* be blocked', async () => {
        await openExternal('barf://whatever.foo');
    
        expect(mockShowNavigationBlockedMessage).toHaveBeenCalledTimes(1);
        expect(mockShellOpenExternal).not.toHaveBeenCalled();
    Severity: Major
    Found in app/src/helpers/helpers.test.ts and 2 other locations - About 1 hr to fix
    app/src/helpers/helpers.test.ts on lines 335..340
    app/src/helpers/helpers.test.ts on lines 342..347

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 55.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      test('malformed urls *should* be blocked', async () => {
        await openExternal('zombocom');
    
        expect(mockShowNavigationBlockedMessage).toHaveBeenCalledTimes(1);
        expect(mockShellOpenExternal).not.toHaveBeenCalled();
    Severity: Major
    Found in app/src/helpers/helpers.test.ts and 2 other locations - About 1 hr to fix
    app/src/helpers/helpers.test.ts on lines 328..333
    app/src/helpers/helpers.test.ts on lines 335..340

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 55.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      test('https urls scheme should *not* be blocked', async () => {
        await openExternal('https://whatever.foo');
    
        expect(mockShowNavigationBlockedMessage).not.toHaveBeenCalled();
        expect(mockShellOpenExternal).toHaveBeenCalled();
    Severity: Minor
    Found in app/src/helpers/helpers.test.ts and 1 other location - About 55 mins to fix
    app/src/helpers/helpers.test.ts on lines 321..326

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 54.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      test('urls with whitelisted scheme should *not* be blocked', async () => {
        await openExternal('ircs://irc.libera.chat/whatever');
    
        expect(mockShowNavigationBlockedMessage).not.toHaveBeenCalled();
        expect(mockShellOpenExternal).toHaveBeenCalled();
    Severity: Minor
    Found in app/src/helpers/helpers.test.ts and 1 other location - About 55 mins to fix
    app/src/helpers/helpers.test.ts on lines 314..319

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 54.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    test.each(testNonLoginPages)(
      '%s page should not be internal',
      (url: string) => {
        expect(linkIsInternal(internalUrl, url, undefined, false)).toEqual(false);
      },
    Severity: Minor
    Found in app/src/helpers/helpers.test.ts and 1 other location - About 35 mins to fix
    app/src/helpers/helpers.test.ts on lines 212..219

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    test.each(testLoginPages)(
      '%s login page should be internal',
      (loginUrl: string) => {
        expect(linkIsInternal(internalUrl, loginUrl, undefined, false)).toEqual(
          true,
    Severity: Minor
    Found in app/src/helpers/helpers.test.ts and 1 other location - About 35 mins to fix
    app/src/helpers/helpers.test.ts on lines 234..239

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    There are no issues that match your filters.

    Category
    Status