theodi/metrics-api

View on GitHub

Showing 71 of 71 total issues

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

  $.each(table.find('select.height-selector'), function() {
    select = $(this)
    tr = $(this).closest('tr')
    index = tr.index()

Severity: Major
Found in lib/public/javascripts/dashboard.js and 1 other location - About 6 hrs to fix
lib/public/javascripts/dashboard.js on lines 195..209

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

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

  $.each(table.find('select.width-selector'), function() {
    select = $(this)
    td = $(this).closest('td')
    index = td.index()

Severity: Major
Found in lib/public/javascripts/dashboard.js and 1 other location - About 6 hrs to fix
lib/public/javascripts/dashboard.js on lines 176..190

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

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 4 locations. Consider refactoring.
Open

    Gumby.addInitalisation('skiplink', function(all) {
        $('.skiplink > a, .skip').each(function() {
            var $this = $(this);

            // this element has already been initialized
Severity: Major
Found in docs/js/libs/ui/gumby.skiplink.js and 3 other locations - About 5 hrs to fix
docs/js/libs/ui/gumby.fixed.js on lines 203..223
docs/js/libs/ui/gumby.shuffle.js on lines 149..169
docs/js/libs/ui/gumby.toggleswitch.js on lines 202..222

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

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 4 locations. Consider refactoring.
Open

    Gumby.addInitalisation('shuffle', function(all) {
        $('[data-shuffle],[gumby-shuffle],[shuffle]').each(function() {
            var $this = $(this);

            // this element has already been initialized
Severity: Major
Found in docs/js/libs/ui/gumby.shuffle.js and 3 other locations - About 5 hrs to fix
docs/js/libs/ui/gumby.fixed.js on lines 203..223
docs/js/libs/ui/gumby.skiplink.js on lines 129..149
docs/js/libs/ui/gumby.toggleswitch.js on lines 202..222

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

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 4 locations. Consider refactoring.
Open

    Gumby.addInitalisation('switches', function(all) {
        $('.switch').each(function() {
            var $this = $(this);

            // this element has already been initialized
Severity: Major
Found in docs/js/libs/ui/gumby.toggleswitch.js and 3 other locations - About 5 hrs to fix
docs/js/libs/ui/gumby.fixed.js on lines 203..223
docs/js/libs/ui/gumby.shuffle.js on lines 149..169
docs/js/libs/ui/gumby.skiplink.js on lines 129..149

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

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 4 locations. Consider refactoring.
Open

    Gumby.addInitalisation('fixed', function(all) {
        $('[data-fixed],[gumby-fixed],[fixed]').each(function() {
            var $this = $(this);

            // this element has already been initialized
Severity: Major
Found in docs/js/libs/ui/gumby.fixed.js and 3 other locations - About 5 hrs to fix
docs/js/libs/ui/gumby.shuffle.js on lines 149..169
docs/js/libs/ui/gumby.skiplink.js on lines 129..149
docs/js/libs/ui/gumby.toggleswitch.js on lines 202..222

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

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

    $('.signup-form').validation({
      // pass an array of required field objects
      required: [
        {
          name: 'email',
Severity: Major
Found in docs/js/theme.js and 1 other location - About 5 hrs to fix
docs/js/theme.js on lines 90..117

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

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

    $('.header-signup').validation({
      // pass an array of required field objects
      required: [
        {
          name: 'email',
Severity: Major
Found in docs/js/theme.js and 1 other location - About 5 hrs to fix
docs/js/theme.js on lines 120..147

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

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

    def self.registered(app)

      app.get '/metrics' do
        @metrics = list_metrics
        @title = 'Metrics API'
Severity: Major
Found in lib/bothan/metrics.rb - About 4 hrs to fix

    Function buildTable has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    function buildTable(row_num, col_num) {
      table = $('#dashboard');
    
      form = $('#metric-template').clone();
      form.removeClass('hidden')
    Severity: Minor
    Found in lib/public/javascripts/dashboard.js - About 4 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

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

        Gumby.addInitalisation('checkbox', function() {
            $('.checkbox').each(function() {
                var $this = $(this);
                // this element has already been initialized
                if($this.data('isCheckbox')) {
    Severity: Major
    Found in docs/js/libs/ui/gumby.checkbox.js and 3 other locations - About 3 hrs to fix
    docs/js/libs/ui/gumby.navbar.js on lines 91..102
    docs/js/libs/ui/gumby.radiobtn.js on lines 72..83
    docs/js/libs/ui/gumby.tabs.js on lines 60..71

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

    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 4 locations. Consider refactoring.
    Open

        Gumby.addInitalisation('tabs', function() {
            $('.tabs').each(function() {
                var $this = $(this);
                // this element has already been initialized
                if($this.data('isTabs')) {
    Severity: Major
    Found in docs/js/libs/ui/gumby.tabs.js and 3 other locations - About 3 hrs to fix
    docs/js/libs/ui/gumby.checkbox.js on lines 83..94
    docs/js/libs/ui/gumby.navbar.js on lines 91..102
    docs/js/libs/ui/gumby.radiobtn.js on lines 72..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 97.

    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 4 locations. Consider refactoring.
    Open

        Gumby.addInitalisation('navbar', function() {
            $('.navbar').each(function() {
                var $this = $(this);
                // this element has already been initialized
                if($this.data('isNavbar')) {
    Severity: Major
    Found in docs/js/libs/ui/gumby.navbar.js and 3 other locations - About 3 hrs to fix
    docs/js/libs/ui/gumby.checkbox.js on lines 83..94
    docs/js/libs/ui/gumby.radiobtn.js on lines 72..83
    docs/js/libs/ui/gumby.tabs.js on lines 60..71

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

    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 4 locations. Consider refactoring.
    Open

        Gumby.addInitalisation('radiobtn', function() {
            $('.radio').each(function() {
                var $this = $(this);
                // this element has already been initialized
                if($this.data('isRadioBtn')) {
    Severity: Major
    Found in docs/js/libs/ui/gumby.radiobtn.js and 3 other locations - About 3 hrs to fix
    docs/js/libs/ui/gumby.checkbox.js on lines 83..94
    docs/js/libs/ui/gumby.navbar.js on lines 91..102
    docs/js/libs/ui/gumby.tabs.js on lines 60..71

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

    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

    File dashboard.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    function growRow(td, span, cell_content) {
      var cell_content = (typeof cell_content === 'undefined') ? '<td></td>' : cell_content
      var row = td.closest("tr")
      var index = td.index()
      var old_span = (typeof td.attr('rowspan') === 'undefined') ? 1 : Number(td.attr('rowspan'))
    Severity: Minor
    Found in lib/public/javascripts/dashboard.js - About 3 hrs to fix

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

          function Switch($el) {
              this.$el = $($el);
              this.targets = [];
              this.on = '';
      
      
      Severity: Major
      Found in docs/js/libs/ui/gumby.toggleswitch.js and 1 other location - About 2 hrs to fix
      docs/js/libs/ui/gumby.toggleswitch.js on lines 9..18

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

      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

          function Toggle($el) {
              this.$el = $($el);
              this.targets = [];
              this.on = '';
      
      
      Severity: Major
      Found in docs/js/libs/ui/gumby.toggleswitch.js and 1 other location - About 2 hrs to fix
      docs/js/libs/ui/gumby.toggleswitch.js on lines 21..30

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

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

          def self.registered(app)
      
            app.get '/metrics' do
              @metrics = list_metrics
              @title = 'Metrics API'
      Severity: Minor
      Found in lib/bothan/metrics.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 registered has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.registered(app)
      
            app.get '/dashboards' do
              @dashboards = Dashboard.all
              @title = "Dashboards"
      Severity: Major
      Found in lib/bothan/dashboards.rb - About 2 hrs to fix

        File metrics_helpers.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Bothan
          module Helpers
            module Metrics
        
              # pseudo controller functions, ones returning objects, ergo ones grape-entity concerns itself with
        Severity: Minor
        Found in lib/bothan/helpers/metrics_helpers.rb - About 2 hrs to fix
          Severity
          Category
          Status
          Source
          Language