publiclab/plots2

View on GitHub

Showing 686 of 688 total issues

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def notify_moderators_of_comment_spam(comment, moderator)
    subject = '[New Public Lab comment needs moderation]'
    @author = comment.author
    @moderator = moderator
    @comment = comment
Severity: Major
Found in app/mailers/admin_mailer.rb and 1 other location - About 1 hr to fix
app/mailers/admin_mailer.rb on lines 104..119

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def notify_moderators_of_comment_approval(comment, moderator)
    subject = '[New Public Lab commenter needs moderation]'
    @author = comment.author
    @moderator = moderator
    @comment = comment
Severity: Major
Found in app/mailers/admin_mailer.rb and 1 other location - About 1 hr to fix
app/mailers/admin_mailer.rb on lines 68..83

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  def self.notes_grid(body, _page = 1)
    body.gsub(/(?<![\>`])(\<p\>)?\[notes\:(\S+)\]/) do |_tagname|
      tagname = Regexp.last_match(2)
      exclude = nil

Severity: Major
Found in app/models/concerns/node_shared.rb and 2 other locations - About 1 hr to fix
app/models/concerns/node_shared.rb on lines 20..34
app/models/concerns/node_shared.rb on lines 286..300

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  def self.wikis_grid(body, _page = 1)
    body.gsub(/(?<![\>`])(\<p\>)?\[wikis\:(\S+)\]/) do |_tagname|
      tagname = Regexp.last_match(2)
      exclude = nil

Severity: Major
Found in app/models/concerns/node_shared.rb and 2 other locations - About 1 hr to fix
app/models/concerns/node_shared.rb on lines 20..34
app/models/concerns/node_shared.rb on lines 93..107

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  def self.notes_thumbnail_grid(body, _page = 1)
    body.gsub(/(?<![\>`])(\<p\>)?\[notes\:grid\:(\S+)\]/) do |_tagname|
      tagname = Regexp.last_match(2)
      exclude = nil

Severity: Major
Found in app/models/concerns/node_shared.rb and 2 other locations - About 1 hr to fix
app/models/concerns/node_shared.rb on lines 93..107
app/models/concerns/node_shared.rb on lines 286..300

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    if node.valid?
      revision = false
      saved = true
      ActiveRecord::Base.transaction do
        node.save!
Severity: Major
Found in app/models/node.rb and 1 other location - About 1 hr to fix
app/models/node.rb on lines 777..792

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 51.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language