withassociates/slices

View on GitHub

Showing 74 of 74 total issues

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

    this.uploadWithOptions(url, data, {
      progress: function(xhr, progress) { self.onS3Progress(progress) },
      success: function(response) { self.onS3Success(response) },
      error: function(response) { self.onS3Error(response) }
    });
Severity: Major
Found in app/assets/javascripts/slices/app/models/s3_file.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/slices/app/models/file.js on lines 61..65

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 81.

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 addSliceTemplate has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function addSliceTemplate(slice) {
      var templateData = {},
          sliceBlock,
          sliceContent,
          sliceContentTemplate = slices.availableSlices[slice.type].template,
Severity: Major
Found in app/assets/javascripts/slices/app/slices.js - About 2 hrs to fix

    Class Asset has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Asset
      include Mongoid::Document
      include Mongoid::Timestamps
      include MongoSearch::Searchable
      include Mongoid::Paperclip
    Severity: Minor
    Found in app/models/asset.rb - About 2 hrs to fix

      Function onFormSubmitted has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function onFormSubmitted(event) {
            event.preventDefault();
      
            busy = true;
      
      
      Severity: Major
      Found in app/assets/javascripts/slices/app/slices.js - About 2 hrs to fix

        Function thumbPress has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          thumbPress: function(event, thumb) {
            _.invoke(this.selection, 'deselect');
        
            if (event.shiftKey) {
              if (this.selection.length === 0) {
        Severity: Minor
        Found in app/assets/javascripts/slices/app/views/asset_library_view.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

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

                minutes: _.map(_.range(0, 60, 15), function(minute) {
                  var o = { value: _.string.pad('' + minute, 2, '0') };
                  if (minute == self.value.minutes()) o.attrs = 'selected';
                  return o;
                })
        Severity: Major
        Found in app/assets/javascripts/slices/app/views/date_field_view.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/slices/app/views/date_field_view.js on lines 80..84

        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 71.

        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

                hours: _.map(_.range(0, 24), function(hour) {
                  var o = { value: _.string.pad('' + hour, 2, '0') };
                  if (hour == self.value.hours()) o.attrs = 'selected';
                  return o;
                }),
        Severity: Major
        Found in app/assets/javascripts/slices/app/views/date_field_view.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/slices/app/views/date_field_view.js on lines 85..89

        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 71.

        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 save has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function save() {
              var dfd = $.Deferred();
        
              var params = $.extend({}, pageData);
        
        
        Severity: Minor
        Found in app/assets/javascripts/slices/app/models/page.js - About 1 hr to fix

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

            def update_attributes(attributes)
              attributes = attributes.symbolize_keys
          
              unless home?
                if attributes.has_key?(:name) || attributes.has_key?(:permalink)
          Severity: Minor
          Found in app/models/page.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

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

                  }, function() {
                    $('#page-meta').slideUp('fast');
                    $(this).html('<a href="#">advanced options&hellip;</a>');
                    $(this).removeClass('open');
                    $(document).trigger('slices:didHideAdvancedOptions');
          Severity: Major
          Found in app/assets/javascripts/slices/app/slices.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/slices/app/slices.js on lines 298..303

          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 66.

          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

                  toggle(function() {
                    $('#page-meta').slideDown('fast');
                    $(this).html('<a href="#">hide advanced options</a>');
                    $(this).addClass('open');
                    $(document).trigger('slices:didShowAdvancedOptions');
          Severity: Major
          Found in app/assets/javascripts/slices/app/slices.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/slices/app/slices.js on lines 303..308

          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 66.

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

            countMessage: function() {
              var t = this.countMessages,
                  total = this.collection.totalEntries,
                  count = this.collection.length;
          
          
          Severity: Minor
          Found in app/assets/javascripts/slices/app/views/asset_library_view.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 body has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            body: function() {
              var data        = [],
                  today       = moment().startOf('day'),
                  thisMonth   = this.month.clone(),
                  nextMonth   = thisMonth.clone().add('months', 1),
          Severity: Minor
          Found in app/assets/javascripts/slices/app/views/calendar_view.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 thumbPress has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            thumbPress: function(event, thumb) {
              _.invoke(this.selection, 'deselect');
          
              if (event.shiftKey) {
                if (this.selection.length === 0) {
          Severity: Minor
          Found in app/assets/javascripts/slices/app/views/asset_library_view.js - About 1 hr to fix

            Function editinplace has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              $.fn.editinplace = function (settings) {
                this.find('textarea,input[type=text]').each(
                function () {
                  var ta = $(this);
                  var val = ta.val();
            Severity: Minor
            Found in app/assets/javascripts/slices/lib/plugins.js - About 1 hr to fix

              Function addSliceContainers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function addSliceContainers() {
                    _.each(slices.availableContainers, function (container, machineName) {
                      $('#container-' + machineName + ' ul').empty();
                    });
              
              
              Severity: Minor
              Found in app/assets/javascripts/slices/app/slices.js - About 1 hr to fix

                Method make has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.make(attributes = {})
                    attributes = attributes.symbolize_keys
                    parent = parent_from_attributes(attributes)
                    attributes[:path] ||= path_from_attributes(attributes, parent)
                
                
                Severity: Minor
                Found in app/models/page.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 find_all_slices has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.find_all_slices
                      slices = []
                
                      Dir.glob(File.join(Rails.root, 'app/slices/**/*_slice.rb')).each do |path|
                
                
                Severity: Minor
                Found in lib/slices/available_slices.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 update_attributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def update_attributes(attributes)
                      [:slices, :set_slices].each do |embed_name|
                        next if attributes[embed_name].nil?
                
                        attributes[embed_name] = attributes[embed_name].map { |slice_attributes|
                Severity: Minor
                Found in lib/slices/has_slices.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

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

                    search: {
                      none: Handlebars.compile('No matching assets'),
                      one: Handlebars.compile('Showing 1 matching asset'),
                      some: Handlebars.compile(
                        'Showing latest {{count}} matching assets of {{total}} total'
                app/assets/javascripts/slices/app/views/asset_library_view.js on lines 290..299

                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 58.

                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