publiclab/plots2

View on GitHub

Showing 216 of 688 total issues

Function diff has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function diff( o, n ) {
  var ns = new Object();
  var os = new Object();
  
  for ( var i = 0; i < n.length; i++ ) {
Severity: Minor
Found in app/assets/javascripts/jsdiff.js - 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 show_for_author has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show_for_author
    # try for a matching /wiki/_TAGNAME_ or /_TAGNAME_
    @wiki = Node.where(path: "/wiki/#{params[:id]}").try(:first) || Node.where(path: "/#{params[:id]}").try(:first)
    @wiki = Node.find(@wiki.power_tag('redirect')) if @wiki&.has_power_tag('redirect')

Severity: Minor
Found in app/controllers/tag_controller.rb - About 1 hr to fix

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

  def self.search(query:, order: :default, type: :natural, limit: 25)
    order_param = if order == :default
                    { changed: :desc }
                  elsif order == :likes
                    { cached_likes: :desc }
Severity: Minor
Found in app/models/node.rb - About 1 hr to fix

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

  const handleCreateComment = (commentId, formType) => {
    // form ID is either reply-123 or main
    const formId = formType === "reply" ? "reply-" + commentId : "main";
    console.log(state.textAreaValues);
    const commentBody = state.textAreaValues[formId];
Severity: Minor
Found in app/javascript/components/CommentsContainer.js - About 1 hr to fix

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

var TimeAgo = (function() {
    var self = {};
    
    // Public Methods
    self.locales = {
Severity: Minor
Found in app/assets/javascripts/timeago.js - About 1 hr to fix

Function setTypeVisibility has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var setTypeVisibility = function(type, checked) {

    if (type == "all") {

      Object.keys(types).forEach(function(type, i) {
Severity: Minor
Found in app/assets/javascripts/dashboard.js - About 1 hr to fix

Method graph_data has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.graph_data(limit = 250, type = 'nodes', weight = 0)
    Rails.cache.fetch("graph-data/#{limit}/#{type}/#{weight}", expires_in: 1.weeks) do
      data = {}
      data["tags"] = []
      if type == 'nodes' # notes
Severity: Minor
Found in app/models/tag.rb - About 1 hr to fix

Method profile has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def profile
    if current_user && params[:id].nil?
      redirect_to "/profile/#{current_user.username}"
    elsif !current_user && params[:id].nil?
      redirect_to "/"
Severity: Minor
Found in app/controllers/users_controller.rb - About 1 hr to fix

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

  def self.search(query:, order: :default, type: :natural, limit: 25)
    order_param = if order == :default
                    { changed: :desc }
                  elsif order == :likes
                    { cached_likes: :desc }
Severity: Minor
Found in app/models/node.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

Function diffString2 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function diffString2( o, n ) {
  o = o.replace(/\s+$/, '');
  n = n.replace(/\s+$/, '');

  var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/) );
Severity: Minor
Found in app/assets/javascripts/jsdiff.js - 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 list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def list
    sort_param = params[:sort]
    @tagname_param = params[:tagname]

    order_string = if params[:id]
Severity: Minor
Found in app/controllers/users_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 delete has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def delete
    node_tag = NodeTag.where(nid: params[:nid], tid: params[:tid]).first
    node = Node.where(nid: params[:nid]).first
    # only admins, mods can delete other peoples' tags if the note/wiki contains the locked tag
    if (node_tag.uid == current_user.uid && !node.has_tag('locked')) || logged_in_as(['admin', 'moderator']) || (node.uid == current_user.uid && !node.has_tag('locked'))
Severity: Minor
Found in app/controllers/tag_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 add has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def add
    if current_user && params[:type] == "tag"

      tag = Tag.find_by(name: params[:name])

Severity: Minor
Found in app/controllers/subscription_controller.rb - About 1 hr to fix

Method list has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def list
    sort_param = params[:sort]
    @tagname_param = params[:tagname]

    order_string = if params[:id]
Severity: Minor
Found in app/controllers/users_controller.rb - About 1 hr to fix

Method save_settings has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def save_settings
    user_settings = [
      'notify-comment-direct:false',
      'notify-likes-direct:false',
      'notify-comment-indirect:false',
Severity: Minor
Found in app/controllers/users_controller.rb - About 1 hr to fix

Function promptTag has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function promptTag(val) {
  var input;
  switch(val) {

    case "series:":
Severity: Minor
Found in app/assets/javascripts/tagging.js - 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 update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    @password_verification = user_verification_params
    @user = current_user
    @user = User.find_by(username: params[:id]) if params[:id] && logged_in_as(['admin'])
    if @user.valid_password?(user_verification_params["current_password"]) || user_verification_params["ui_update"].nil? || (user_verification_params["current_password"].blank? && user_verification_params["password"].blank? && user_verification_params["password_confirmation"].blank?)
Severity: Minor
Found in app/controllers/users_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 delete has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def delete
    output = {
      status: false,
      tid: 0,
      errors: []
Severity: Minor
Found in app/controllers/user_tags_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 graph_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def self.graph_data(limit = 250, type = 'nodes', weight = 0)
    Rails.cache.fetch("graph-data/#{limit}/#{type}/#{weight}", expires_in: 1.weeks) do
      data = {}
      data["tags"] = []
      if type == 'nodes' # notes
Severity: Minor
Found in app/models/tag.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 delete has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def delete
    @node = Node.find(params[:id])
    if current_user && (current_user.uid == @node.uid || current_user.can_moderate?)
      if @node.authors.uniq.length == 1
        @node.destroy
Severity: Minor
Found in app/controllers/notes_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

Severity
Category
Status
Source
Language