publiclab/plots2

View on GitHub

Showing 216 of 688 total issues

Function exports has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(api) {
  var validEnv = ['development', 'test', 'production']
  var currentEnv = api.env()
  var isDevelopmentEnv = api.env('development')
  var isProductionEnv = api.env('production')
Severity: Major
Found in babel.config.js - About 3 hrs to fix

Class UsersController has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

class UsersController < ApplicationController
  before_action :require_no_user, only: [:new]
  before_action :require_user, only: %i(edit update save_settings settings)
   before_action :set_user, only: %i(info followed following followers)

Severity: Minor
Found in app/controllers/users_controller.rb - About 3 hrs to fix

Method handle_site_login_flow has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def handle_site_login_flow
    username = params[:user_session][:username] if params[:user_session]
    u = User.find_by(username: username) || User.find_by(email: username)
    if u && u.password_checker != 0
      n = u.password_checker
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 3 hrs to fix

Method show_for_author has a Cognitive Complexity of 22 (exceeds 5 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 3 hrs 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 handle_social_login_flow has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def handle_social_login_flow(auth)
    # Find an identity here
    @identity = UserTag.find_with_omniauth(auth)
    return_to = request.env['omniauth.origin'] || root_url
    return_to += '?_=' + Time.now.to_i.to_s
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 3 hrs to fix

Class AdminController has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

class AdminController < ApplicationController
  before_action :require_user, only: %i(spam spam_revisions mark_comment_spam publish_comment spam_comments)

  # intended to provide integration tests for assets
  def assets; end
Severity: Minor
Found in app/controllers/admin_controller.rb - About 2 hrs to fix

Class WikiController has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

class WikiController < ApplicationController
  before_action :require_user, only: %i(new create edit update delete replace)

  def subdomain
    url = "//#{request.host}/wiki/"
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 2 hrs to fix

Class TagController has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

class TagController < ApplicationController
  respond_to :html, :xml, :json, :ics
  before_action :require_user, only: %i(create delete)
  include Pagy::Backend

Severity: Minor
Found in app/controllers/tag_controller.rb - About 2 hrs to fix

Function CommentsList has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

const CommentsList = ({
  commentFormsVisibility,
  comments,
  currentUser,
  dispatch,
Severity: Minor
Found in app/javascript/components/CommentsList.js - About 2 hrs 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_note has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def self.new_note(params)
    saved = false
    author = User.find(params[:uid])
    node = Node.new(uid:     author.uid,
                    title:   params[:title],
Severity: Minor
Found in app/models/node.rb - About 2 hrs 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 generateCommentComponents has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const generateCommentComponents = (commentsArray) => {
    return commentsArray.map((comment) => {
      // these props are common to all forms
      const commentFormProps = {
        commentId: comment.commentId,
Severity: Major
Found in app/javascript/components/CommentsList.js - About 2 hrs to fix

Function reducer has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const reducer = (state, action) => {
  switch(action.type) {
    // COMMENT actions
    case "CREATE COMMENT":
      return {
Severity: Major
Found in app/javascript/components/reducers.js - About 2 hrs to fix

Method create has a Cognitive Complexity of 19 (exceeds 5 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 2 hrs 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 19 (exceeds 5 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 2 hrs 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_tag has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def add_tag(tagname, user)
    if user.status == 1
      tagname = tagname.downcase
      unless has_tag_without_aliasing(tagname)
        saved = false
Severity: Major
Found in app/models/node.rb - About 2 hrs to fix

Method index has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    @toggle = params[:sort] || "uses"

    @title = I18n.t('tag_controller.tags')
    @paginated = true
Severity: Major
Found in app/controllers/tag_controller.rb - About 2 hrs to fix

File validation.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

$(document).ready(function() {
  $("#edit-form").validate({
    rules: {
      'user[email]': {
        required: true,
Severity: Minor
Found in app/assets/javascripts/validation.js - About 2 hrs to fix

Method check_and_add_tweets has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def self.check_and_add_tweets(tweets)
    tweets.each do |tweet|
      next unless tweet.reply?

      in_reply_to_tweet_id = tweet.in_reply_to_tweet_id
Severity: Minor
Found in app/models/comment.rb - About 2 hrs 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 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    @node = if params[:lang]
              Node.find_wiki(params[:lang] + '/' + params[:id])
            else
              Node.find_wiki(params[:id])
Severity: Major
Found in app/controllers/wiki_controller.rb - About 2 hrs to fix

Method index has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    @toggle = params[:sort] || "uses"

    @title = I18n.t('tag_controller.tags')
    @paginated = true
Severity: Minor
Found in app/controllers/tag_controller.rb - About 2 hrs 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