os-js/osjs-client

View on GitHub

Showing 77 of 77 total issues

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

  _maximize(toggle) {
    if (this._toggleState('maximized', toggle, toggle ? 'maximize' : 'restore')) {
      const emit = () => this.emit('resized', {
        width: this.$element ? this.$element.offsetWidth : -1,
        height: this.$element ? this.$element.offsetHeight : -1
Severity: Minor
Found in src/window.js - 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 _launch has 59 lines of code (exceeds 50 allowed). Consider refactoring.
Open

  _launch(name, metadata, args, options) {
    const _ = this.core.make('osjs/locale').translate;
    const canLaunch = createPackageAvailabilityCheck(this.core);

    const dialog = e => {
Severity: Major
Found in src/packages.js - About 1 hr to fix

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

          if (touch) {
            document.removeEventListener('touchmove', mousemove, touchArg);
            document.removeEventListener('touchend', mouseup, touchArg);
          } else {
            document.removeEventListener('mousemove', mousemove);
    Severity: Major
    Found in src/window-behavior.js and 1 other location - About 1 hr to fix
    src/window-behavior.js on lines 319..325

    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 61.

    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

          if (touch) {
            document.addEventListener('touchmove', mousemove, touchArg);
            document.addEventListener('touchend', mouseup, touchArg);
          } else {
            document.addEventListener('mousemove', mousemove);
    Severity: Major
    Found in src/window-behavior.js and 1 other location - About 1 hr to fix
    src/window-behavior.js on lines 284..290

    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 61.

    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

    export type CoreProviderLocaleContract = {
      format: Function;
      translate: Function;
      translatable: Function;
      translatableFlat: Function;
    Severity: Major
    Found in index.d.ts and 1 other location - About 1 hr to fix
    index.d.ts on lines 2051..2058

    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 61.

    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

    export type DeskopProviderContract = {
      setKeyboardContext: Function;
      openContextMenu: Function;
      addContextMenuEntries: Function;
      applySettings: Function;
    Severity: Major
    Found in index.d.ts and 1 other location - About 1 hr to fix
    index.d.ts on lines 1935..1942

    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 61.

    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

    Function createFetchOptions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    const createFetchOptions = (url, options, type) => {
      const fetchOptions = {
        credentials: 'same-origin',
        method: 'get',
        headers: {},
    Severity: Minor
    Found in src/utils/fetch.js - 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 onContextMenu has 55 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

      onContextMenu(ev) {
        const lockSettings = this.core.config('desktop.lock');
        const extras = [].concat(...this.contextmenuEntries.map(e => typeof e === 'function' ? e() : e));
        const config = this.core.config('desktop.contextmenu');
        const hasIconview = this.core.make('osjs/settings').get('osjs/desktop', 'iconview.enabled');
    Severity: Major
    Found in src/desktop.js - About 1 hr to fix

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

          rename: (from, to, options) =>
            request('rename', {from: from.path, to: to.path, options}, 'json').then(({body}) => body),
      Severity: Major
      Found in src/adapters/vfs/system.js and 1 other location - About 1 hr to fix
      src/adapters/vfs/system.js on lines 82..83

      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 59.

      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

          copy: (from, to, options) =>
            request('copy', {from: from.path, to: to.path, options}, 'json').then(({body}) => body),
      Severity: Major
      Found in src/adapters/vfs/system.js and 1 other location - About 1 hr to fix
      src/adapters/vfs/system.js on lines 85..86

      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 59.

      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

            if (!this.destroyed) {
              const foundIndex = this.windows.findIndex(w => w === instance);
              if (foundIndex !== -1) {
                this.windows.splice(foundIndex, 1);
              }
      Severity: Major
      Found in src/application.js and 1 other location - About 1 hr to fix
      src/packages.js 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 59.

      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

                app.on('destroy', () => {
                  const foundIndex = this._running.findIndex(n => n === name);
                  if (foundIndex !== -1) {
                    this._running.splice(foundIndex, 1);
                  }
      Severity: Major
      Found in src/packages.js and 1 other location - About 1 hr to fix
      src/application.js on lines 366..371

      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 59.

      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

      Function droppable has 53 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      export const droppable = (el, options = {}) => {
        const {strict, type, effect, dataTransferProperty, ondragenter, ondragover, ondragleave, ondrop} = {
          type: 'application/json',
          effect: 'move',
          dataTransferProperty: 'files',
      Severity: Major
      Found in src/utils/dnd.js - About 1 hr to fix

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

        declare class SettingsServiceProvider extends ServiceProvider {
          /**
           */
          constructor(core: Core, options?: SettingsServiceOptions);
          /**
        Severity: Major
        Found in index.d.ts and 1 other location - About 1 hr to fix
        index.d.ts on lines 2288..2298

        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 57.

        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

        declare class AuthServiceProvider extends ServiceProvider {
          /**
           */
          constructor(core: Core, options?: AuthServiceOptions);
          /**
        Severity: Major
        Found in index.d.ts and 1 other location - About 1 hr to fix
        index.d.ts on lines 2380..2390

        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 57.

        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

        Function createWindow has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          createWindow(options = {}) {
            const found = this.windows.find(w => w.id === options.id);
            if (found) {
              const msg = this.core.make('osjs/locale')
                .translate('ERR_WINDOW_ID_EXISTS', options.id);
        Severity: Minor
        Found in src/application.js - 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 _launch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          _launch(name, metadata, args, options) {
            const _ = this.core.make('osjs/locale').translate;
            const canLaunch = createPackageAvailabilityCheck(this.core);
        
            const dialog = e => {
        Severity: Minor
        Found in src/packages.js - 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 loadOptionsFromConfig has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        export const loadOptionsFromConfig = (config, appName, windowId) => {
          const matchStringOrRegex = (str, matcher) => matcher instanceof RegExp
            ? !!str.match(matcher)
            : str === matcher;
        
        
        Severity: Minor
        Found in src/utils/windows.js - 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

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

              }, {
                label: maximized ? _('LBL_RESTORE') : _('LBL_MAXIMIZE'),
                disabled: !maximizable,
                onclick: () => maximized ? win.restore() : win.maximize()
              }, {
        Severity: Major
        Found in src/window-behavior.js and 1 other location - About 1 hr to fix
        src/window-behavior.js on lines 368..372

        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 56.

        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

              menu: [{
                label: minimized ? _('LBL_RAISE') : _('LBL_MINIMIZE'),
                disabled: !minimizable,
                onclick: () => minimized ? win.raise() : win.minimize()
              }, {
        Severity: Major
        Found in src/window-behavior.js and 1 other location - About 1 hr to fix
        src/window-behavior.js on lines 372..376

        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 56.

        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

        Severity
        Category
        Status
        Source
        Language