cfpb/owning-a-home

View on GitHub

Showing 154 of 154 total issues

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

  return {
    disable:              disable,
    enable:               enable,
    show:                 show,
    hide:                 hide,
Severity: Major
Found in src/static/js/modules/dropdown-utils.js and 1 other location - About 1 hr to fix
src/static/js/modules/explore-rates.js on lines 36..49

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

Function getRateData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function getRateData() {
    if ( currentRequest && typeof currentRequest === 'object' ) {
      currentRequest.abort();
    }

Severity: Minor
Found in src/static/js/modules/formalize.js - About 1 hr to fix

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

      function InputGraded( options ) {
        // TODO see if bind() can be used in place of _self = this.
        // Note bind()'s lack of IE8 support.
        var _self = this;
        // Load our handlebar templates.
      Severity: Minor
      Found in src/static/js/modules/prepare-worksheets/inputs/input-graded.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 render has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          render: function () {
              var tooltipHtml = common.outputTooltips[this.props.prop]
                                ? <Tooltip text={common.outputTooltips[this.props.prop]}/>
                                : null;
              var headingType = function (prop, type, label, scenario) {

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

          componentDidMount: function() {
              var scenario = this.state.scenario;
              var animating;
      
              LoanStore.addChangeListener(this._onChange);
      Severity: Minor
      Found in src/static/js/modules/loan-comparison/components/app.js - About 1 hr to fix

        Function dispatchToken has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        LoanStore.dispatchToken = AppDispatcher.register( function( action ) {
          switch( action.actionType ) {
        
            case LoanConstants.UPDATE_LOAN:
              // update both loans or single loan, dep. on whether the prop changed
        Severity: Minor
        Found in src/static/js/modules/loan-comparison/stores/loan-store.js - About 1 hr to fix

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

            fetchInsurance: function( loan ) {
              return api.fetchMortgageInsuranceData( loan )
                        .done( function( results ) {
                          LoanStore.updateLoanInsurance( loan, ( results || {} ).data );
                        } );
          Severity: Major
          Found in src/static/js/modules/loan-comparison/stores/loan-store.js and 1 other location - About 1 hr to fix
          src/static/js/modules/loan-comparison/stores/loan-store.js on lines 306..311

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

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

              var Observer = (function(){
                var wraped = [];
                var Observer = function(O, callback, accept){
                  validateArguments(O, callback, accept);
                  if (!accept) {
          Severity: Minor
          Found in src/static/js/modules/object.observe-polyfill.js - About 1 hr to fix

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

              fetchRates: function( loan ) {
                return api.fetchRateData( loan )
                          .done( function( results ) {
                            LoanStore.updateLoanRates( loan, ( results || {} ).data );
                          } );
            Severity: Major
            Found in src/static/js/modules/loan-comparison/stores/loan-store.js and 1 other location - About 1 hr to fix
            src/static/js/modules/loan-comparison/stores/loan-store.js on lines 282..287

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

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

                render: function() {
                    var loading = "";
                    var results = ['closing-costs','monthly-payment','overall-costs'].map(function (prop) {
                        return (
                            <LoanOutputTable result={prop} prop={prop} loans={this.props.loans}  scenario={this.props.scenario} />

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

                function EmailSignup( element ) {
                  var UNDEFINED;
                  var _baseElement = $(element);
                  var _formElement = _baseElement.find( 'form' );
                  var _emailElement = _formElement.find( 'input[type="email"]' );
                Severity: Minor
                Found in src/static/js/modules/email-signup.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 dispatchToken has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                LoanStore.dispatchToken = AppDispatcher.register( function( action ) {
                  switch( action.actionType ) {
                
                    case LoanConstants.UPDATE_LOAN:
                      // update both loans or single loan, dep. on whether the prop changed
                Severity: Minor
                Found in src/static/js/modules/loan-comparison/stores/loan-store.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 filterEmptyRows has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                this.filterEmptyRows = function( worksheet, opts ) {
                  // Filters out worksheet rows without text values
                  // opts.requireGrade = true will also filter out items without grades
                  // opts.skipLast = true will allow blank values for last item
                  // TODO: add delete option?
                Severity: Minor
                Found in src/static/js/modules/prepare-worksheets/worksheet-model.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 InputNotes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function InputNotes( options ) {
                  // TODO see if bind() can be used in place of _self = this.
                  // Note bind()'s lack of IE8 support.
                  var _self = this;
                  var _row = options.row;
                Severity: Minor
                Found in src/static/js/modules/prepare-worksheets/inputs/input-notes.js - About 1 hr to fix

                  Function loadPage has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function loadPage( lastPage, pageNum ) {
                    formExplainer.currentPage = pageNum;
                    $( '.form-explainer_page-link' ).removeClass( 'current-page' );
                    $( '.form-explainer_page-link[data-page=' + pageNum + ']' ).addClass( 'current-page' );
                  
                  
                  Severity: Minor
                  Found in src/static/js/modules/form-explainer.js - About 1 hr to fix

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

                      function addEvent(obj, event, func) {
                        if (obj.addEventListener) {
                          obj.addEventListener(event, func, false);
                        } else if (obj.attachEvent) {
                          obj.attachEvent('on' + event, func);
                    Severity: Major
                    Found in src/static/js/modules/placeholder-polyfill.js and 1 other location - About 1 hr to fix
                    src/static/js/modules/placeholder-polyfill.js on lines 199..205

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

                    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 removeEvent(obj, event, func) {
                        if (obj.removeEventListener) {
                          obj.removeEventListener(event, func, false);
                        } else if (obj.detachEvent) {
                          obj.detachEvent('on' + event, func);
                    Severity: Major
                    Found in src/static/js/modules/placeholder-polyfill.js and 1 other location - About 1 hr to fix
                    src/static/js/modules/placeholder-polyfill.js on lines 191..197

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

                    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