Showing 329 of 329 total issues
File safePolygon.ts
has 354 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {contains, getTarget} from '@floating-ui/react/utils';
import {isElement} from '@floating-ui/utils/dom';
import type {Rect, Side} from './types';
import type {HandleCloseFn} from './hooks/useHover';
import {getChildren} from './utils/getChildren';
- Create a ticketCreate a ticket
Function FloatingArrow
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const FloatingArrow = React.forwardRef(function FloatingArrow(
props: FloatingArrowProps,
ref: React.ForwardedRef<SVGSVGElement>,
): React.JSX.Element | null {
const {
- Create a ticketCreate a ticket
Function useHover
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
export function useHover(
context: FloatingRootContext,
props: UseHoverProps = {},
): ElementProps {
const {open, onOpenChange, dataRef, events, elements} = context;
- Read upRead up
- Create a ticketCreate a ticket
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 inline
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
export const inline = (
options: InlineOptions | Derivable<InlineOptions> = {},
): Middleware => ({
name: 'inline',
options,
- Read upRead up
- Create a ticketCreate a ticket
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 useClientPoint
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function useClientPoint(
context: FloatingRootContext,
props: UseClientPointProps = {},
): ElementProps {
const {
- Create a ticketCreate a ticket
Function useFloating
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function useFloating<T extends ReferenceElement = ReferenceElement>(
reference: Readonly<Ref<MaybeElement<T>>>,
floating: Readonly<Ref<MaybeElement<FloatingElement>>>,
options: UseFloatingOptions<T> = {},
): UseFloatingReturn {
- Create a ticketCreate a ticket
File Tutorial.js
has 345 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {
arrow,
flip,
offset,
shift,
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
const {
refs,
floatingStyles,
placement,
update,
- Read upRead up
- Create a ticketCreate a ticket
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 120.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
const {
refs,
floatingStyles,
placement,
update,
- Read upRead up
- Create a ticketCreate a ticket
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 120.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function useFocus
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function useFocus(
context: FloatingRootContext,
props: UseFocusProps = {},
): ElementProps {
const {open, onOpenChange, events, dataRef, elements} = context;
- Create a ticketCreate a ticket
Function useFloating
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function useFloating<RT extends ReferenceType = ReferenceType>(
options: UseFloatingOptions = {},
): UseFloatingReturn<RT> {
const {nodeId} = options;
- Create a ticketCreate a ticket
Function FloatingArrow
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
export const FloatingArrow = React.forwardRef(function FloatingArrow(
props: FloatingArrowProps,
ref: React.ForwardedRef<SVGSVGElement>,
): React.JSX.Element | null {
const {
- Read upRead up
- Create a ticketCreate a ticket
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 Virtual
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function Virtual() {
const [open, setOpen] = useState(false);
const boundaryRef = useRef();
const pointerTypeRef = useRef();
const {x, y, refs, update} = useFloating({
- Create a ticketCreate a ticket
Function onKeyDown
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
onKeyDown(event) {
isPointerModalityRef.current = false;
const isArrowKey = event.key.startsWith('Arrow');
const isHomeOrEndKey = ['Home', 'End'].includes(event.key);
- Create a ticketCreate a ticket
Function FloatingPortal
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function FloatingPortal(props: FloatingPortalProps): React.JSX.Element {
const {children, id, root, preserveTabOrder = true} = props;
const portalNode = useFloatingPortalNode({id, root});
const [focusManagerState, setFocusManagerState] =
- Create a ticketCreate a ticket
Function FloatingUIMiddleware
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const FloatingUIMiddleware = React.memo(function FloatingUIMiddleware() {
const devtools = useDevtools();
const serializedData = useSerializedData('FloatingUIMiddleware');
const [index, setIndex] = React.useState(serializedData.length - 1);
const handleIndexChange = React.useCallback(
- Create a ticketCreate a ticket
File Combobox.js
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {
autoUpdate,
flip,
FloatingFocusManager,
FloatingPortal,
- Create a ticketCreate a ticket
Function fn
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
async fn(state) {
const {placement, elements, rects, platform, strategy} = state;
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
// ClientRect's bounds, despite the event listener being triggered. A
// padding of 2 seems to handle this issue.
- Create a ticketCreate a ticket
Function FluentUIMiddleware
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const FluentUIMiddleware = React.memo(() => {
const serializedData = useSerializedData('FluentUIMiddleware');
const devtools = useDevtools();
const styles = useStyles();
const [index, setIndex] = React.useState(serializedData.length - 1);
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
export type {
AlignedPlacement,
Alignment,
Axis,
ClientRectObject,
- Read upRead up
- Create a ticketCreate a ticket
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 106.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76