starqle/biduribulan

View on GitHub

Showing 15 of 24 total issues

Method construct_menu has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def construct_menu(nodes, options = {}, current = nil)
    ul_class = ''

    case options
    when Hash
Severity: Minor
Found in app/helpers/entries_helper.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 construct_menu has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def construct_menu(nodes, options = {}, current = nil)
    ul_class = ''

    case options
    when Hash
Severity: Minor
Found in app/helpers/entries_helper.rb - About 1 hr to fix

    Method read_entry_type has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.read_entry_type
        yaml = YAML::load(File.read(Rails.root.join(Option.entry_types_yaml_path)))
        
        yaml['taxonomies'] = {}
        yaml['entry_type_associations'] = {}
    Severity: Minor
    Found in app/models/entry.rb - About 1 hr to fix

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

        def menu_item(node, options = {})  
          result = ''
          link_label = (node.rgt - node.lft > 1) ? icon('caret-down', node.to_s, 'right') : node.to_s
      
          result << '<div class="node">' unless options[:li_wrapper].eql?(false)
      Severity: Minor
      Found in app/helpers/entries_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 truncate_html has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def truncate_html(text, len = 30, at_end = ' ...')
          p = REXML::Parsers::PullParser.new((text.presence || '<p> </p>').gsub(/[\r\n\t]/, ''))
          tags = []
          new_len = len
          results = ''
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 1 hr to fix

        Method read_entry_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.read_entry_type
            yaml = YAML::load(File.read(Rails.root.join(Option.entry_types_yaml_path)))
            
            yaml['taxonomies'] = {}
            yaml['entry_type_associations'] = {}
        Severity: Minor
        Found in app/models/entry.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

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

          def self.get_tree(taxonomy_type, status=nil)
            taxonomies_sorted = []
            curr_level = 0
            leveling = [99]
            depth = 0
        Severity: Minor
        Found in app/models/taxonomy.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @option = Option.new(params[:option])
        
            value = {'entry_types' => params[:entry_types], 'fields' => []}
            if params[:field].present?
        Severity: Minor
        Found in app/controllers/admin/options_controller.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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            dirname = THEMES_DIRECTORIES
            @themes = Array.new
            Dir.foreach(dirname) do |filename|
              if File.directory?(dirname + filename) && filename != '.'  && filename != '..'
        Severity: Minor
        Found in app/controllers/admin/themes_controller.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 get_tree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.get_tree(entry_type, status=nil)
            entries_sorted = []
            curr_level = 0
            level = 0
            leveling = [99]
        Severity: Minor
        Found in app/models/entry.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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def update
            @option = Option.find(params[:id])
            
            value = {'entry_types' => params[:entry_types], 'fields' => []}
            if params[:field].present?
        Severity: Minor
        Found in app/controllers/admin/options_controller.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 truncate_html has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def truncate_html(text, len = 30, at_end = ' ...')
            p = REXML::Parsers::PullParser.new((text.presence || '<p> </p>').gsub(/[\r\n\t]/, ''))
            tags = []
            new_len = len
            results = ''
        Severity: Minor
        Found in app/helpers/application_helper.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 component has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def component(content = nil, title = nil, footer = nil, id = nil)
            result = '<div class="component ' + (title.present? ? title.parameterize + '-component' : '') + '"'
            result << ' id="' + id + '" ' if id.present?
            result << '>'
            result << '<div class="component_title">' + title  + '</div>' if title.present?
        Severity: Minor
        Found in app/helpers/application_helper.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            omniauth = request.env["omniauth.auth"]
            authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
            if authentication
              flash[:notice] = "Signed in successfully."
        Severity: Minor
        Found in app/controllers/authentications_controller.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 convert_entry_metas_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def convert_entry_metas_attributes(entry_metas_attributes)
            entry_metas_attributes.each do |k, v|
              if(v.count == 4 || v.count == 5)
                entry_metas_attributes[k]['value'] = Time.parse("#{v['date_value(1i)']}-#{v['date_value(2i)']}-#{v['date_value(3i)']}")
              elsif(v.count == 6 || v.count == 7)
        Severity: Minor
        Found in app/controllers/admin/entries_controller.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