studpad/studpad

View on GitHub

Showing 118 of 280 total issues

Function slide has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  Carousel.prototype.slide = function (type, next) {
    var $active   = this.$element.find('.item.active')
    var $next     = next || this.getItemForDirection(type, $active)
    var isCycling = this.interval
    var direction = type == 'next' ? 'left' : 'right'
Severity: Minor
Found in app/assets/javascripts/bootstrap.js - About 1 hr to fix

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

      def update
        @post.update_attributes post_params
        @post.bind_tags(params[:post][:tags])
        @post.attachment_ids = params[:post][:attachment_ids]
        element_ids = params[:post][:text_elements].values.map{|e| e[:id]}.compact
    Severity: Minor
    Found in app/controllers/posts_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

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

      render: function(){
        var style = {
          background: 'url(' + this.props.comment.author.avatar + ') no-repeat',
          backgroundSize: 'cover'
        };
    Severity: Minor
    Found in app/assets/javascripts/components/comment.js.jsx - 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 render has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render: function() {
        var elements = this.props.text_elements;
        var length = elements.length;
        rendered_elements = elements.map(function (e, position) {
          switch (e.type) {
    Severity: Minor
    Found in app/assets/javascripts/components/post_text.js.jsx - About 1 hr to fix

      Function update has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var update = function(e, options) {
            var value, keyCode, printable, placeholder, width;
            var shift, character, selection;
            e = e || window.event || {};
            options = options || {};
      Severity: Minor
      Found in app/assets/javascripts/selectize_fixed.js - About 1 hr to fix

        Function addItem has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            addItem: function(value, silent) {
              var events = silent ? [] : ['change'];
        
              debounce_events(this, events, function() {
                var $item, $option, $options;
        Severity: Minor
        Found in app/assets/javascripts/selectize_fixed.js - About 1 hr to fix

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

            render: function() {
              var tags = this.props.post.tags.map(function(name, i){
                return <a key={i} href={'/explore?tag_name=' + name}>{'#'+name}</a>
              });
              if (window.currentUser && window.currentUser.admin)
          Severity: Minor
          Found in app/assets/javascripts/components/post.js.jsx - About 1 hr to fix

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

              Modal.prototype.backdrop = function (callback) {
                var that = this
                var animate = this.$element.hasClass('fade') ? 'fade' : ''
            
                if (this.isShown && this.options.backdrop) {
            Severity: Minor
            Found in app/assets/javascripts/bootstrap.js - About 1 hr to fix

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

                Modal.prototype.show = function (_relatedTarget) {
                  var that = this
                  var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
              
                  this.$element.trigger(e)
              Severity: Minor
              Found in app/assets/javascripts/bootstrap.js - About 1 hr to fix

                Function activate has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  Tab.prototype.activate = function (element, container, callback) {
                    var $active    = container.find('> .active')
                    var transition = callback
                      && $.support.transition
                      && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
                Severity: Minor
                Found in app/assets/javascripts/bootstrap.js - About 1 hr to fix

                  Function updateOption has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      updateOption: function(value, data) {
                        var self = this;
                        var $item, $item_new;
                        var value_new, index_item, cache_items, cache_options, order_old;
                  
                  
                  Severity: Minor
                  Found in app/assets/javascripts/selectize_fixed.js - About 1 hr to fix

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

                      render: function() {
                    
                        var className;
                        if (this.props.className) {
                          className = this.props.className;
                    Severity: Minor
                    Found in app/assets/javascripts/react-dropzone.js.jsx - About 1 hr to fix

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

                        render: function () {
                          var comments = this.props.comments;
                          if (!this.state.show_all){
                            comments = comments.slice(-3);
                          }
                      Severity: Minor
                      Found in app/assets/javascripts/components/comment_list.js.jsx - About 1 hr to fix

                        Function onChangeLink has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          onChangeLink: function(event) {
                            url = event.target.value;
                            console.log(url);
                            if (this.state.timeout_id)
                              clearTimeout(this.state.timeout_id);
                        Severity: Minor
                        Found in app/assets/javascripts/components/post_modal_form.js.jsx - About 1 hr to fix

                          Function createItem has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              createItem: function(input, triggerDropdown) {
                                var self  = this;
                                var caret = self.caretPos;
                                input = input || $.trim(self.$control_input.val() || '');
                          
                          
                          Severity: Minor
                          Found in app/assets/javascripts/selectize_fixed.js - About 1 hr to fix

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

                              render: function() {
                                return (
                                <ReactBootstrap.Modal
                                  onHide={this.hide}
                                  backdrop='static'
                            Severity: Minor
                            Found in app/assets/javascripts/components/post_modal_form.js.jsx - About 1 hr to fix

                              Method update has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def update
                                  @post.update_attributes post_params
                                  @post.bind_tags(params[:post][:tags])
                                  @post.attachment_ids = params[:post][:attachment_ids]
                                  element_ids = params[:post][:text_elements].values.map{|e| e[:id]}.compact
                              Severity: Minor
                              Found in app/controllers/posts_controller.rb - About 1 hr to fix

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

                                  render: function () {
                                    var self = this;
                                    var childElements = this.state.posts.map(function(post, i){
                                      return (
                                        <ExplorePost
                                Severity: Minor
                                Found in app/assets/javascripts/explore_grid.js.jsx - About 1 hr to fix

                                  Function show has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    Collapse.prototype.show = function () {
                                      if (this.transitioning || this.$element.hasClass('in')) return
                                  
                                      var activesData
                                      var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')
                                  Severity: Minor
                                  Found in app/assets/javascripts/bootstrap.js - About 1 hr to fix

                                    Function componentDidMount has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      componentDidMount() {
                                        $(this.refs.input).selectize({
                                          splitOn: /#/,
                                          delimiters_array: [',', "#"],
                                          persist: false,
                                    Severity: Minor
                                    Found in app/assets/javascripts/components/tag_select.js.jsx - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language