grommet/grommet

View on GitHub

Showing 545 of 2,098 total issues

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

export const normalizeBackground = (backgroundArg, theme) => {
  const background = theme.global.backgrounds?.[backgroundArg] || backgroundArg;
  let result = background;
  // If the background has a light or dark object, use that
  if (background) {
Severity: Minor
Found in src/js/utils/background.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

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

const sizeStyle = (props) => {
  const style =
    props.theme.pagination.button &&
    props.theme.pagination.button.size &&
    props.theme.pagination.button.size[props.size || 'medium'];
Severity: Minor
Found in src/js/components/Pagination/StyledPageControl.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

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

  (Story, context) => {
    const [rootRef, setRootRef] = useState(null);
    const [state, setState] = useState('grommet');
    const [root, setRoot] = useState('document');
    const full = context.allArgs?.full || 'min';
Severity: Minor
Found in storybook/preview.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

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

const Searcher = ({ filtering, filters, onFilter, onFiltering, property }) => {
  const theme = useContext(ThemeContext) || defaultProps.theme;
  const inputRef = useRef();
  const needsFocus = filtering === property;

Severity: Minor
Found in src/js/components/DataTable/Searcher.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

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

export const usePagination = ({ data, page, step, ...rest }) => {
  const totalPages = data ? Math.ceil(data.length / step) : 0;
  const [activePage, setActivePage] = useState(Math.min(page, totalPages) || 1);

  // ensure activePage is never lower than 1 to ensure that itemsBeginIndex
Severity: Minor
Found in src/js/utils/pagination.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

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

const sizeStyle = (props) => {
  if (props.size) {
    const size = props.size || 'medium';
    const data = props.theme.text[size];
    return css`
Severity: Minor
Found in src/js/components/Anchor/StyledAnchor.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

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

export const ControlledDataTable = () => {
  const [checked, setChecked] = React.useState([]);

  const onCheck = (event, value) => {
    if (event.target.checked) {
Severity: Minor
Found in src/js/components/DataTable/stories/rowDetails.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

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

export const withinDropPortal = (node, portalContext) => {
  const root = node?.getRootNode();
  let element = node;
  let portalId;
  while (element && element !== root) {
Severity: Minor
Found in src/js/utils/DOM.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

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

export const animationObjectStyle = (animation, theme, themeObj) => {
  const bounds = animationBounds(animation.type, animation.size);
  const animationTheme =
    (themeObj && themeObj.animation) || theme.global.animation;

Severity: Minor
Found in src/js/utils/animation.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

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

export const getRGBArray = (color) => {
  if (hexExp.test(color)) {
    const [red, green, blue, alpha] = parseHexToRGB(color);
    return [red, green, blue, alpha !== undefined ? alpha / 255.0 : undefined];
  }
Severity: Minor
Found in src/js/utils/colors.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

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

const Sorter = ({
  align,
  children,
  fill,
  onSort,
Severity: Minor
Found in src/js/components/DataTable/Sorter.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

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

export const ArrayOfFormFields = () => {
  const [values, setValues] = useState({
    name: '',
    phones: [{ number: '', ext: '' }],
  });
Severity: Minor
Found in src/js/components/Form/stories/ArrayOfFormFields.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

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

export const getNormalizedValue = (value, valueKey) => {
  if (Array.isArray(value))
    return value.map((v) =>
      valueKey && valueKey.reduce ? v : applyKey(v, valueKey),
    );
Severity: Minor
Found in src/js/components/Select/utils.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

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

const normalizeOutput = (dateValue, outputFormat) => {
  let result;

  const normalize = (value) => {
    let normalizedValue = value.toISOString();
Severity: Minor
Found in src/js/components/Calendar/Calendar.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

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

const setValueAt = (valueObject, pathArg, value) => {
  const object = valueObject;
  const path = Array.isArray(pathArg) ? pathArg : pathArg.split('.');
  if (path.length === 1) object[path] = value;
  else {
Severity: Minor
Found in src/js/components/Form/Form.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

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

const reorder = (array, pinnedArray, source, target) => {
  const result = array.slice(0);
  const tmp = result[source];
  if (source < target)
    for (let i = source; i < target; i += 1) result[i] = result[i + 1];
Severity: Minor
Found in src/js/components/List/List.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

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

const getAnimationStyle = (props, position, full) => {
  let animation =
    props.animation !== undefined ? props.animation : props.animate;
  if (animation === undefined) animation = 'slide';
  let keys;
Severity: Minor
Found in src/js/components/Layer/StyledLayer.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

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

  ${(props) =>
    props.shouldOpen
      ? `visibility: hidden;
      position: absolute;
      pointer-events: none;`
Severity: Minor
Found in src/js/components/Collapsible/Collapsible.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

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

const LazyDrop = () => {
  const [pad, setPad] = useState(null);

  const topLeftTargetRef = useRef();
  const topRightTargetRef = useRef();
Severity: Minor
Found in src/js/components/Drop/stories/CustomThemed/Lazy.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

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

  (
    {
      a11yTitle,
      'aria-label': ariaLabel,
      align = defaultAlign,
Severity: Minor
Found in src/js/components/Drop/DropContainer.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

Severity
Category
Status
Source
Language