TryGhost/Ghost

View on GitHub
apps/portal/src/components/pages/SignupPage.js

Summary

Maintainability
F
6 days
Test Coverage

File SignupPage.js has 717 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';
import ActionButton from '../common/ActionButton';
import AppContext from '../../AppContext';
import CloseButton from '../common/CloseButton';
import SiteTitleBackButton from '../common/SiteTitleBackButton';
Severity: Major
Found in apps/portal/src/components/pages/SignupPage.js - About 1 day to fix

    Function renderForm has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        renderForm() {
            const fields = this.getInputFields({state: this.state});
            const {site, pageQuery, t} = this.context;
    
            if (this.state.showNewsletterSelection) {
    Severity: Major
    Found in apps/portal/src/components/pages/SignupPage.js - About 3 hrs to fix

      SignupPage has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class SignupPage extends React.Component {
          static contextType = AppContext;
      
          constructor(props) {
              super(props);
      Severity: Minor
      Found in apps/portal/src/components/pages/SignupPage.js - About 2 hrs to fix

        Function getClassNames has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            getClassNames() {
                const {site, pageQuery} = this.context;
                const plansData = getSitePrices({site, pageQuery});
                const fields = this.getInputFields({state: this.state});
                let sectionClass = '';
        Severity: Minor
        Found in apps/portal/src/components/pages/SignupPage.js - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function renderSubmitButton has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            renderSubmitButton() {
                const {action, site, brandColor, pageQuery, t} = this.context;
        
                if (isInviteOnlySite({site, pageQuery})) {
                    return null;
        Severity: Minor
        Found in apps/portal/src/components/pages/SignupPage.js - About 1 hr to fix

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

              getInputFields({state, fieldNames}) {
                  const {site: {portal_name: portalName}, t} = this.context;
          
                  const errors = state.errors || {};
                  const fields = [
          Severity: Minor
          Found in apps/portal/src/components/pages/SignupPage.js - About 1 hr to fix

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

                renderSignupTerms() {
                    const {site} = this.context;
            
                    if (site.portal_signup_terms_html === null || site.portal_signup_terms_html === '') {
                        return null;
            Severity: Minor
            Found in apps/portal/src/components/pages/SignupPage.js - About 1 hr to fix

              Function renderForm has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  renderForm() {
                      const fields = this.getInputFields({state: this.state});
                      const {site, pageQuery, t} = this.context;
              
                      if (this.state.showNewsletterSelection) {
              Severity: Minor
              Found in apps/portal/src/components/pages/SignupPage.js - About 1 hr to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function renderSubmitButton has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  renderSubmitButton() {
                      const {action, site, brandColor, pageQuery, t} = this.context;
              
                      if (isInviteOnlySite({site, pageQuery})) {
                          return null;
              Severity: Minor
              Found in apps/portal/src/components/pages/SignupPage.js - About 25 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

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

                  renderSignupTerms() {
                      const {site} = this.context;
              
                      if (site.portal_signup_terms_html === null || site.portal_signup_terms_html === '') {
                          return null;
              Severity: Major
              Found in apps/portal/src/components/pages/SignupPage.js and 1 other location - About 1 day to fix
              apps/portal/src/components/pages/OfferPage.js on lines 222..262

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

              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

                  getFormErrors(state) {
                      const checkboxRequired = this.context.site.portal_signup_checkbox_required && this.context.site.portal_signup_terms_html;
                      const checkboxError = checkboxRequired && !state.termsCheckboxChecked;
              
                      return {
              Severity: Major
              Found in apps/portal/src/components/pages/SignupPage.js and 1 other location - About 3 hrs to fix
              apps/portal/src/components/pages/OfferPage.js on lines 164..172

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

              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

                      if (!isSignupAllowed({site})) {
                          return (
                              <section>
                                  <div className='gh-portal-section'>
                                      <p
              Severity: Major
              Found in apps/portal/src/components/pages/SignupPage.js and 1 other location - About 2 hrs to fix
              apps/portal/src/components/pages/SigninPage.js on lines 123..136

              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

                                  <div className='gh-portal-logged-out-form-container'>
                                      <InputForm
                                          fields={fields}
                                          onChange={(e, field) => this.handleInputChange(e, field)}
                                          onKeyDown={e => this.onKeyDown(e)}
              Severity: Major
              Found in apps/portal/src/components/pages/SignupPage.js and 1 other location - About 1 hr to fix
              apps/portal/src/components/pages/OfferPage.js on lines 361..367

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

              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

                      if (this.state.showNewsletterSelection) {
                          return (
                              <NewsletterSelectionPage
                                  pageData={this.state.pageData}
                                  onBack={() => {
              Severity: Major
              Found in apps/portal/src/components/pages/SignupPage.js and 1 other location - About 1 hr to fix
              apps/portal/src/components/pages/OfferPage.js on lines 346..357

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

              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.unshift({
                              type: 'text',
                              value: state.name,
                              placeholder: 'Jamie Larson',
                              label: t('Name'),
              Severity: Major
              Found in apps/portal/src/components/pages/SignupPage.js and 1 other location - About 1 hr to fix
              apps/portal/src/components/pages/SignupPage.js on lines 478..487

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

              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

                          {
                              type: 'email',
                              value: state.email,
                              placeholder: 'jamie@example.com',
                              label: t('Email'),
              Severity: Major
              Found in apps/portal/src/components/pages/SignupPage.js and 1 other location - About 1 hr to fix
              apps/portal/src/components/pages/SignupPage.js on lines 492..501

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

              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

                  handleInputChange(e, field) {
                      const fieldName = field.name;
                      const value = e.target.value;
                      this.setState({
                          [fieldName]: value
              Severity: Minor
              Found in apps/portal/src/components/pages/SignupPage.js and 1 other location - About 55 mins to fix
              apps/portal/src/components/pages/OfferPage.js on lines 308..314

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

              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 3 locations. Consider refactoring.
              Open

                      if (fieldNames && fieldNames.length > 0) {
                          return fields.filter((f) => {
                              return fieldNames.includes(f.name);
                          });
                      }
              Severity: Major
              Found in apps/portal/src/components/pages/SignupPage.js and 2 other locations - About 50 mins to fix
              apps/portal/src/components/pages/AccountProfilePage.js on lines 160..164
              apps/portal/src/components/pages/OfferPage.js on lines 214..218

              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

                      this.timeoutId = setTimeout(() => {
                          this.setState(() => {
                              return {
                                  plan: priceId
                              };
              Severity: Minor
              Found in apps/portal/src/components/pages/SignupPage.js and 1 other location - About 40 mins to fix
              apps/portal/src/components/pages/AccountPlanPage.js on lines 401..407

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

              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

              There are no issues that match your filters.

              Category
              Status