ShogunPanda/ballast

View on GitHub

Showing 12 of 18 total issues

Function generateTOC has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function generateTOC() {
  if ($('#filecontents').length === 0) return;
  var _toc = $('<ol class="top"></ol>');
  var show = false;
  var toc = _toc;
Severity: Major
Found in docs/js/app.js - About 2 hrs to fix

    Function searchItem has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    function searchItem() {
      for (var i = 0; i < searchCache.length / 50; i++) {
        var item = searchCache[searchIndex];
        var searchName = (searchString.indexOf('::') != -1 ? item.fullName : item.name);
        var matchString = regexSearchString;
    Severity: Minor
    Found in docs/js/full_list.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

    Function fullListSearch has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function fullListSearch() {
      // generate cache
      searchCache = [];
      $('#full_list li').each(function() {
        var link = $(this).find('.object_link a');
    Severity: Minor
    Found in docs/js/full_list.js - About 1 hr to fix

      Function summaryToggle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function summaryToggle() {
        $('.summary_toggle').click(function() {
          if (localStorage) {
            localStorage.summaryCollapsed = $(this).text();
          }
      Severity: Minor
      Found in docs/js/app.js - About 1 hr to fix

        Function linkList has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function linkList() {
          $('#full_list li, #full_list li a:last').click(function(evt) {
            if ($(this).hasClass('toggle')) return true;
            if (this.tagName.toLowerCase() == "li") {
              if ($(this).find('.object_link a').length === 0) {
        Severity: Minor
        Found in docs/js/full_list.js - About 1 hr to fix

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

                  def unembed_relationships(data, target, field)
                    return data unless defined?(target.class::RELATIONSHIPS)
                    relationships = target.class::RELATIONSHIPS
          
                    data.each do |k, v|
          Severity: Minor
          Found in lib/ballast/concerns/json_api/request_handling.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 validate_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def validate_data(content_type)
                    if request.post? || request.patch?
                      raise(Errors::BadRequestError) unless request.content_type == content_type
          
                      request_load_data
          Severity: Minor
          Found in lib/ballast/concerns/json_api/request_handling.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 request_cast_attribute has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def request_cast_attribute(target, attributes, types, key, value)
          Severity: Minor
          Found in lib/ballast/concerns/json_api/request_handling.rb - About 35 mins to fix

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

                    def apply_value(collection, value, sort_field, sort_order)
                      if value
                        if cursor.use_offset
                          collection = collection.offset(value)
                        else
            Severity: Minor
            Found in lib/ballast/concerns/json_api/pagination_handling.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def call(operation = :perform, owner: nil, raise_errors: false, params: {}, **kwargs, &block)
                  # PI: Ignore Roodi on this method
                  @owner = owner if owner
                  fail!(status: 501, error: "Unsupported operation #{self.class}##{operation}.") unless respond_to?(operation)
                  Response.new(true, data: send(operation, params: params, **kwargs, &block))
            Severity: Minor
            Found in lib/ballast/service.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 update_javascript_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def update_javascript_params(key, data, replace: false)
                    initialize_view_params
            
                    if key
                      @javascript_params[key] = nil if replace
            Severity: Minor
            Found in lib/ballast/concerns/view.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 validate_reference has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def validate_reference(expected, id, sanitized, type)
                      raise("Relationship does not contain the \"data.type\" attribute") if type.blank?
                      raise("Relationship does not contain the \"data.id\" attribute") if id.blank?
                      raise("Invalid relationship type \"#{type}\" provided for when type \"#{expected}\" was expected.") unless sanitized == sanitize_model_name(expected)
            
            
            Severity: Minor
            Found in lib/ballast/concerns/json_api/request_handling.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