locomotivecms/engine

View on GitHub

Showing 91 of 169 total issues

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

    def build_fullpath
      if self.index_or_not_found?
        self.site.each_locale { |locale, current| self.fullpath = self.slug }
      else
        _parent = self.parent # do not hit the database more than once
Severity: Minor
Found in app/models/locomotive/page.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 underscore_keys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def underscore_keys
    new_hash = {}

    self.each_pair do |key, value|
      if value.respond_to?(:collect!) # Array
Severity: Minor
Found in lib/locomotive/core_ext.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 fetch_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def self.fetch_file(source)
      file = nil

      if source.is_a?(String) || source.is_a?(Hash) # simple string or drop
        source = source['url'] if source.is_a?(Hash)
Severity: Minor
Found in lib/locomotive/dragonfly.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 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { pageId, iframeLoaded, location } = this.props;
    const currentKey      = iframeLoaded ? location.pathname : 'startup';
    const slideDirection  = !iframeLoaded ? 'up' : (location.state || {}).slideDirection || 'up';
    const timeout         = slideDirection === 'none' ? { enter: 1, exit: 1 } : { enter: 150, exit: 100 };
Severity: Minor
Found in app/javascript/src/locomotive/editor/views/action_bar/index.js - About 1 hr to fix

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

      render() {
        const { sectionDefinition } = this.props;
    
        return (
          <div className="editor-section-blocks--new" ref={el => this.pickerRef = el}>

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

        render() {
          const { setting, getValue, label, handleChange } = this.props;
          const value = getValue(null);
          const asset = value && typeof(value) === 'object' ? value : { url: value };
      
      
      Severity: Minor
      Found in app/javascript/src/locomotive/editor/inputs/asset_picker.js - About 1 hr to fix

        Method _metafields_schema_schema has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def _metafields_schema_schema
                  {
                    'id' => 'http://locomotive.works/schemas/metafields.json',
                    'definitions' => {
                      'field' => {
        Severity: Minor
        Found in app/models/locomotive/concerns/site/metafields.rb - About 1 hr to fix

          Method to_json has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def to_json
                  add_authenticated_header
          
                  if get?
                    add_pagination_header if resource.respond_to?(:total_pages)
          Severity: Minor
          Found in lib/locomotive/action_controller/responder.rb - About 1 hr to fix

            Method as_json has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def as_json(methods = nil)
                  methods ||= self.getters
                  {}.tap do |hash|
                    methods.each do |meth|
                      _options = self.property_options[meth]
            Severity: Minor
            Found in lib/locomotive/presentable.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 build has a Cognitive Complexity of 10 (exceeds 5 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: Minor
            Found in app/javascript/src/locomotive/editor/services/routes_service.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

            Method attributes= has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def attributes=(values)
                  return unless values
            
                  @_attributes = values # memoize them for the callbacks
            
            
            Severity: Minor
            Found in lib/locomotive/presentable.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 document_stamp has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def document_stamp(document)
                  distance  = distance_of_time_in_words_to_now(document.updated_at)
                  update    = document.updated_at && document.updated_at != document.created_at
            
                  if account = (document.updated_by || document.created_by)
            Severity: Minor
            Found in app/helpers/locomotive/base_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

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

              render() {
                const TabPane = {
                  sections: Sections,
                  settings: Settings,
                  seo:      Seo
            Severity: Minor
            Found in app/javascript/src/locomotive/editor/views/action_bar/main.js - About 1 hr to fix

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

                render() {
                  const { input, suggestions, loading } = this.state;
                  const inputProps = {
                    placeholder:  this.props.placeholder,
                    value:        input || '',

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

                  render() {
                    const { input, suggestions, loading } = this.state;
                    const inputProps = {
                      placeholder:  this.props.placeholder,
                      value:        input || '',

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

                      def update_all(attributes)
                        each_metafield(attributes) do |namespace, name, value|
                          next unless field = site.find_metafield(name)
                  
                          if field['localized']
                  Severity: Minor
                  Found in app/services/locomotive/site_metafields_service.rb - About 55 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

                  Method to_json has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def to_json
                          add_authenticated_header
                  
                          if get?
                            add_pagination_header if resource.respond_to?(:total_pages)
                  Severity: Minor
                  Found in lib/locomotive/action_controller/responder.rb - About 55 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

                  Method persist_missing_translations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def persist_missing_translations(site, translations)
                            new_translations = []
                  
                            translations.each do |attributes|
                              if existing = site.translations.where(key: attributes[:key]).first
                  Severity: Minor
                  Found in lib/locomotive/steam/middlewares/missing_translations.rb - About 55 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

                  Method create_api_token has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def create_api_token(email, password, api_key)
                              if api_key.present?
                                account = self.where(api_key: api_key).first
                  
                                raise 'The API key is invalid.' if account.nil?
                  Severity: Minor
                  Found in app/models/locomotive/concerns/account/api_key.rb - About 55 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

                  Severity
                  Category
                  Status
                  Source
                  Language