baw/ThePurpleNotes

View on GitHub

Showing 6 of 10 total issues

Method seed_new_user has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def seed_new_user(user)
    notebook = Notebook.create!({
      user_id: user.id,
      title: "Shakespeare's Sonnets"
    })
Severity: Major
Found in app/helpers/seed_user.rb - About 3 hrs to fix

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

    PurpleNotes.Searches.search = function ($search, $div) {
      var count = function (searchString, stringToSearch) {
        searchString = searchString.toLowerCase();
        stringToSearch = stringToSearch.toLowerCase();
        
    Severity: Minor
    Found in app/assets/javascripts/search/search.js - About 1 hr to fix

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

        def create
          @sharing = Sharing.find_by(note_id: params[:note_id])
          
          if @sharing
            @sharing.update_attributes(active: true) unless @sharing.active
      Severity: Minor
      Found in app/controllers/api/sharings_controller.rb - About 55 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

      Function search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      PurpleNotes.Searches.search = function ($search, $div) {
        var count = function (searchString, stringToSearch) {
          searchString = searchString.toLowerCase();
          stringToSearch = stringToSearch.toLowerCase();
          
      Severity: Minor
      Found in app/assets/javascripts/search/search.js - About 55 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

      Function initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        initialize: function($notebooks, $notes, $noteEditor, $tags, $bootstrappedData, $search) {
      Severity: Minor
      Found in app/assets/javascripts/purple_notes.js - About 45 mins to fix

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

          def create
            @tag = Tag.find_by(name: params[:name])
            
            unless @tag
              @tag = Tag.new(name: params[:name])
        Severity: Minor
        Found in app/controllers/api/taggings_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

        Severity
        Category
        Status
        Source
        Language