Showing 173 of 964 total issues

File ExpressionManager.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import log from 'loglevel';
import { Observable } from 'rxjs';

Severity: Minor
Found in packages/expression-manager/src/ExpressionManager.js - About 2 hrs to fix

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

        render() {
            const styles = {
                tree: {
                    marginLeft: 16,
                    whiteSpace: 'nowrap',
    Severity: Major
    Found in packages/core/src/tree-view/TreeView.component.js - About 2 hrs to fix

      Function renderLabel has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          renderLabel(
              isSelected,
              isSelectable,
              isInitiallyExpanded,
              canBecomeCurrentRoot,
      Severity: Major
      Found in packages/org-unit-tree/src/OrgUnitTree.component.js - About 2 hrs to fix

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

            render() {
                const setDateState = (nothing, date) => {
                    const year = getYear(date);
                    const month = getTwoDigitMonth(date);
                    this.setState({ date, year, month }, this.handleChange);
        Severity: Major
        Found in packages/core/src/period-picker/PeriodPicker.component.js - About 2 hrs to fix

          File FileMenu.js has 263 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React, { Component, Fragment } from 'react';
          import PropTypes from 'prop-types';
          import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
          import { mui3theme } from '@dhis2/d2-ui-core';
          import { withStyles } from '@material-ui/core/styles';
          Severity: Minor
          Found in packages/file-menu/src/FileMenu.js - About 2 hrs to fix

            File TreeView.component.spec.js has 263 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React from 'react';
            import { shallow } from 'enzyme';
            import TreeView from '../TreeView.component';
            
            describe('TreeView component', () => {
            Severity: Minor
            Found in packages/core/src/tree-view/__tests__/TreeView.component.spec.js - About 2 hrs to fix

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

                  render() {
                      const headerBannerWrapperStyle = {
                          width: 155,
                          height: 44,
                          verticalAlign: 'middle',
              Severity: Major
              Found in packages/header-bar/src/InnerHeader.js - About 2 hrs to fix

                Function insertMarkers has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                const insertMarkers = (mode, cb) => {
                    const { selectionStart: start, selectionEnd: end, value } = state.element;
                    const marker = markerMap[mode] || null;
                    if (!marker || !cb || start < 0) {
                        return;
                Severity: Minor
                Found in packages/rich-text/src/editor/convertCtrlKey.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

                Function SelectFieldExample has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function SelectFieldExample (props) {
                    return(
                        <div style={style}>
                            <SelectField
                                label="Select animal"
                Severity: Major
                Found in examples/create-react-app/src/components/select-field.js - About 2 hrs to fix

                  File header-bar-styles.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { Observable } from 'rxjs/Observable';
                  import 'rxjs/add/observable/fromEvent';
                  import 'rxjs/add/operator/debounceTime';
                  import log from 'loglevel';
                  import curry from 'lodash/fp/curry';
                  Severity: Minor
                  Found in packages/header-bar/src/header-bar-styles.js - About 2 hrs to fix

                    Function getStubContext has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function getStubContext() {
                        return {
                            d2: {
                                i18n: {
                                    getTranslation(key) {
                    Severity: Major
                    Found in packages/interpretations/config/test-context.js - About 2 hrs to fix

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

                          render() {
                              const styles = {
                                  scale: {
                                      width: 36 * this.state.classes,
                                      minWidth: 36 * this.state.classes,
                      Severity: Minor
                      Found in packages/legend/src/ColorScaleSelect.component.js - About 1 hr to fix

                        Function constructor has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            constructor (props) {
                                super(props);
                        
                                const d2 = props.d2;
                                this.state = {
                        Severity: Minor
                        Found in examples/create-react-app/src/components/org-unit-tree.js - About 1 hr to fix

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

                              getPeriod() {
                                  const week = this.props.periodType === 'BiWeekly' && this.state.biWeek 
                                      ? biWeekToWeek(this.state.biWeek)
                                      : this.state.week;
                                  const date = this.state.year && week && getFirstDateOfWeek(this.state.year, week);
                          Severity: Minor
                          Found in packages/core/src/period-picker/PeriodPicker.component.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 render has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              render () {
                                  const dataElement = this.props.d2.models.dataElement.create({
                                      "code":"DE_11486142",
                                      "created":"2011-04-20T15:54:58.775+0000",
                                      "lastUpdated":"2016-06-29T07:30:50.235+0000",
                          Severity: Minor
                          Found in examples/create-react-app/src/components/translation.js - About 1 hr to fix

                            Function TableContextMenu has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function TableContextMenu(props, context) {
                                const actionList = Object
                                    .keys(props.actions)
                                    .filter(menuActionKey => typeof props.actions[menuActionKey] === 'function');
                            
                            
                            Severity: Minor
                            Found in packages/table/src/TableContextMenu.component.js - About 1 hr to fix

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

                                  getOrgUnitsForLevel(level, ignoreCache = false) {
                                      const d2 = this.context.d2;
                                      return new Promise((resolve) => {
                                          if (this.props.currentRoot) {
                                              const rootLevel = this.props.currentRoot.level || this.props.currentRoot.path
                              Severity: Minor
                              Found in packages/org-unit-select/src/OrgUnitSelectByLevel.component.js - About 1 hr to fix

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

                                    render() {
                                        const classList = classes(
                                            'd2-ui-table__rows__row',
                                            {
                                                'd2-ui-table__rows__row--even': !this.props.isOdd,
                                Severity: Minor
                                Found in packages/table/src/TableRow.component.js - About 1 hr to fix

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

                                      render() {
                                          const { open, fileType } = this.props;
                                  
                                          return (
                                              <Dialog open={open} onClose={this.onRequestClose} maxWidth="md">
                                  Severity: Minor
                                  Found in packages/file-menu/src/SaveAsDialog.js - About 1 hr to fix

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

                                        render() {
                                            const { open, fileType } = this.props;
                                    
                                            return (
                                                <Dialog open={open} onClose={this.onRequestClose} maxWidth="md">
                                    Severity: Minor
                                    Found in packages/file-menu/src/RenameDialog.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language