catarse/catarse.js

View on GitHub

Showing 1,380 of 1,380 total issues

Function oninit has 131 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    oninit: function(vnode) {
        const {
                survey_id
            } = vnode.attrs,
            contributionId = m.route.param('contribution_id'),
Severity: Major
Found in legacy/src/root/surveys-show.js - About 5 hrs to fix

    Function addressVM has 131 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const addressVM = (args) => {
        const data = args.data;
        const international = prop();
        const statesLoader = catarse.loader(models.state.getPageOptions());
    
    
    Severity: Major
    Found in legacy/src/vms/address-vm.js - About 5 hrs to fix

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

          view({ attrs, state } : m.Vnode<UserInfoEditPublicProfileAttrs, UserInfoEditPublicProfileState>) {
              const user = attrs.user
              const hasErrorOn = attrs.hasErrorOn
              const getErrorsOn = attrs.getErrorsOn
              const onSelectProfileImage = attrs.onSelectProfileImage

        File project-basics-edit.js has 384 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/project-basics-edit.js - About 5 hrs to fix

          File payment-vm.js has 384 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import m from 'mithril';
          import prop from 'mithril/stream';
          import _ from 'underscore';
          import moment, { defaultFormat } from 'moment';
          import h from '../h';
          Severity: Minor
          Found in legacy/src/vms/payment-vm.js - About 5 hrs to fix

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

                view({ attrs, state } : m.Vnode<ShareAttrs, ShareState>) {
                    
                    const project = attrs.project
                    const projectUrl = `${window.location.origin}/${project.permalink}`
                    const copyToClipboard = (copyText : HTMLInputElement) => {
            Severity: Major
            Found in legacy/src/root/projects/publish-by-steps/share.tsx - About 5 hrs to fix

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

              const getUserContributedProjectsWithFilter = () => {
                  const contributions = catarse.paginationVM(models.project, 'created_at.desc', { Prefer: 'count=exact' });
              
                  return {
                      firstPage: params => contributions.firstPage(params).then(() => h.redraw()),
              Severity: Major
              Found in legacy/src/vms/contribution-vm.js and 1 other location - About 5 hrs to fix
              legacy/src/vms/contribution-vm.js on lines 63..73

              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

              const getUserContributionsListWithFilter = () => {
                  const contributions = catarse.paginationVM(models.userContribution, 'created_at.desc', { Prefer: 'count=exact' });
              
                  return {
                      firstPage: params => contributions.firstPage(params).then(() => h.redraw()),
              Severity: Major
              Found in legacy/src/vms/contribution-vm.js and 1 other location - About 5 hrs to fix
              legacy/src/vms/contribution-vm.js on lines 75..85

              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

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

                  view: function({state, attrs}) {
                      const list = state.listVM,
                          project = attrs.project() || {},
                          postHeader = (post) => _.map(post.rewards_that_can_access_post, r => ` R$${h.formatNumber(r.minimum_value)}${r.title ? ` - ${r.title}` : ''}`),
                          postTextSubscription = (post) => `Post exclusivo para assinantes${ post.rewards_that_can_access_post ? ' de' : ''}${postHeader(post)}`,
              Severity: Minor
              Found in legacy/src/c/project-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 view has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                  view: function({state, attrs}) {
                      const contribution = attrs.contribution(),
                          project = attrs.project(),
                          survey = _.first(state.survey()),
                          profileImg = (_.isEmpty(contribution.profile_img_thumbnail) ? '/assets/catarse_bootstrap/user.jpg' : contribution.profile_img_thumbnail),
              Severity: Minor
              Found in legacy/src/c/project-contribution-report-content-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 publish-vm.js has 378 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import m from 'mithril';
              import h from '../h';
              
              const formattedServiceFee = (project) => (project.service_fee * 100).toFixed(2).replace(/(\.|,)?0+$/g, '');
              
              
              Severity: Minor
              Found in legacy/src/vms/publish-vm.js - About 5 hrs to fix

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

                            }, { // state
                                component: filterDropdown,
                                data: {
                                    label: 'Com o estado',
                                    name: 'state',
                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 27..59

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

                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

                            }, { // state
                                component: filterDropdown,
                                data: {
                                    label: 'Com o estado',
                                    name: 'status',
                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 53..85

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

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

                    view({ attrs, state } : m.Vnode<CardEditAttrs, CardEditState>) {
                        
                        const project = attrs.project
                        const isSaving = attrs.isSaving
                        const save = attrs.save
                Severity: Major
                Found in legacy/src/root/projects/publish-by-steps/card-edit.tsx - About 4 hrs to fix

                  Function oninit has 123 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      oninit({ attrs, state }: m.Vnode<RewardsEditListAttrs, RewardsEditListState>) {
                          const rewards = prop<StreamType<RewardDetailsStream>[]>([])
                          const loading = attrs.loading
                          const error = attrs.error
                          const errors = attrs.errors
                  Severity: Major
                  Found in legacy/src/c/projects/edit/rewards-edit-list.tsx - About 4 hrs to fix

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

                        view: function ({
                            state,
                            attrs
                        }) {
                            const reward = attrs.reward();
                    Severity: Minor
                    Found in legacy/src/c/dashboard-reward-card.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

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

                        view: function({state, attrs}) {
                            // @TODO: remove all those things from the view
                            const project = attrs.project,
                                elapsed = project().elapsed_time,
                                remaining = project().remaining_time,
                    Severity: Minor
                    Found in legacy/src/c/project-sidebar.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 2 locations. Consider refactoring.
                    Open

                                            m('.w-row', [
                                                m('.w-col.w-col-12.u-text-center', {
                                                    style: {
                                                        'min-height': '300px'
                                                    }
                    Severity: Major
                    Found in legacy/src/c/project-insights.js and 1 other location - About 4 hrs to fix
                    legacy/src/c/project-insights.js on lines 251..265

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

                    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(
                                                                '.fontsize-smallest.reward-description.opened.fontcolor-secondary',
                                                                {
                                                                    class: state.isLongDescription(state.reward()) ? (state.toggleDescription() ? 'extended' : '') : 'extended',
                                                                },
                    Severity: Major
                    Found in legacy/src/root/projects-payment.js and 1 other location - About 4 hrs to fix
                    legacy/src/root/projects-subscription-checkout.js on lines 429..443

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

                    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('.fontsize-smallest.reward-description.opened.fontcolor-secondary', {
                                                        class: state.isLongDescription(state.reward()) ?
                                                                state.toggleDescription() ? 'extended' : '' : 'extended'
                                                    }, state.reward().description ?
                                                        state.reward().description :
                    Severity: Major
                    Found in legacy/src/root/projects-subscription-checkout.js and 1 other location - About 4 hrs to fix
                    legacy/src/root/projects-payment.js on lines 394..411

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

                    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