onejgordon/flow-dashboard

View on GitHub
src/js/components/Integrations.js

Summary

Maintainability
F
3 days
Test Coverage

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

    render() {
        let {form} = this.state;
        let {user} = this.props;
        if (!user) return <div></div>;
        let gr_user_id, gh_user, gh_pat, en_notebook_ids, evernote_connected, en_evernote_max_quote_length;
Severity: Major
Found in src/js/components/Integrations.js - About 4 hrs to fix

    File Integrations.js has 322 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var React = require('react');
    
    var util = require('utils/util');
    var UserStore = require('stores/UserStore');
    var UserActions = require('actions/UserActions');
    Severity: Minor
    Found in src/js/components/Integrations.js - About 3 hrs to fix

      Integrations has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      @connectToStores
      @changeHandler
      export default class Integrations extends React.Component {
          static defaultProps = {};
          constructor(props) {
      Severity: Minor
      Found in src/js/components/Integrations.js - About 2 hrs to fix

        Function render_admin_section has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            render_admin_section() {
                let {form} = this.state;
                let {user} = this.props;
                let bigquery_dataset_name = null, bigquery_table_name = null;
                if (user && user.integrations) {
        Severity: Minor
        Found in src/js/components/Integrations.js - About 1 hr to fix

          Function render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              render() {
                  let {form} = this.state;
                  let {user} = this.props;
                  if (!user) return <div></div>;
                  let gr_user_id, gh_user, gh_pat, en_notebook_ids, evernote_connected, en_evernote_max_quote_length;
          Severity: Minor
          Found in src/js/components/Integrations.js - About 35 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

          XXX found
          Open

                                          For example, if part of the URL looks like this <code>#b=XXX-XX-XXXXX&ses=4&sh=1</code>, the notebook ID is <code>XXX-XX-XXXXX</code>.
          Severity: Minor
          Found in src/js/components/Integrations.js by fixme

          XXX found
          Open

                                          For example, if part of the URL looks like this <code>#b=XXX-XX-XXXXX&ses=4&sh=1</code>, the notebook ID is <code>XXX-XX-XXXXX</code>.
          Severity: Minor
          Found in src/js/components/Integrations.js by fixme

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

              start_evernote_authentication() {
                  this.setState({snack_message: "Evernote connecting...", snack_open: true})
                  api.post("/api/integrations/evernote/authenticate", {}, (res) => {
                      if (res.redirect) window.location = res.redirect;
                  });
          Severity: Major
          Found in src/js/components/Integrations.js and 1 other location - About 2 hrs to fix
          src/js/components/Integrations.js on lines 56..61

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

          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

              start_pocket_authentication() {
                  this.setState({snack_message: "Pocket connecting...", snack_open: true})
                  api.post("/api/integrations/pocket/authenticate", {}, (res) => {
                      if (res.redirect) window.location = res.redirect;
                  });
          Severity: Major
          Found in src/js/components/Integrations.js and 1 other location - About 2 hrs to fix
          src/js/components/Integrations.js on lines 85..90

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

          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

              disconnect_pocket() {
                  this.setState({snack_message: "Disconnecting from Pocket...", snack_open: true})
                  api.post("/api/integrations/pocket/disconnect", {}, (res) => {
                      if (res.user) {
                          UserActions.storeUser(res.user);
          Severity: Major
          Found in src/js/components/Integrations.js and 1 other location - About 1 hr to fix
          src/js/components/Integrations.js on lines 104..111

          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

              disconnect_evernote() {
                  this.setState({snack_message: "Disconnecting from Evernote...", snack_open: true})
                  api.post("/api/integrations/evernote/disconnect", {}, (res) => {
                      if (res.user) {
                          UserActions.storeUser(res.user);
          Severity: Major
          Found in src/js/components/Integrations.js and 1 other location - About 1 hr to fix
          src/js/components/Integrations.js on lines 74..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 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

                  api.post("/api/integrations/evernote/authorize", params, (res) => {
                      if (res.user) {
                          UserActions.storeUser(res.user);
                          this.setState({snack_message: "Evernote connected!", snack_open: true})
                          browserHistory.push('/app/integrations');
          Severity: Major
          Found in src/js/components/Integrations.js and 1 other location - About 1 hr to fix
          src/js/components/Integrations.js on lines 65..71

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

          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

                  api.post("/api/integrations/pocket/authorize", {}, (res) => {
                      if (res.user) {
                          UserActions.storeUser(res.user);
                          this.setState({snack_message: "Pocket connected!", snack_open: true})
                          browserHistory.push('/app/integrations');
          Severity: Major
          Found in src/js/components/Integrations.js and 1 other location - About 1 hr to fix
          src/js/components/Integrations.js on lines 95..101

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

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

                                  <TextField name="gh_username" placeholder="Github User ID" value={form.github_username||''} onChange={this.changeHandler.bind(this, 'form', 'github_username')} /><br/>
          Severity: Major
          Found in src/js/components/Integrations.js and 3 other locations - About 55 mins to fix
          src/js/components/Integrations.js on lines 345..345
          src/js/components/Integrations.js on lines 357..357
          src/js/components/common/FetchedList.js on lines 186..189

          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

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

                                  <TextField name="user_id" placeholder="Goodreads User ID (e.g. 2901234)" value={form.goodreads_user_id || ''} onChange={this.changeHandler.bind(this, 'form', 'goodreads_user_id')} /><br/>
          Severity: Major
          Found in src/js/components/Integrations.js and 3 other locations - About 55 mins to fix
          src/js/components/Integrations.js on lines 356..356
          src/js/components/Integrations.js on lines 357..357
          src/js/components/common/FetchedList.js on lines 186..189

          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

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

                                  <TextField name="gh_pat" placeholder="Github Personal Access Token (PAT)" value={form.github_pat||''} onChange={this.changeHandler.bind(this, 'form', 'github_pat')} /><br/>
          Severity: Major
          Found in src/js/components/Integrations.js and 3 other locations - About 55 mins to fix
          src/js/components/Integrations.js on lines 345..345
          src/js/components/Integrations.js on lines 356..356
          src/js/components/common/FetchedList.js on lines 186..189

          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

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

                                      <TextField name="bq_dataset_name" placeholder="BigQuery dataset name" value={form.bigquery_dataset_name} onChange={this.changeHandler.bind(this, 'form', 'bigquery_dataset_name')} fullWidth /><br/>
          Severity: Major
          Found in src/js/components/Integrations.js and 2 other locations - About 50 mins to fix
          src/js/components/Integrations.js on lines 233..233
          src/js/components/ProjectViewer.js on lines 199..199

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

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

                                      <TextField name="bq_table_name" placeholder="BigQuery dataset name" value={form.bigquery_table_name} onChange={this.changeHandler.bind(this, 'form', 'bigquery_table_name')} fullWidth /><br/>
          Severity: Major
          Found in src/js/components/Integrations.js and 2 other locations - About 50 mins to fix
          src/js/components/Integrations.js on lines 232..232
          src/js/components/ProjectViewer.js on lines 199..199

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

          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

                                      <TextField placeholder="Evernote Notebook IDs (comma separated)"
                                                 value={form.evernote_notebook_ids || ''}
                                                 onChange={this.changeHandler.bind(this, 'form', 'evernote_notebook_ids')}
                                                 fullWidth /><br/>
          Severity: Minor
          Found in src/js/components/Integrations.js and 1 other location - About 50 mins to fix
          src/js/components/Integrations.js on lines 321..324

          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

                                      <TextField placeholder="Evernote max quote length (number)"
                                                 value={form.evernote_max_quote_length || ''}
                                                 onChange={this.changeHandler.bind(this, 'form', 'evernote_max_quote_length')}
                                                 fullWidth /><br/>
          Severity: Minor
          Found in src/js/components/Integrations.js and 1 other location - About 50 mins to fix
          src/js/components/Integrations.js on lines 317..320

          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

                                  <FlatButton label={ evernote_connected ? "Connected" : "Connect" } onClick={this.start_evernote_authentication.bind(this)} disabled={evernote_connected}/>
          Severity: Minor
          Found in src/js/components/Integrations.js and 1 other location - About 35 mins to fix
          src/js/components/Integrations.js on lines 292..292

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

          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

                                  <FlatButton label={ pocket_connected ? "Connected" : "Connect" } onClick={this.start_pocket_authentication.bind(this)} disabled={pocket_connected}/>
          Severity: Minor
          Found in src/js/components/Integrations.js and 1 other location - About 35 mins to fix
          src/js/components/Integrations.js on lines 302..302

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

          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