gilbarbara/react-dropdown

View on GitHub

Showing 31 of 32 total issues

File config.ts has 1271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

export const options = [
  {
    label: "Alister Chilles",
    value: "achilleso",
    join_time: "1/7/2023"
Severity: Major
Found in demo/src/config.ts - About 3 days to fix

    File index.tsx has 494 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { ChangeEvent, Component, createRef, KeyboardEvent, MouseEvent, RefObject } from 'react';
    import { css } from '@emotion/react';
    import styled from '@emotion/styled';
    import isEqual from '@gilbarbara/deep-equal';
    
    
    Severity: Minor
    Found in src/index.tsx - About 7 hrs to fix

      Dropdown has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class Dropdown extends Component<Props, State> {
        private readonly dropdownRef: RefObject<HTMLDivElement>;
        private readonly methods: Methods;
      
        static defaultProps = defaultProps;
      Severity: Minor
      Found in src/index.tsx - About 3 hrs to fix

        Function componentDidUpdate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          componentDidUpdate(previousProps: Props, previousState: State) {
            const { search, status, values: stateValues } = this.state;
            const {
              closeOnSelect,
              comparatorFn = defaultProps.comparatorFn,
        Severity: Minor
        Found in src/index.tsx - 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 render has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render() {
            const { status, values } = this.state;
            const {
              className,
              direction = 'ltr',
        Severity: Major
        Found in src/index.tsx - About 2 hrs to fix

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

          export default function MenuItem(props: ItemComponentProps) {
            const {
              item,
              itemIndex,
              methods: { addItem, getLabels, getStyles, isSelected, removeItem },
          Severity: Major
          Found in src/components/MenuItem.tsx - About 2 hrs to fix

            Function Input has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function Input(props: ComponentProps) {
              const {
                methods: { createItem, getInputSize, getStyles, setSearch },
                props: { autoFocus, create, disabled, inputComponent, options, searchable },
                state: { cursor, search, status, values },
            Severity: Major
            Found in src/components/Input.tsx - About 2 hrs to fix

              Function componentDidUpdate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                componentDidUpdate(previousProps: Props, previousState: State) {
                  const { search, status, values: stateValues } = this.state;
                  const {
                    closeOnSelect,
                    comparatorFn = defaultProps.comparatorFn,
              Severity: Major
              Found in src/index.tsx - About 2 hrs to fix

                Function CustomStyles has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function CustomStyles() {
                  const [isOpen, setOpen] = useState(false);
                  const [values, setValues] = useState<Option[]>([options[0]]);
                
                  const handleOnChange = (selectedValues: Option[]) => {
                Severity: Major
                Found in demo/src/components/ExternalControls.tsx - About 2 hrs to fix

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

                  const StyledMenuItem = styled.div<Styles & Required<Pick<Props, 'disabled'>>>(props => {
                    const {
                      bgColor,
                      color,
                      disabled,
                  Severity: Minor
                  Found in src/components/MenuItem.tsx - About 1 hr to fix

                    Function Content has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function Content(props: ComponentProps) {
                      const {
                        methods: { getStyles, setStatus },
                        props: { contentComponent, multi, onClickSelector, searchable },
                        state: { status, values },
                    Severity: Minor
                    Found in src/components/Content.tsx - About 1 hr to fix

                      Function Menu has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function Menu(props: ComponentProps) {
                        const {
                          methods: { getStyles },
                          props: { menuComponent },
                          state: { dropdownBounds, searchResults },
                      Severity: Minor
                      Found in src/components/Menu.tsx - About 1 hr to fix

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

                        )<Styles & Required<Pick<Props, 'direction' | 'disabled'>>>(props => {
                          const { bgColor, borderColor, borderRadius, color, direction, disabled, minHeight, width } =
                            props;
                        
                          return css`
                        Severity: Minor
                        Found in src/index.tsx - About 1 hr to fix

                          Function MenuItem has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export default function MenuItem(props: ItemComponentProps) {
                            const {
                              item,
                              itemIndex,
                              methods: { addItem, getLabels, getStyles, isSelected, removeItem },
                          Severity: Minor
                          Found in src/components/MenuItem.tsx - 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 StyledMenu has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          >(props => {
                            const {
                              bgColor,
                              borderColor,
                              borderRadius,
                          Severity: Minor
                          Found in src/components/Menu.tsx - About 1 hr to fix

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

                            export function getCursor(cursor: number | null, type: 'down' | 'up', values: Option[] = []) {
                              const total = values.length;
                              const lastValidIndex = values.map(item => !!item.disabled).lastIndexOf(false);
                              const disabled = values.reduce<number[]>((acc, value, index) => {
                                if (value.disabled) {
                            Severity: Minor
                            Found in src/modules/helpers.ts - About 1 hr to fix

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

                              export function getStyles(styles?: Partial<Styles>): Styles {
                                const {
                                  bgColor = '#fff',
                                  borderColor = '#ccc',
                                  borderRadius = '4px',
                              Severity: Minor
                              Found in src/modules/helpers.ts - About 1 hr to fix

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

                                export default function Option(props: OptionComponentProps) {
                                  const {
                                    item,
                                    methods: { removeItem },
                                    props: {
                                Severity: Minor
                                Found in src/components/Option.tsx - About 1 hr to fix

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

                                    constructor(props: Props) {
                                      super(props);
                                  
                                      this.state = {
                                        cursor: null,
                                  Severity: Minor
                                  Found in src/index.tsx - About 1 hr to fix

                                    Function Create has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    export default function Create(props: ComponentProps): JSX.Element | null {
                                      const {
                                        methods: { createItem, getLabels, getStyles },
                                        props: { create, options },
                                        state: { cursor, search, values },
                                    Severity: Minor
                                    Found in src/components/Create.tsx - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language