pushtype/push_type

View on GitHub

Showing 6 of 28 total issues

Function ptStyle has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.FroalaEditor.PLUGINS.ptStyle = function (editor) {
  var $current_image;

  // The start point for your plugin.
  function _init () { }
Severity: Major
Found in admin/app/assets/javascripts/push_type/wysiwyg/style.js - About 3 hrs to fix

    Function ptStyle has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    $.FroalaEditor.PLUGINS.ptStyle = function (editor) {
      var $current_image;
    
      // The start point for your plugin.
      function _init () { }
    Severity: Minor
    Found in admin/app/assets/javascripts/push_type/wysiwyg/style.js - 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

    Method upload has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def upload
          respond_to do |format|
            format.json do
              if @asset.save
                hash = params[:froala] ? { link: media_path(@asset) } : { asset: asset_hash(@asset).as_json }
    Severity: Minor
    Found in admin/app/controllers/push_type/admin/assets_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 node_params has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def node_params
          params.fetch(@node.type.underscore.to_sym, {}).permit(:title, :slug, :status, :published_at, :published_to).tap do |whitelist|
            if Rails.version.to_f >= 5
              @node.fields.keys.each { |k| whitelist[k] = params[@node.type.underscore.to_sym].to_unsafe_h[k] if params[@node.type.underscore.to_sym].try(:[], k) }
            else
    Severity: Minor
    Found in admin/app/controllers/push_type/admin/nodes_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 field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def field(name, *args, &blk)
            raise ArgumentError if args.size > 2
            kind, opts = case args.size
              when 2 then args
              when 1 then args[0].is_a?(Hash) ? args.insert(0, :string) : args.insert(-1, {})
    Severity: Minor
    Found in core/app/models/concerns/push_type/customizable.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 run_node_filter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def run_node_filter(*args)
          methods_or_proc, opts = case args.last
            when Proc then args.first.is_a?(Hash) ? [ args.last, args.first ] : [ args.last, {} ]
            when Hash then [ args[0..-2], args.last ]
            else [ args, {} ]
    Severity: Minor
    Found in core/app/controllers/concerns/push_type/filterable.rb - About 45 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