locomotivecms/engine

View on GitHub

Showing 91 of 169 total issues

Function content has 172 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function content(state = {}, action) {
  switch (action.type) {

    // EDITOR
    case 'EDITOR::LOAD':
Severity: Major
Found in app/javascript/src/locomotive/editor/reducers/content.js - About 6 hrs to fix

    Function withEditingSection has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const withEditingSection = Component => {
    
      const findSetting = (sectionDefinition, blockDefinition, settingId) => {
        if (settingId === null || settingId === undefined) return null;
    
    
    Severity: Major
    Found in app/javascript/src/locomotive/editor/hoc/with_editing_section.js - About 4 hrs to fix

      Function withEditingSection has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      const withEditingSection = Component => {
      
        const findSetting = (sectionDefinition, blockDefinition, settingId) => {
          if (settingId === null || settingId === undefined) return null;
      
      
      Severity: Minor
      Found in app/javascript/src/locomotive/editor/hoc/with_editing_section.js - About 4 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

      Method _localize has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def _localize(page, locales, default_locale, parent_fullpaths)
            slug = page.slug_translations[default_locale]
      
            locales.each do |locale|
              next if locale == default_locale
      Severity: Minor
      Found in app/services/locomotive/page_service.rb - About 3 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

      Method _definition_schema has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def _definition_schema
            {
              id: 'http://www.locomotive.cms/schemas/sections/definition2.json',
              definitions: {
                settings: {
      Severity: Major
      Found in app/models/locomotive/section.rb - About 2 hrs to fix

        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

          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

              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

              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

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

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

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

                        render() {
                          const { sectionDefinition, sectionContent, translate } = this.props;
                      
                          // DEBUG
                          // console.log('BlockList', sectionDefinition.blocks_display, sectionDefinition.block_max_depth, sectionDefinition.blocks_display === 'tree' ? sectionDefinition.block_max_depth || 1 : 0)
                      Severity: Minor
                      Found in app/javascript/src/locomotive/editor/views/sections/edit/index.js - About 1 hr to fix

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

                          render() {
                            const {
                              config: { options, link, unlink, className },
                              currentState,
                              expanded,
                        Severity: Minor
                        Found in app/javascript/src/locomotive/editor/components/draft/link.jsx - About 1 hr to fix

                          Method authenticate! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def authenticate!
                              resource  = valid_password? && mapping.to.find_for_database_authentication(authentication_hash)
                              encrypted = false
                          
                              return fail(:invalid) unless resource
                          Severity: Minor
                          Found in lib/locomotive/devise.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

                          Method sections_content has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def sections_content(model, sections, definitions)
                                source  = model.respond_to?(:title) ? :page : :site
                                content = model.sections_content || {}
                          
                                (sections[:top] + sections[:bottom]).each do |attributes|
                          Severity: Minor
                          Found in app/helpers/locomotive/page_content_helper.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

                          Method render_exception has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def render_exception(exception)
                                  ::Locomotive.log "[ApplicationError] #{exception.inspect}"
                          
                                  status = (case exception
                                  when ::Mongoid::Errors::DocumentNotFound  then 404
                          Severity: Minor
                          Found in app/controllers/locomotive/concerns/exception_controller.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

                          Method update_select_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def update_select_options(options)
                                return nil if options.blank?
                          
                                default_locale      = field._parent.site.default_locale.to_sym
                                include_new_options = false
                          Severity: Minor
                          Found in app/services/locomotive/custom_field_service.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

                          Severity
                          Category
                          Status
                          Source
                          Language