publify/publify

View on GitHub

Showing 99 of 236 total issues

Consider simplifying this complex logical expression.
Open

                                        if( (options.initTime||options.defaultSelect||datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours())==parseInt(h)&&(options.step>59||Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes()/options.step)*options.step==parseInt(m))) {
                                            if( options.defaultSelect||datetimepicker.data('changed')) {
                                                classes.push('xdsoft_current');
                                            } else if( options.initTime ) {
                                                classes.push('xdsoft_init_time');
Severity: Major
Found in publify_core/app/assets/javascripts/datetimepicker.js - About 40 mins to fix

    Function edSetCookie has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function edSetCookie(name, value, expires, path, domain) {
    Severity: Minor
    Found in publify_core/app/assets/javascripts/quicktags.js - About 35 mins to fix

      Method query_rbls has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def query_rbls(rbls, *subdomains)
          rbls.each do |rbl|
            subdomains.uniq.each do |d|
              begin
                response = IPSocket.getaddress([d, rbl].join("."))
      Severity: Minor
      Found in publify_core/lib/spam_protection.rb - 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

      Method requested_article has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.requested_article(params)
          date_range = PublifyTime.delta(params[:year], params[:month], params[:day])
      
          req_params = {}
          req_params[:permalink] = params[:title] if params[:title]
      Severity: Minor
      Found in publify_core/app/models/article.rb - 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

      Method send_to_twitter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def send_to_twitter
          return false unless blog.has_twitter_configured?
          return false unless user.has_twitter_configured?
      
          twitter = Twitter::REST::Client.new do |config|
      Severity: Minor
      Found in publify_core/app/models/note.rb - 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

      Method filter_text has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.filter_text(text, filters)
          map = TextFilterPlugin.filter_map
      
          filters.each do |filter|
            next if filter.nil?
      Severity: Minor
      Found in publify_core/app/models/text_filter.rb - 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

      Method fetch_html_content_for_feeds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def fetch_html_content_for_feeds(item, this_blog)
          if item.password_protected?
            "<p>This article is password protected. Please " \
              "<a href='#{item.permalink_url}'>fill in your password</a> to read it</p>"
          elsif this_blog.hide_extended_on_rss
      Severity: Minor
      Found in publify_core/app/helpers/base_helper.rb - 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

      Method down has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def down
          if adapter_name == "PostgreSQL"
            indexes(:contents).each do |index|
              remove_index(:contents, name: index.name) if /blog_id/.match?(index.name)
            end
      Severity: Minor
      Found in publify_core/db/migrate/20150808052637_add_blog_ids.rb - 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

      Avoid too many return statements within this function.
      Open

              return this.error("Could not detect remote target type. Force the type using data-type=\"image|youtube|vimeo\"");
      Severity: Major
      Found in publify_core/app/assets/javascripts/lightbox.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return false
        Severity: Major
        Found in publify_core/app/assets/javascripts/bootstrap/affix.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return this.showInstagramVideo(this.options.remote);
          Severity: Major
          Found in publify_core/app/assets/javascripts/lightbox.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'
            Severity: Major
            Found in publify_core/app/assets/javascripts/bootstrap/affix.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                        return this.detectRemoteType(this.options.remote);
              Severity: Major
              Found in publify_core/app/assets/javascripts/lightbox.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return this.error("Could not detect remote target type. Force the type using data-type=\"image|youtube|vimeo\"");
                Severity: Major
                Found in publify_core/app/assets/javascripts/lightbox.js - About 30 mins to fix

                  Method is_spam? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def is_spam?(string)
                      return false unless this_blog.sp_global
                      return false if string.blank?
                  
                      reason = catch(:hit) do
                  Severity: Minor
                  Found in publify_core/lib/spam_protection.rb - About 25 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 shorten_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def shorten_url
                      return unless published?
                  
                      if redirect.present?
                        return if redirect.to_path == permalink_url
                  Severity: Minor
                  Found in publify_core/app/models/content.rb - About 25 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 up has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def up
                      add_column :redirects, :content_id, :integer
                      Redirect.find_each do |redirect|
                        redirections = Redirection.where(redirect_id: redirect.id)
                        if redirections.count > 1
                  Severity: Minor
                  Found in publify_core/db/migrate/20150807134129_simplify_redirect_relations.rb - About 25 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 classify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def classify
                      return :ham if user_id
                      return :spam if blog.default_moderate_comments
                      return :ham unless blog.sp_global
                  
                  
                  Severity: Minor
                  Found in publify_core/app/models/feedback.rb - About 25 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 excerpt_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def excerpt_text(length = 160)
                      text = if respond_to?(:excerpt) && (excerpt || "") != ""
                               generate_html(:excerpt, excerpt)
                             else
                               html(:all)
                  Severity: Minor
                  Found in publify_core/app/models/content_base.rb - About 25 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