cfpb/owning-a-home

View on GitHub
src/static/js/modules/explore-rates.js

Summary

Maintainability
F
5 days
Test Coverage

File explore-rates.js has 851 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var $ = require( 'jquery' );
var jQuery = $;
require( 'highcharts' );
Severity: Major
Found in src/static/js/modules/explore-rates.js - About 2 days to fix

    Function renderChart has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function renderChart( data, cb ) {
      if ( chart.isInitialized ) {
    
        var hc = chart.$el.highcharts();
    
    
    Severity: Major
    Found in src/static/js/modules/explore-rates.js - About 4 hrs to fix

      Function updateView has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function updateView() {
        chart.startLoading();
      
        // reset view
        dropdown( [ 'county', 'loan-term' ] ).hideHighlight();
      Severity: Major
      Found in src/static/js/modules/explore-rates.js - About 3 hrs to fix

        Function processCounty has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function processCounty() {
          var $counties = $( '#county' );
          var $county = $( '#county' ).find( ':selected' );
          var $loan = dropdown( 'loan-type' );
          var norms = [ 'conf', 'fha', 'va' ];
        Severity: Major
        Found in src/static/js/modules/explore-rates.js - About 2 hrs to fix

          Function processCounty has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          function processCounty() {
            var $counties = $( '#county' );
            var $county = $( '#county' ).find( ':selected' );
            var $loan = dropdown( 'loan-type' );
            var norms = [ 'conf', 'fha', 'va' ];
          Severity: Minor
          Found in src/static/js/modules/explore-rates.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

          Function checkForJumbo has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function checkForJumbo() {
            var loan;
            var jumbos = ['jumbo', 'agency', 'fha-hb', 'va-hb'];
            var norms = [ 'conf', 'fha', 'va' ];
            var warnings = {
          Severity: Major
          Found in src/static/js/modules/explore-rates.js - About 2 hrs to fix

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

            function renderChart( data, cb ) {
              if ( chart.isInitialized ) {
            
                var hc = chart.$el.highcharts();
            
            
            Severity: Minor
            Found in src/static/js/modules/explore-rates.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 renderInterestAmounts has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function renderInterestAmounts() {
              var shortTermVal = [],
                  longTermVal = [],
                  rate,
                  fullTerm = +( getSelection( 'loan-term' ) ) * 12;
            Severity: Minor
            Found in src/static/js/modules/explore-rates.js - About 1 hr to fix

              Function checkARM has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function checkARM() {
                // reset warning and info
                $( '#arm-warning' ).addClass( 'hidden' );
                $( '.arm-info' ).addClass( 'hidden' );
                var disallowedTypes = [ 'fha', 'va', 'va-hb', 'fha-hb' ];
              Severity: Minor
              Found in src/static/js/modules/explore-rates.js - About 1 hr to fix

                Function loadCounties has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function loadCounties() {
                
                  // And request 'em.
                  var request = getCounties();
                  request.done( function( resp ) {
                Severity: Minor
                Found in src/static/js/modules/explore-rates.js - About 1 hr to fix

                  Function checkForJumbo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function checkForJumbo() {
                    var loan;
                    var jumbos = ['jumbo', 'agency', 'fha-hb', 'va-hb'];
                    var norms = [ 'conf', 'fha', 'va' ];
                    var warnings = {
                  Severity: Minor
                  Found in src/static/js/modules/explore-rates.js - About 55 mins 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 renderDownPayment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function renderDownPayment() {
                  
                    var $el = $( this );
                    var $price = $( '#house-price' );
                    var $percent = $( '#percent-down' );
                  Severity: Minor
                  Found in src/static/js/modules/explore-rates.js - About 45 mins 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 checkARM has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function checkARM() {
                    // reset warning and info
                    $( '#arm-warning' ).addClass( 'hidden' );
                    $( '.arm-info' ).addClass( 'hidden' );
                    var disallowedTypes = [ 'fha', 'va', 'va-hb', 'fha-hb' ];
                  Severity: Minor
                  Found in src/static/js/modules/explore-rates.js - About 45 mins 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

                  var template = {
                    county: county,
                    countyConfWarning: countyConfWarning,
                    countyFHAWarning: countyFHAWarning,
                    countyVAWarning: countyVAWarning,
                  Severity: Major
                  Found in src/static/js/modules/explore-rates.js and 1 other location - About 1 hr to fix
                  src/static/js/modules/dropdown-utils.js on lines 215..228

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

                  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

                      if ( length < 180 ) {
                        shortTermVal.push( {
                          rate:     parseFloat( rate ),
                          interest: parseFloat( totalInterest ),
                          term:     length / 12
                  Severity: Minor
                  Found in src/static/js/modules/explore-rates.js and 1 other location - About 45 mins to fix
                  src/static/js/modules/explore-rates.js on lines 773..780

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

                  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

                      } else {
                        longTermVal.push( {
                          rate:     parseFloat( rate ),
                          interest: parseFloat( totalInterest ),
                          term:     length / 12
                  Severity: Minor
                  Found in src/static/js/modules/explore-rates.js and 1 other location - About 45 mins to fix
                  src/static/js/modules/explore-rates.js on lines 766..773

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

                  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

                      if ( disallowedTerms.indexOf( params['loan-term'] ) !== -1 ) {
                        dropdown( 'loan-term' ).reset();
                        dropdown( 'loan-term' ).showHighlight();
                        $( '#arm-warning' ).removeClass( 'hidden' );
                      }
                  Severity: Minor
                  Found in src/static/js/modules/explore-rates.js and 1 other location - About 35 mins to fix
                  src/static/js/modules/explore-rates.js on lines 825..829

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

                  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

                      if ( disallowedTypes.indexOf( params['loan-type'] ) !== -1 ) {
                        dropdown( 'loan-type' ).reset();
                        dropdown( 'loan-type' ).showHighlight();
                        $( '#arm-warning' ).removeClass( 'hidden' );
                      }
                  Severity: Minor
                  Found in src/static/js/modules/explore-rates.js and 1 other location - About 35 mins to fix
                  src/static/js/modules/explore-rates.js on lines 819..823

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status