cmspsgp31/anubis

View on GitHub
anubis/frontend/src/components/record_list.js

Summary

Maintainability
F
4 days
Test Coverage

File record_list.js has 507 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright © 2016, Ugo Pozo
//             2016, Câmara Municipal de São Paulo

// record_list.js - component for listing records that match a search.

Severity: Major
Found in anubis/frontend/src/components/record_list.js - About 1 day to fix

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

        render() {
            let contents = (
                <div style={{textAlign: "center"}}>
                    <CircularProgress
                        size={80}
    Severity: Major
    Found in anubis/frontend/src/components/record_list.js - About 4 hrs to fix

      Function getSortingMenu has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getSortingMenu() {
              if (!this.props.sorting.get('available')) return null;
      
              const available = this.props.sorting.getIn(['available',
                                                          this.props.modelName]);
      Severity: Major
      Found in anubis/frontend/src/components/record_list.js - About 2 hrs to fix

        Function getPaginationElement has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getPaginationElement() {
                if (!this.props.pagination) return null;
        
                const pagination = this.props.pagination;
                const allPages = pagination.get('allPages');
        Severity: Minor
        Found in anubis/frontend/src/components/record_list.js - About 1 hr to fix

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

              render() {
                  let contents = (
                      <div style={{textAlign: "center"}}>
                          <CircularProgress
                              size={80}
          Severity: Minor
          Found in anubis/frontend/src/components/record_list.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 getActionsMenu has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              getActionsMenu() {
                  if (this.props.actions.size == 0) return null;
          
                  return (
                      <ToolbarGroup>
          Severity: Minor
          Found in anubis/frontend/src/components/record_list.js - About 1 hr to fix

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

                        let tiles = this.props.results.map(record => {
                            const id = record.get('id', null);
                            const link = (id) ? this.searchAndDetailsHtml(id) : null;
                            const groupName = (!id) ? record.get('__groupName') : null;
                            const extraStyle = (Item.getExtraStyle) ?
            Severity: Minor
            Found in anubis/frontend/src/components/record_list.js - About 1 hr to fix

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

                  get searchApi() {
                      /*eslint-disable no-unused-vars */
                      const model = this.props.params.model;
                      const expr = this.props.params.splat;
                      const page = this.props.params.page;
              Severity: Major
              Found in anubis/frontend/src/components/record_list.js and 2 other locations - About 3 hrs to fix
              anubis/frontend/src/app.js on lines 134..143
              anubis/frontend/src/components/record_zoom.js on lines 142..151

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

              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

                              <IconButton
                                  disabled={!prevPage}
                                  onTouchTap={() => this.goTo({page: prevPage})}
                                  style={{float: "left", top: "3px"}}
                              >
              Severity: Major
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 1 hr to fix
              anubis/frontend/src/components/record_list.js on lines 307..313

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

              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

                              <IconButton
                                  disabled={!nextPage}
                                  onTouchTap={() => this.goTo({page: nextPage})}
                                  style={{float: "left", top: "3px"}}
                              >
              Severity: Major
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 1 hr to fix
              anubis/frontend/src/components/record_list.js on lines 278..284

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

              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.props.isSearch) {
                          this.fetchSearch(this.props.params);
                      }
                      else {
                          this.conditionalCache(this.props.params);
              Severity: Major
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 1 hr to fix
              anubis/frontend/src/components/record_zoom.js on lines 102..107

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

              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

                      let contents = (
                          <div style={{textAlign: "center"}}>
                              <CircularProgress
                                  size={80}
                                  thickness={7}
              Severity: Minor
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 55 mins to fix
              anubis/frontend/src/components/record_zoom.js on lines 213..220

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

                      const cached = (this.props.cache) ?
                          this.props.cache.getIn([model, expr, sorting, `${page}`]) :
                          null;
              Severity: Minor
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 50 mins to fix
              anubis/frontend/src/components/record_list.js on lines 233..235

              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

                      const cached = (this.props.cache) ?
                          this.props.cache.getIn([model, expr, sorting, `${page}`]) :
                          null;
              Severity: Minor
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 50 mins to fix
              anubis/frontend/src/components/record_list.js on lines 216..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

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

                      params: RPropTypes.shape({
                          splat: RPropTypes.string,
                          model: RPropTypes.string,
                          sorting: RPropTypes.string,
                          page: RPropTypes.string,
              Severity: Minor
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 45 mins to fix
              anubis/frontend/src/components/TokenField/token_field.js on lines 88..93

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

              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 (!currentAsc) {
                                          const sorting = this._makeSorting({
                                              by: current,
                                              ascending: true,
                                          });
              Severity: Minor
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 35 mins to fix
              anubis/frontend/src/components/record_list.js on lines 380..386

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

              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 (currentAsc) {
                                          const sorting = this._makeSorting({
                                              by: current,
                                              ascending: false,
                                          });
              Severity: Minor
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 35 mins to fix
              anubis/frontend/src/components/record_list.js on lines 362..368

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

              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

                                          <MenuItem
                                              key={`${num}`}
                                              primaryText={text}
                                              value={`${num}`}
                                          />
              Severity: Minor
              Found in anubis/frontend/src/components/record_list.js and 1 other location - About 35 mins to fix
              anubis/frontend/src/components/TokenField/unit_token.js on lines 201..205

              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