SumOfUs/Champaign

View on GitHub

Showing 338 of 338 total issues

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

  handleSendEmail = () => {
    const emailParam = {
      emailService: this.state.emailService,
      toEmails: this.composeTargetAddress(),
      subject: this.props.emailSubject,
Severity: Major
Found in app/javascript/plugins/email_pension/EmailPensionView.js and 1 other location - About 2 hrs to fix
app/javascript/plugins/email_tool/EmailToolView.js on lines 140..148

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

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

        <div className="Thermometer-raised">
          <FormattedMessage
            className="Thermometer-stats-label"
            id="fundraiser.thermometer.raised"
            defaultMessage="Raised"
Severity: Major
Found in app/javascript/components/Thermometer.js and 1 other location - About 2 hrs to fix
app/javascript/components/Thermometer.js on lines 38..48

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

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

  render() {
    return (
      <div className="AmountSelection-container section">
        <Thermometer />
        <DonationBands
Severity: Major
Found in app/javascript/components/AmountSelection/AmountSelection.js - About 2 hrs to fix

    Function rtl has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        rtl: function(context) {
          var self = this;
          var selection;
          // ui has renders to build ui elements.
          //  - you can create a button with `ui.button`
    Severity: Major
    Found in app/javascript/packs/summernote-rtl-plugin.js - About 2 hrs to fix

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

              <FormGroup>
                <SweetInput
                  label="Full name"
                  name="fullName"
                  type="text"
      Severity: Major
      Found in app/javascript/modules/EmailParliament/EmailComposer.js and 1 other location - About 2 hrs to fix
      app/javascript/modules/EmailParliament/EmailComposer.js on lines 189..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 86.

      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

              <FormGroup>
                <SweetInput
                  label="email"
                  name="email"
                  type="email"
      Severity: Major
      Found in app/javascript/modules/EmailParliament/EmailComposer.js and 1 other location - About 2 hrs to fix
      app/javascript/modules/EmailParliament/EmailComposer.js on lines 176..188

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

      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

      Fundraiser has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class Fundraiser extends Plugin<IFundraiserPluginConfig> {
        public store: Store<IAppState>;
        public customRenderer: (instance: Fundraiser) => any | undefined;
      
        constructor(options: IPluginOptions<IFundraiserPluginConfig>) {
      Severity: Minor
      Found in app/javascript/plugins/fundraiser/index.tsx - About 2 hrs to fix

        Function ltr has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            ltr: function(context) {
              var self = this;
              // ui has renders to build ui elements.
              var ui = $.summernote.ui;
              context.memo('button.ltr', function() {
        Severity: Major
        Found in app/javascript/packs/summernote-rtl-plugin.js - About 2 hrs to fix

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

            render() {
              const errorMessage = this.state.newPensionFundNameError ? (
                <FormattedMessage
                  id="email_tool.form.errors.suggest_fund"
                  defaultMessage="Name of pension fund can't be blank"
          Severity: Major
          Found in app/javascript/plugins/email_pension/SuggestFund.js - About 2 hrs to fix

            Function render has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              render() {
                const { restrictedCountryCode } = this.props;
                const className = classnames(
                  {
                    SweetPhoneInput__root: true,
            Severity: Major
            Found in app/javascript/components/SweetPhoneInput/SweetPhoneInput.js - About 2 hrs to fix

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

                  fields.forEach(field => {
                    if (isEmpty(this.props[field])) {
                      const location = `email_tool.form.errors.${field}`;
                      const message = <FormattedMessage id={location} />;
                      errors[field] = message;
              Severity: Major
              Found in app/javascript/plugins/email_pension/EmailPensionView.js and 1 other location - About 2 hrs to fix
              app/javascript/plugins/email_pension/EmailRepresentativeView.js on lines 50..56

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

              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

                  fields.forEach(field => {
                    if (isEmpty(this.state[field])) {
                      const location = `email_tool.form.errors.${field}`;
                      const message = <FormattedMessage id={location} />;
                      errors[field] = message;
              app/javascript/plugins/email_pension/EmailPensionView.js on lines 77..83

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

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

                render() {
                  let targets;
              
                  if (this.state.not_found) {
                    targets = (
              Severity: Major
              Found in app/javascript/plugins/email_pension/SelectTarget.js - About 2 hrs to fix

                Function createHostedFields has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  createHostedFields(client) {
                    Promise.all([
                      braintree.threeDSecure.create(
                        {
                          client: client,
                Severity: Major
                Found in app/javascript/components/Braintree/BraintreeCardFields.js - About 2 hrs to fix

                  Function render has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    render() {
                      const { header, footer, errors } = this.props;
                  
                      const hasHeaderValue = this.hasValue(header);
                      const hasFooterValue = this.hasValue(footer);
                  Severity: Major
                  Found in app/javascript/components/EmailEditor/EmailEditor.js - About 2 hrs to fix

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

                      ensureCopyableChoiceField() {
                        if (this.$copyableChoiceField === undefined) {
                          this.$copyableChoiceField = this.$('.form-element__choice-field')
                            .first()
                            .clone();
                    Severity: Major
                    Found in app/javascript/legacy/campaigner_facing/list_editor.js and 1 other location - About 2 hrs to fix
                    app/javascript/legacy/campaigner_facing/form_element_creator.js on lines 133..140

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

                    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

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

                      ensureCopyableChoiceField() {
                        if (this.$copyableChoiceField === undefined) {
                          this.$copyableChoiceField = this.$('.form-element__choice-field')
                            .first()
                            .clone();
                    app/javascript/legacy/campaigner_facing/list_editor.js on lines 11..18

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

                    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

                      test(`checkbox => <Checkbox .../>`, () => {
                        const wrapper = shallow(<FieldShape field={{...field, data_type: 'checkbox'}} />);
                        expect(wrapper.find('Checkbox').length).toEqual(1);
                      });
                    Severity: Major
                    Found in app/javascript/components/FieldShape/FieldShape.test.js and 1 other location - About 2 hrs to fix
                    app/javascript/components/FieldShape/FieldShape.test.js on lines 73..76

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

                    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

                      test(`paragraph => <textarea>`, () => {
                        const wrapper = shallow(<FieldShape field={{...field, data_type: 'paragraph'}} />);
                        expect(wrapper.find('textarea').length).toEqual(1);
                      });
                    Severity: Major
                    Found in app/javascript/components/FieldShape/FieldShape.test.js and 1 other location - About 2 hrs to fix
                    app/javascript/components/FieldShape/FieldShape.test.js on lines 78..81

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

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

                      handleSuccess(e, data) {
                        ee.emit('petition:submitted');
                    
                        const tracking = data.tracking;
                        const member = window.champaign.personalization.member;
                    Severity: Minor
                    Found in app/javascript/legacy/member-facing/backbone/petition.js - About 2 hrs to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Severity
                    Category
                    Status
                    Source
                    Language