catarse/catarse.js

View on GitHub

Showing 1,380 of 1,380 total issues

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

    matchers.toBeOddNumber = function() {
        return matchers.toBeNumber.call(this) && this.actual % 2 !== 0;
    };
Severity: Minor
Found in legacy/spec/lib/jasmine-matchers.js and 1 other location - About 50 mins to fix
legacy/spec/lib/jasmine-matchers.js on lines 415..417

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

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

    matchers.toBeNonEmptyArray = function() {
        return matchers.toBeArray.call(this) && this.actual.length > 0;
    };
Severity: Minor
Found in legacy/spec/lib/jasmine-matchers.js and 1 other location - About 50 mins to fix
legacy/spec/lib/jasmine-matchers.js on lines 513..515

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

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

                                            m('textarea.text-field.height-medium.positive.u-marginbottom-60.w-input', {
                                                value: state.currentReward().welcome_message_body(),
                                                onchange: m.withAttr('value', state.currentReward().welcome_message_body)
                                            }),
Severity: Minor
Found in legacy/src/root/project-edit-welcome.js and 1 other location - About 50 mins to fix
legacy/src/root/project-edit-welcome.js on lines 139..142

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

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

jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
  beforeEachFunction.typeName = 'beforeEach';
  this.before_.unshift(beforeEachFunction);
};
Severity: Minor
Found in legacy/spec/lib/jasmine/jasmine.js and 1 other location - About 50 mins to fix
legacy/spec/lib/jasmine/jasmine.js on lines 2129..2132

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

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

        const saveRequestConfig = {
            method: 'PUT',
            url: `/users/${this.user_id}.json`,
            data: {
                user: userAttributes
Severity: Minor
Found in legacy/src/vms/user-info-edit-vm.ts and 1 other location - About 50 mins to fix
legacy/src/vms/project-publish-by-steps-vm.ts on lines 196..201

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

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

        const requestOptions = {
            method: 'PUT',
            url: `/projects/${this.project_id}.json`,
            data: { project: projectDataToSave },
            config: h.setCsrfToken,
Severity: Minor
Found in legacy/src/vms/project-publish-by-steps-vm.ts and 1 other location - About 50 mins to fix
legacy/src/vms/user-info-edit-vm.ts on lines 172..179

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

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

    oninit: function(vnode) {
        const userDetails = prop(vnode.attrs.user_details || {}),
            user_id = vnode.attrs.user_id.split('-')[0],
            hash = prop(window.location.hash),
            displayTabContent = (user) => {
Severity: Minor
Found in legacy/src/root/users-show.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 view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    view: function({state, attrs}) {
        const user = state.userDetails();

        return m('.w-dropdown.user-profile',
            [
Severity: Minor
Found in legacy/src/c/menu-profile.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 oninit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    oninit: function(vnode) {
        h.analytics.windowScroll({ cat: 'project_start', act: 'start_page_scroll' });
        const stats = prop([]),
            categories = prop([]),
            selectedPane = prop(0),
Severity: Minor
Found in legacy/src/root/start.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 view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    view: function({state, attrs}) {
        const collection = attrs.collection,
            isSubscription = attrs.isSubscription,
            pagination = attrs.pagination,
            hideSurveys = state.hideSurveys,
Severity: Minor
Found in legacy/src/c/user-contributed-list.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 view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    view: function({ state }) {
        const subscription = state.subscription,
            project = subscription.project;

        return !_.isEmpty(subscription) && !_.isEmpty(subscription.project)
Severity: Minor
Found in legacy/src/c/user-subscription-box.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

Avoid deeply nested control flow statements.
Open

                if (subscription.payment_status !== 'pending') {
                    const editHref = `/projects/${subscription.project_external_id}/subscriptions/start?${subscription.reward_external_id ? `reward_id=${subscription.reward_external_id}` : ''}&subscription_id=${subscription.id}&subscription_status=${subscription.status}`;
                    return [
                        showLastSubscriptionVersionEditionNextCharge(),
                        m('a.btn.btn-terciary.btn-inline.w-button', {
Severity: Major
Found in legacy/src/c/user-subscription-box-control.js - About 45 mins to fix

    Function oninit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        oninit: function(vnode) {
            let interval;
            const selectedSlideIdx = prop(0),
                translationSize = prop(1600),
                sliderTime = vnode.attrs.sliderTime || 6500,
    Severity: Minor
    Found in legacy/src/c/slider.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 requestInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const requestInfo = (promise, paymentId, defaultPaymentMethod, isEdit) => {
        if (retries <= 0) {
            return promise.resolve(resolvePayment(defaultPaymentMethod, false, paymentId, isEdit));
        }
    
    
    Severity: Minor
    Found in legacy/src/vms/common-payment-vm.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 sendSlipPayment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const sendSlipPayment = (fields, commonData) => {
        fields.isLoading(true);
        m.redraw();
    
        const customer = fields.fields;
    Severity: Minor
    Found in legacy/src/vms/common-payment-vm.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 set has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      var monster={set:function(name,value,days,path,secure,domain){var date=new Date(),expires='',type=typeof(value),valueToUse='',secureFlag='';path=path||"/";if(days){date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toUTCString();}if(type==="object"&&type!=="undefined"){if(!("JSON"in window))throw"Bummer, your browser doesn't support JSON parsing.";valueToUse=encodeURIComponent(JSON.stringify({v:value}));}else{valueToUse=encodeURIComponent(value);}if(secure){secureFlag="; secure";}domain=domain?"; domain="+encodeURIComponent(domain):"";document.cookie=name+"="+valueToUse+expires+"; path="+path+secureFlag+domain;},get:function(name){var nameEQ=name+"=",ca=document.cookie.split(';'),value='',firstChar='',parsed={};for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)===0){value=decodeURIComponent(c.substring(nameEQ.length,c.length));firstChar=value.substring(0,1);if(firstChar=="{"){try{parsed=JSON.parse(value);if("v"in parsed)return parsed.v;}catch(e){return value;}}if(value=="undefined")return undefined;return value;}}return null;},remove:function(name){this.set(name,"",-1);},increment:function(name,days){var value=this.get(name)||0;this.set(name,(parseInt(value,10)+1),days);},decrement:function(name,days){var value=this.get(name)||0;this.set(name,(parseInt(value,10)-1),days);}};
    Severity: Minor
    Found in legacy/spec/lib/analytics.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (i > 0) message += ",";
      Severity: Major
      Found in legacy/spec/lib/jasmine/jasmine.js - About 45 mins to fix

        Function addResult has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        jasmine.NestedResults.prototype.addResult = function(result) {
          if (result.type != 'log') {
            if (result.items_) {
              this.rollupCounts(result);
            } else {
        Severity: Minor
        Found in legacy/spec/lib/jasmine/jasmine.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 XmlHttpRequest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
          try {
            return new ActiveXObject("Msxml2.XMLHTTP.6.0");
          } catch(e) {
          }
        Severity: Minor
        Found in legacy/spec/lib/jasmine/jasmine.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 _checkout has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          function _checkout(transactionId, prodName, sku, category, price, fee) {
        Severity: Minor
        Found in legacy/spec/lib/analytics.js - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language