locomotivecms/engine

View on GitHub

Showing 169 of 169 total issues

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

  const pickAssetPath = (section, blockType, blockId, settingType, settingId) => {
    const postfix = `setting/${settingType}/${settingId}/assets`;

    if (blockType && blockId)
      return `${blockPath(section, blockType, blockId)}/${postfix}`;
app/javascript/src/locomotive/editor/services/routes_service.js on lines 34..41
app/javascript/src/locomotive/editor/services/routes_service.js on lines 52..59
app/javascript/src/locomotive/editor/services/routes_service.js on lines 61..68

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

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 build has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const build = (pageId, contentEntryId, baseUrl) => {
  const _pageId       = compact([pageId, contentEntryId]).join('-');
  const basePath      = `/${_pageId}/content/edit`;
  const sectionsPath  = `${basePath}/sections`;

Severity: Major
Found in app/javascript/src/locomotive/editor/services/routes_service.js - About 2 hrs to fix

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

          <li className={menuItemClassname('seo', selectedTab)}>
            <a onClick={() => onSelectTab('seo')}>
              <BarChartIcon color={Style.navTabColor} />
              {i18n.t('views.action_bar.menu.seo')}
            </a>
    app/javascript/src/locomotive/editor/views/action_bar/menu.js on lines 23..28
    app/javascript/src/locomotive/editor/views/action_bar/menu.js on lines 29..34

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

    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

          <li className={menuItemClassname('sections', selectedTab)}>
            <a onClick={() => onSelectTab('sections')}>
              <SectionIcon color={Style.navTabActiveColor} />
              {i18n.t('views.action_bar.menu.content')}
            </a>
    app/javascript/src/locomotive/editor/views/action_bar/menu.js on lines 29..34
    app/javascript/src/locomotive/editor/views/action_bar/menu.js on lines 35..40

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

    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

          <li className={menuItemClassname('settings', selectedTab)}>
            <a onClick={() => onSelectTab('settings')}>
              <SettingsIcon color={Style.navTabColor} />
              {i18n.t('views.action_bar.menu.settings')}
            </a>
    app/javascript/src/locomotive/editor/views/action_bar/menu.js on lines 23..28
    app/javascript/src/locomotive/editor/views/action_bar/menu.js on lines 35..40

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

    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

              compress.compress(files)
              .then(conversions => map(conversions, conversion => ({ blob: conversion.photo.data, filename: conversion.photo.name })))
              .then(_files => this._handleUpload(_files))
    app/javascript/src/locomotive/editor/views/pickers/images/uploader.js on lines 41..43

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

    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

              compress.compress(files)
              .then(conversions => map(conversions, conversion => ({ blob: conversion.photo.data, filename: conversion.photo.name })))
              .then(_files => this._handleUpload(_files))
    app/javascript/src/locomotive/editor/views/pickers/assets/uploader.js on lines 40..42

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

    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

    Method call has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def call(env)
              disable_live_editing_if_not_html(env)
    
              status, headers, response = @app.call(env)
    
    
    Severity: Major
    Found in lib/locomotive/steam/middlewares/page_editing.rb - About 2 hrs to fix

      Function render has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render() {
          const { setting, getValue, label, handleChange } = this.props;
          const value = getValue(null);
          const image = value && typeof(value) === 'object' ? value : { source: value };
      
      
      Severity: Major
      Found in app/javascript/src/locomotive/editor/inputs/image_picker.js - About 2 hrs to fix

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

                {page.slug !== undefined && (
                  <CheckboxInput
                    label={i18n.t('views.settings.listed')}
                    getValue={() => page.listed}
                    handleChange={value => updatePageSetting('listed', value)}
        app/javascript/src/locomotive/editor/views/settings/index.js on lines 22..29
        app/javascript/src/locomotive/editor/views/settings/index.js on lines 31..38

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

        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

                {page.slug !== undefined && (
                  <TextInput
                    label={i18n.t('views.settings.slug_label')}
                    getValue={() => page.slug}
                    handleChange={value => updatePageSetting('slug', value)}
        app/javascript/src/locomotive/editor/views/settings/index.js on lines 31..38
        app/javascript/src/locomotive/editor/views/settings/index.js on lines 40..47

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

        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

                {page.slug !== undefined && (
                  <CheckboxInput
                    label={i18n.t('views.settings.published')}
                    getValue={() => page.published}
                    handleChange={value => updatePageSetting('published', value)}
        app/javascript/src/locomotive/editor/views/settings/index.js on lines 22..29
        app/javascript/src/locomotive/editor/views/settings/index.js on lines 40..47

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

        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

        Method update_all has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_all(list_of_attributes)
              [].tap do |elements|
                pages, modified_pages = {}, {}
        
                list_of_attributes.each do |attributes|
        Severity: Minor
        Found in app/services/locomotive/editable_element_service.rb - About 2 hrs 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

            return (
              <Select
                label={i18n.t('views.pickers.url.page.section_label')}
                value={this.state.settings.anchor}
                list={options}
        app/javascript/src/locomotive/editor/views/pickers/urls/types/content_entry.js on lines 112..120

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

        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

            return (
              <Select
                label={i18n.t('views.pickers.url.page.section_label')}
                value={this.state.settings.anchor}
                list={list}
        app/javascript/src/locomotive/editor/views/pickers/urls/types/page.js on lines 67..75

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

        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 withApiFetching has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const withApiFetching = (source, options) => (Component) => {
        
          const _options = Object.assign({ pagination: false }, options);
        
          return class WithFetching extends React.Component {
        Severity: Major
        Found in app/javascript/src/locomotive/editor/hoc/with_api_fetching.js - About 2 hrs to fix

          Function render has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            render() {
              return (
                <View
                  title={i18n.t('views.pickers.assets.title')}
                  subTitle={this.props.blockLabel || this.props.sectionLabel}
          Severity: Minor
          Found in app/javascript/src/locomotive/editor/views/pickers/assets/index.js - About 2 hrs to fix

            Function editor has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function editor(state = {}, action) {
              switch(action.type) {
            
                case 'EDITOR::LOAD':
                  return action.editor;
            Severity: Minor
            Found in app/javascript/src/locomotive/editor/reducers/editor.js - About 1 hr to fix

              Method with_flash_message has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                    def with_flash_message(type = :notice, in_header = true)
                      unless set_flash_message?
                        yield if block_given?
                        return
                      end
              Severity: Minor
              Found in lib/locomotive/action_controller/responder.rb - 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

                  <g fill="none" fillRule="evenodd" transform="translate(0 -1)">
                    <path
                      stroke="#1C77C3"
                      strokeLinecap="round"
                      d="M11.25 2.357h9m-9 3.143h9m-9 3.143h6"
              app/javascript/src/locomotive/editor/components/icons/slide.js on lines 5..12

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

              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