Showing 251 of 251 total issues

Function BaseSettings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const BaseSettings = ({ changeSettings }) => {
  const updateSettings = (key, value, isTheme, isBoolean = false) => {
    changeSettings(key, value, isTheme, isBoolean);
    if (isBoolean) {
      setBooleanSetting(key);
Severity: Minor
Found in src/components/layout/content/settings/Base.js - 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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const { file, username, snippetId, edit, toggleCollapse, theme } = this.props;
    const openOnWebUrl = `${getSnippetUrl('/gist')}/${username}/${snippetId}#file-${file.filename}`;

    return (
Severity: Minor
Found in src/components/layout/content/snippet/SnippetHeader.js - 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 SnippetsSettings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const SnippetsSettings = ({ changeSettings }) => {
  const updateSettings = (key, value, isBoolean = false) => {
    changeSettings(key, value, false, isBoolean);
    if (isBoolean) {
      setBooleanSetting(key);
Severity: Minor
Found in src/components/layout/content/settings/Snippets.js - 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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    if (isElectron) {
      const { ipcRenderer } = require('electron');

      ipcRenderer.on('token', (event, token) => {
Severity: Minor
Found in src/components/LogIn.js - 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

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

    const expected = initialState({
      filter: {
        text: '',
        tags: ['HTML', 'CSS'],
        language: '',
Severity: Minor
Found in __tests__/reduceres/snippets.spec.js and 1 other location - About 35 mins to fix
__tests__/reduceres/snippets.spec.js on lines 105..114

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

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 (isBoolean) {
      setBooleanSetting(key);
    } else {
      setSetting(key, value);
      if (key === 'settings-icons' || key === 'settings-notification-position') {
Severity: Minor
Found in src/components/layout/content/settings/Base.js and 1 other location - About 35 mins to fix
src/components/layout/content/settings/Snippets.js on lines 56..63

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

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 (isBoolean) {
      setBooleanSetting(key);
    } else {
      setSetting(key, value);
      if (key === 'settings-snippet-order-direction' || key === 'settings-snippet-order-field') {
Severity: Minor
Found in src/components/layout/content/settings/Snippets.js and 1 other location - About 35 mins to fix
src/components/layout/content/settings/Base.js on lines 43..50

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

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

    const expected = initialState({
      filter: {
        text: '',
        tags: ['HTML', 'JS'],
        language: '',
Severity: Minor
Found in __tests__/reduceres/snippets.spec.js and 1 other location - About 35 mins to fix
__tests__/reduceres/snippets.spec.js on lines 191..200

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

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

Avoid too many return statements within this function.
Open

      return flow([
        set(['filter', 'text'], ''),
        set(['filter', 'tags'], []),
        set(['filter', 'language'], ''),
        set(['filter', 'status'], ''),
Severity: Major
Found in src/reducers/snippets.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return flow([
            set(['starred'], without([action.meta.id], state.starred)),
            set(['snippets', action.meta.id, 'star'], false)
          ])(state);
    Severity: Major
    Found in src/reducers/snippets.js - About 30 mins to fix

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

      describe('COMPONENTS - <Settings>', () => {
        test('render Settings', () => {
          const component = setup();
      
          expect(component).toMatchSnapshot();
      Severity: Major
      Found in __tests__/components/layout/content/Settings.spec.js and 11 other locations - About 30 mins to fix
      __tests__/components/common/Languagelist.spec.js on lines 15..21
      __tests__/components/layout/App.spec.js on lines 11..17
      __tests__/components/layout/KeyBindings.spec.js on lines 5..11
      __tests__/components/layout/Updater.js on lines 9..15
      __tests__/components/layout/content/About.spec.js on lines 14..20
      __tests__/components/layout/content/NewSnippet.spec.js on lines 19..25
      __tests__/components/layout/content/settings/Editor.spec.js on lines 10..16
      __tests__/components/layout/content/settings/Snippets.spec.js on lines 10..16
      __tests__/components/layout/headers/SubHeader.spec.js on lines 9..15
      __tests__/components/layout/sidebar/Sidebar.spec.js on lines 9..15
      __tests__/components/layout/sidebar/SnippetsList.spec.js on lines 9..15

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

      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

      Avoid too many return statements within this function.
      Open

            return set('snippets.comments', !state.snippets.comments, state);
      Severity: Major
      Found in src/reducers/ui.js - About 30 mins to fix

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

              return API.get(`${getApiUrl('/api/v3')}/gists/${action.payload.id}`)
                .set(_headers())
                .end((error, result) => {
                  errorHandler(error, result);
                  const lastModified = result.headers['last-modified'] || '';
        Severity: Major
        Found in src/middlewares/gitHubAPI.js and 5 other locations - About 30 mins to fix
        src/middlewares/gitHubAPI.js on lines 224..242
        src/middlewares/gitHubAPI.js on lines 267..280
        src/middlewares/gitHubAPI.js on lines 286..288
        src/middlewares/gitHubAPI.js on lines 302..314
        src/middlewares/gitHubAPI.js on lines 319..321

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

        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

        Avoid too many return statements within this function.
        Open

              return flow([
                set('edit', {}),
                set(['snippets', action.payload.id], snippetStructure(action.payload, state.starred))
              ])(state);
        Severity: Major
        Found in src/reducers/snippets.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return set(
                  ['snippets', action.payload.snippetId, 'files', [fileIndex], 'collapsed'],
                  !isCollapsed,
                  state
                );
          Severity: Major
          Found in src/reducers/snippets.js - About 30 mins to fix

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

            describe('COMPONENTS - <KeyBindings>', () => {
              test('render KeyBindings', () => {
                const component = setup();
            
                expect(component).toMatchSnapshot();
            Severity: Major
            Found in __tests__/components/layout/KeyBindings.spec.js and 11 other locations - About 30 mins to fix
            __tests__/components/common/Languagelist.spec.js on lines 15..21
            __tests__/components/layout/App.spec.js on lines 11..17
            __tests__/components/layout/Updater.js on lines 9..15
            __tests__/components/layout/content/About.spec.js on lines 14..20
            __tests__/components/layout/content/NewSnippet.spec.js on lines 19..25
            __tests__/components/layout/content/Settings.spec.js on lines 9..15
            __tests__/components/layout/content/settings/Editor.spec.js on lines 10..16
            __tests__/components/layout/content/settings/Snippets.spec.js on lines 10..16
            __tests__/components/layout/headers/SubHeader.spec.js on lines 9..15
            __tests__/components/layout/sidebar/Sidebar.spec.js on lines 9..15
            __tests__/components/layout/sidebar/SnippetsList.spec.js on lines 9..15

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

            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 6 locations. Consider refactoring.
            Open

                  return API.delete(`${getApiUrl('/api/v3')}/gists/${action.payload.id}/star`)
                    .set(_headers())
                    .end((error, result) => {
                      errorHandler(error, result);
            
            
            Severity: Major
            Found in src/middlewares/gitHubAPI.js and 5 other locations - About 30 mins to fix
            src/middlewares/gitHubAPI.js on lines 182..194
            src/middlewares/gitHubAPI.js on lines 267..280
            src/middlewares/gitHubAPI.js on lines 286..288
            src/middlewares/gitHubAPI.js on lines 302..314
            src/middlewares/gitHubAPI.js on lines 319..321

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

            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

            Avoid too many return statements within this function.
            Open

                  return flow([
                    set(['filter', 'text'], ''),
                    set(['filter', 'tags'], []),
                    set(['filter', 'language'], action.payload.value),
                    set(['filter', 'status'], ''),
            Severity: Major
            Found in src/reducers/snippets.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return flow([
                      set(['filter', 'text'], ''),
                      set(['filter', 'tags'], []),
                      set(['filter', 'language'], ''),
                      set(['filter', 'status'], ''),
              Severity: Major
              Found in src/reducers/snippets.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return flow([
                        set(['starred'], concat([action.meta.id], state.starred)),
                        set(['snippets', action.meta.id, 'star'], true)
                      ])(state);
                Severity: Major
                Found in src/reducers/snippets.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language