scholarslab/prism

View on GitHub

Showing 4 of 6 total issues

Function setup_highlight has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  (typeof exports !== "undefined" && exports !== null ? exports : this).setup_highlight = function() {
    var all_colors, color, current_color, currently_marking, facet, get_word_number, mark, storage, val, _i, _j, _len, _len2, _ref;
    $("#highlighters span.facet").first().addClass('border');
    all_colors = [];
    _ref = $("li.facet");
Severity: Major
Found in public/javascripts/compiled/highlight.js - About 2 hrs to fix

    Method create has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create
    
        @prism = Prism.new(params[:prism])
        @prism.user_id = current_user.id
        @facet1 = Facet.new(params[:facet1])
    Severity: Minor
    Found in app/controllers/prisms_controller.rb - About 1 hr to fix

      Method create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
      
          @prism = Prism.new(params[:prism])
          @prism.user_id = current_user.id
          @facet1 = Facet.new(params[:facet1])
      Severity: Minor
      Found in app/controllers/prisms_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 new_with_session has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.new_with_session(params, session)
          super.tap do |user|
            if data = session["devise.facebook_data"] && session["devise.facebook_data"]["extra"]["raw_info"]
              user.email = data["email"] if user.email.blank?
            end
      Severity: Minor
      Found in app/models/user.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