SUSE/hackweek

View on GitHub

Showing 72 of 103 total issues

File holder.js has 3089 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!

Holder - client side image placeholders
Version 2.9.9+jl7z
© 2021 Ivan Malopinsky - https://imsky.co
Severity: Major
Found in app/assets/javascripts/holder.js - About 1 wk to fix

    Function buildSceneGraph has 141 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function buildSceneGraph(scene) {
            var fontSize = App.defaults.size;
            var fixedSize = scene.flags.fixedSize != null ? scene.flags.fixedSize : scene.theme.fixedSize;
            if (parseFloat(scene.theme.size)) {
                fontSize = scene.theme.size;
    Severity: Major
    Found in app/assets/javascripts/holder.js - About 5 hrs to fix

      Function shaven has 130 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function shaven(arrayOrObject) {
            var isArray = Array.isArray(arrayOrObject);
            var objType = typeof arrayOrObject === 'undefined' ? 'undefined' : _typeof(arrayOrObject);
      
            if (!isArray && objType !== 'object') {
      Severity: Major
      Found in app/assets/javascripts/holder.js - About 5 hrs to fix

        Function prepareDOMElement has 114 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function prepareDOMElement(prepSettings) {
                var mode = prepSettings.mode;
                var el = prepSettings.el;
                var flags = prepSettings.flags;
                var _engineSettings = prepSettings.engineSettings;
        Severity: Major
        Found in app/assets/javascripts/holder.js - About 4 hrs to fix

          Function run has 107 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  run: function(userOptions) {
                      //todo: split processing into separate queues
                      userOptions = userOptions || {};
                      var engineSettings = {};
                      var options = extend(App.settings, userOptions);
          Severity: Major
          Found in app/assets/javascripts/holder.js - About 4 hrs to fix

            Function _onDomReady has 86 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function _onDomReady(win) {
                    //Lazy loading fix for Firefox < 3.6
                    //http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html
                    if (document.readyState == null && document.addEventListener) {
                        document.addEventListener("DOMContentLoaded", function DOMContentLoaded() {
            Severity: Major
            Found in app/assets/javascripts/holder.js - About 3 hrs to fix

              Function SceneGraph has 82 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  var SceneGraph = function(sceneProperties) {
                      var nodeCount = 1;
              
                      //todo: move merge to helpers section
                      function merge(parent, child) {
              Severity: Major
              Found in app/assets/javascripts/holder.js - About 3 hrs to fix

                Function buildDom has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      function buildDom(elemArray) {
                        if (Array.isArray(elemArray) && elemArray.length === 0) {
                          // Ignore empty arrays
                          return {};
                        }
                Severity: Major
                Found in app/assets/javascripts/holder.js - About 3 hrs to fix

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

                  class ProjectsController < ApplicationController
                    before_action :find_project_by_id
                    before_action :redirect_to_slug, only: [:show]
                    load_and_authorize_resource find_by: :url
                    skip_before_action :authenticate_user!, only: %i[index show archived finished newest popular biggest random]
                  Severity: Minor
                  Found in app/controllers/projects_controller.rb - About 3 hrs to fix

                    Function formatValue has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function formatValue(ctx, value, recurseTimes) {
                          // Provide a hook for user-specified inspect functions.
                          // Check that value is an object with an inspect function on it
                          if (ctx.customInspect &&
                              value &&
                    Severity: Major
                    Found in app/assets/javascripts/holder.js - About 3 hrs to fix

                      Function render has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function render(renderSettings) {
                              var image = null;
                              var mode = renderSettings.mode;
                              var el = renderSettings.el;
                              var holderSettings = renderSettings.holderSettings;
                      Severity: Major
                      Found in app/assets/javascripts/holder.js - About 3 hrs to fix

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

                            module.exports = function (sceneGraph, renderSettings) {
                              var engineSettings = renderSettings.engineSettings;
                              var stylesheets = engineSettings.stylesheets;
                              var stylesheetXml = stylesheets.map(function (stylesheet) {
                                return '<?xml-stylesheet rel="stylesheet" href="' + stylesheet + '"?>';
                        Severity: Major
                        Found in app/assets/javascripts/holder.js - About 3 hrs to fix

                          Function stagingRenderer has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              var stagingRenderer = (function() {
                                  var svg = null,
                                      stagingText = null,
                                      stagingTextNode = null;
                                  return function(graph) {
                          Severity: Major
                          Found in app/assets/javascripts/holder.js - About 3 hrs to fix

                            Function parseURL has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function parseURL(url, instanceOptions) {
                                    var holder = {
                                        theme: extend(App.settings.themes.gray, null),
                                        stylesheets: instanceOptions.stylesheets,
                                        instanceOptions: instanceOptions
                            Severity: Major
                            Found in app/assets/javascripts/holder.js - About 2 hrs to fix

                              Class Project has 22 methods (exceeds 20 allowed). Consider refactoring.
                              Open

                              class Project < ApplicationRecord
                                include AASM
                                include Rails.application.routes.url_helpers
                              
                                validates :title, :description, :originator, presence: true
                              Severity: Minor
                              Found in app/models/project.rb - About 2 hrs to fix

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

                                  def recommended_projects(episode = nil)
                                    return [] if keywords.empty?
                                
                                    recommended = []
                                    keywords.each do |word|
                                Severity: Minor
                                Found in app/models/user.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 formatProperty has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
                                      var name, str, desc;
                                      desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
                                      if (desc.get) {
                                        if (desc.set) {
                                Severity: Major
                                Found in app/assets/javascripts/holder.js - About 2 hrs to fix

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

                                      function updateResizableElements(element) {
                                          var images;
                                          if (element == null || element.nodeType == null) {
                                              images = App.vars.resizableImages;
                                          } else {
                                  Severity: Minor
                                  Found in app/assets/javascripts/holder.js - About 1 hr to fix

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

                                        module.exports = (function() {
                                            var canvas = DOM.newEl('canvas');
                                            var ctx = null;
                                    
                                            return function(sceneGraph) {
                                    Severity: Minor
                                    Found in app/assets/javascripts/holder.js - About 1 hr to fix

                                      Function addTableFilter has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        $.fn.addTableFilter = function (options) {
                                          var o = $.extend({}, $.fn.addTableFilter.defaults, options),
                                            tgt,
                                            id,
                                            label,
                                      Severity: Minor
                                      Found in app/assets/javascripts/jquery.table-filter.js - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language