catarse/catarse.js

View on GitHub

Showing 1,380 of 1,380 total issues

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

            if (subscription.last_payment_data.status === 'refused') {
                return [
                    m('.card-alert.u-radius.fontsize-smaller.u-marginbottom-10.fontweight-semibold',
                        m('div', [
                            m('span.fa.fa-exclamation-triangle', '.'),
Severity: Major
Found in legacy/src/c/user-subscription-box-control.js and 1 other location - About 5 hrs to fix
legacy/src/c/user-subscription-box-control.js on lines 20..87

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

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

    view: function({state}) {
        const contribution = state.contribution,
            contactModalC = [ownerMessageContent, {
                id: contribution.project_user_id,
                name: contribution.project_owner_name,
Severity: Minor
Found in legacy/src/c/user-contributed-box.js - About 5 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 oninit has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    oninit: function(vnode) {
        const project = projectVM.getCurrentProject(),
            reward = vnode.attrs.reward(),
            imageFileToUpload = prop(null),
            minimumValue = projectVM.isSubscription(project) ? 5 : 10,
Severity: Minor
Found in legacy/src/c/edit-reward-card.js - About 5 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

File posts.js has 412 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import m from 'mithril';
import prop from 'mithril/stream';
import { catarse } from '../api';
import _ from 'underscore';
import h from '../h';
Severity: Minor
Found in legacy/src/root/posts.js - About 5 hrs to fix

    File user-billing.js has 409 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import m from 'mithril';
    import prop from 'mithril/stream';
    import _ from 'underscore';
    import { catarse } from '../api';
    import models from '../models';
    Severity: Minor
    Found in legacy/src/c/user-billing.js - About 5 hrs to fix

      Function wrap has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

      export function wrap(component, customAttr) {
          if (!app) {
              app = document.getElementById('application');
          }
      
      
      Severity: Minor
      Found in legacy/src/wrap.js - About 5 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 oninit has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          oninit: function(vnode) {
              const MINIMUM_VALUE = 10;
              const queryRewardValue = h.getParams('value');
              const setInput = localVnode => localVnode.dom.focus();
              const isSelected = currentReward => (currentReward.id == null && !rewardVM.selectedReward() && queryRewardValue) || (rewardVM.selectedReward() && currentReward.id === rewardVM.selectedReward().id);
      Severity: Minor
      Found in legacy/src/c/reward-select-card.js - About 5 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 oninit has 142 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          oninit: function(vnode) {
              models.bank.pageSize(false);
              const user = vnode.attrs.user,
                  bankAccount = prop({}),
                  fields = {
      Severity: Major
      Found in legacy/src/c/user-billing.js - About 5 hrs to fix

        Function view has 142 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            view({state, attrs}) {
                
                const projectsExploreVM : ProjectsExploreViewModel = state.projectsExploreVM;
                const projectsCollection = projectsExploreVM.projectsView.collection();
                const isContributedByFriendsFilter = projectsExploreVM.filter === 'contributed_by_friends';
        Severity: Major
        Found in legacy/src/root/projects-explore.ts - About 5 hrs to fix

          ProjectsExploreViewModel has 42 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class ProjectsExploreViewModel {
          
              private _observer : Observer<Query>;
              private _categories : Category[];
              private _mode : Mode;
          Severity: Minor
          Found in legacy/src/vms/projects-explore-vm.ts - About 5 hrs to fix

            Function view has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
            Open

                view: function({state}) {
                    
                    const project = _.first(state.projectDetails()),
                        isSubscription = projectVM.isSubscription(project),
                        recipients = state.fields.recipients;
            Severity: Minor
            Found in legacy/src/root/posts.js - About 5 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 oninit has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
            Open

                oninit: function(vnode) {
                    const vm = vnode.attrs.vm,
                        isSubscriptionEdit = vnode.attrs.isSubscriptionEdit || prop(false),
                        subscriptionEditConfirmed = prop(false),
                        showSubscriptionModal = prop(false),
            Severity: Minor
            Found in legacy/src/c/payment-credit-card.js - About 5 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

            File mithril-query.js has 395 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            'use strict'
            
            const m = require('mithril/render/hyperscript')
            const cssauron = require('cssauron')
            const code = require('yields-keycode')
            Severity: Minor
            Found in legacy/spec/lib/mithril-query/mithril-query.js - About 5 hrs to fix

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

                          processChargebacks = () => {
                              if (generateIdsToData() !== null && generateIdsToData().length >= 0) {
                                  processChargebacksLoader(true);
                                  m.redraw();
                                  m.request({
              Severity: Major
              Found in legacy/src/root/admin-subscriptions.js and 1 other location - About 5 hrs to fix
              legacy/src/root/admin-contributions.js on lines 213..231

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

              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

                          processChargebacks = () => {
                              if (generateIdsToData() != null && generateIdsToData().length >= 0) {
                                  processChargebacksLoader(true);
                                  m.redraw();
                                  m.request({
              Severity: Major
              Found in legacy/src/root/admin-contributions.js and 1 other location - About 5 hrs to fix
              legacy/src/root/admin-subscriptions.js on lines 150..168

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

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

                  view: function({state, attrs}) {
                      const isInternational = state.vm.isInternational();
              
                      return m('.w-form.u-marginbottom-40', {
                          oncreate: state.loadPagarme
              Severity: Minor
              Found in legacy/src/c/payment-credit-card.js - About 5 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 oninit has 132 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  oninit: function(vnode) {
                      let parsedErrors = userSettingsVM.mapRailsErrors(railsErrorsVM.railsErrors());
                      let deleteFormSubmit;
                      const user = vnode.attrs.user();
                      const userAddress = user.address || {};
              Severity: Major
              Found in legacy/src/c/user-settings.js - About 5 hrs to fix

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

                    oninit: function (vnode) {
                        const reward = vnode.attrs.reward(),
                            imageFileToUpload = prop(null),
                            isUploadingRewardImage = prop(false),
                            isDeletingRewardImage = prop(false),
                Severity: Minor
                Found in legacy/src/c/dashboard-reward-card.js - About 5 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 2 locations. Consider refactoring.
                Open

                const getUserSubscribedProjects = (user_external_id, pageSize = 3) => {
                    const contextVM = commonPayment.filtersVM({
                        user_external_id: 'eq',
                        status: 'in',
                    });
                Severity: Major
                Found in legacy/src/vms/user-vm.js and 1 other location - About 5 hrs to fix
                legacy/src/vms/user-vm.js on lines 121..139

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

                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 getUserContributedProjects = (user_id, pageSize = 3) => {
                    const contextVM = catarse.filtersVM({
                        user_id: 'eq',
                        state: 'in',
                    });
                Severity: Major
                Found in legacy/src/vms/user-vm.js and 1 other location - About 5 hrs to fix
                legacy/src/vms/user-vm.js on lines 141..159

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

                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