publiclab/plots2

View on GitHub

Showing 216 of 688 total issues

Function attachSaveListener has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  attachSaveListener() {
    // remove any other existing eventHandler
    $("textarea").off("input.save"); // input.save is a custom jQuery eventHandler
    const thisEditor = this; // save a reference to this editor, because inside the eventListener, "this" points to e.target
    //implementing a debounce function on save method
Severity: Minor
Found in app/assets/javascripts/editor.js - About 1 hr to fix

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

  def new
    @revision = Revision.new
    if current_user &.first_time_poster
      flash[:notice] = "You can create a wiki once your research note/question has been approved by moderators. Click <a href='https://publiclab.org/notes/tester/04-23-2016/new-moderation-system-for-first-time-posters'>here</a> to learn why."
      redirect_to '/'
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 1 hr to fix

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

  def create
    if !current_user.admin?
      flash[:warning] = 'Only admins may edit features.'
      redirect_to "/features?_=#{Time.now.to_i}"
    else
Severity: Minor
Found in app/controllers/features_controller.rb - About 1 hr to fix

Method delete has 32 lines of code (exceeds 25 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

Function TimeAgo has a Cognitive Complexity of 11 (exceeds 5 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

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 reducer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const reducer = (state, action) => {
  switch(action.type) {
    // COMMENT actions
    case "CREATE COMMENT":
      return {
Severity: Minor
Found in app/javascript/components/reducers.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 create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @node = Node.find params[:id]
    @body = params[:body]
    @user = current_user
    begin
Severity: Minor
Found in app/controllers/comment_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 create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    if params[:i]
      @image = Image.new(remote_url: params[:i],
                         uid: current_user.uid)
      flash[:error] = 'The image could not be saved.' unless @image.save!
Severity: Minor
Found in app/controllers/images_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 show has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    return if redirect_to_node_path?(@node)

    if @node
      if @node.has_power_tag('question') && @node.status == 1
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

Method delete has 31 lines of code (exceeds 25 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

Function promptTag has 30 lines of code (exceeds 25 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

Function setupWiki has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function setupWiki(node_id, title, raw, logged_in) {
  // insert inline forms
  if (raw && logged_in) {
    $('#content-raw-markdown').html(shortCodePrompt($('#content-raw-markdown')[0], {
      submitUrl: '/wiki/replace/' + node_id
Severity: Minor
Found in app/assets/javascripts/wikis.js - About 1 hr to fix

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

  def create
    if current_user.status == 1
      # we no longer allow custom urls, just titles which are parameterized automatically into urls
      # slug = params[:title].parameterize
      # slug = params[:id].parameterize if params[:id] != "" && !params[:id].nil?
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 1 hr to fix

Method can_tag has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def can_tag(tagname, user, errors = false)
    one_split = tagname.split(':')[1]
    socials = { facebook: 'Facebook', github: 'Github', google_oauth2: 'Google', twitter: 'Twitter' }

    if tagname[0..4] == 'with:'
Severity: Minor
Found in app/models/node.rb - About 1 hr to fix

Method publish has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def publish
    if logged_in_as(['admin', 'moderator'])
      @node = Node.find params[:id]
      if @node.status == 1
        flash[:notice] = 'Item already published.'
Severity: Minor
Found in app/controllers/admin_controller.rb - About 1 hr to fix

Method delete has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def delete
    @comment = Comment.find params[:id]

    comments_node_and_path

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

Method stats has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def stats
    @start = params[:start] ? Time.parse(params[:start].to_s) : Time.now - 1.year
    @end = params[:end] ? Time.parse(params[:end].to_s) : Time.now
    tagname = params[:id]

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

Method range has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def range
    flash.now[:notice] = "Data is cached and recalculated daily"
    if params[:options].present? && params[:options] != 'For all time'
      params[:start] = Time.now - to_keyword(params[:options])
      params[:end] = Time.now
Severity: Minor
Found in app/controllers/stats_controller.rb - About 1 hr to fix

Method new has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def new
    @revision = Revision.new
    if current_user &.first_time_poster
      flash[:notice] = "You can create a wiki once your research note/question has been approved by moderators. Click <a href='https://publiclab.org/notes/tester/04-23-2016/new-moderation-system-for-first-time-posters'>here</a> to learn why."
      redirect_to '/'
Severity: Minor
Found in app/controllers/wiki_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 save_settings has a Cognitive Complexity of 10 (exceeds 5 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

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