Showing 43 of 1,811 total issues
File fieldmaps.ts
has 1134 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { HTMLProps } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
interface BaseField<T = string> {
readonly key: T;
Function get_website_meta
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
Open
function get_website_meta() {
if ( ! extension_loaded( 'dom' ) || ! extension_loaded( 'libxml' ) ) {
wp_send_json_error( [], 501 );
exit;
}
- Read upRead up
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 ReferenceFormManual
has 129 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function ReferenceFormManual(props: Props) {
const [errorMessage, setErrorMessage] = useState('');
const [data, setData] = useState<CSL.Data>({
id: '',
type: 'webpage',
Function ToolbarMenu
has 129 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function ToolbarMenu() {
const { parseCitations, parseFootnotes, removeAllCitations } = useDispatch(
'abt/data',
);
const { setSidebarSortMode, setSidebarSortOrder } = useDispatch('abt/ui');
Function Sidebar
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function Sidebar() {
const { parseCitations, parseFootnotes, updateReference } = useDispatch(
'abt/data',
);
const { toggleItemSelected } = useDispatch('abt/ui');
Method get_website_meta
has 119 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function get_website_meta() {
if ( ! extension_loaded( 'dom' ) || ! extension_loaded( 'libxml' ) ) {
wp_send_json_error( [], 501 );
exit;
}
Function StyleSearch
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function StyleSearch(props: Props) {
const [inputValue, setInputValue] = useState(props.value.label);
const [suggestions, setSuggestions] = useState<Style[]>([]);
const [isLoading, setIsLoading] = useState(false);
Function StyleForm
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function StyleForm() {
const [style, setStyle] = useState(SAVED_STYLE);
const [errorMessage, setErrorMessage] = useState('');
return (
Function StaticBibEdit
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function StaticBibEdit(props: Props) {
const {
attributes: { orderedList, items },
setAttributes,
} = props;
Function IdentifierForm
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function IdentifierForm(props: Props) {
const { setIdentifierKind } = useDispatch('abt/ui');
const kind = useSelect(select => select('abt/ui').getIdentifierKind());
const [value, setValue] = useState('');
File webpack.config.ts
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/* eslint-disable @typescript-eslint/no-var-requires */
import { promises as fs } from 'fs';
import path from 'path';
import { promisify } from 'util';
Function BibliographyEdit
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function BibliographyEdit(props: Props) {
const { attributes, setAttributes } = props;
const { heading, headingAlign, headingLevel, isToggleable } = attributes;
return (
<>
Function transform
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
transform(node: HTMLDivElement) {
const heading = node.querySelector<HTMLElement>(
'.abt-bibliography__heading',
);
const body = node.querySelector<HTMLElement>(
Function insertCitation
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
function insertCitation({
onChange,
parseCitations,
selectedItems,
value,
- Read upRead up
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
Method register_script
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function register_script( string $relpath, array $extra_deps = [] ) {
$handle = 'abt-' . $relpath;
$script_suffix = "/bundle/$relpath.js";
$style_suffix = "/bundle/$relpath.css";
Method register_scripts
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function register_scripts() {
//
// Editor.
//
register_script( 'editor-stores' );
Function addItem
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function addItem(
id: string,
references: CSL.Data[],
items: Processor.BibItem[],
setAttributes: (attrs: Partial<Attributes>) => void,
Function mergeLegacyCitations
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mergeLegacyCitations() {
const selectedBlock = select(
'core/block-editor',
).getSelectedBlock();
if (!selectedBlock) {
Function fetchData
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function fetchData(
kind: IdentifierKind,
value: string,
): Promise<CSL.Data> {
let response: CSL.Data | ResponseError;
Function bibliography
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
get bibliography(): Processor.Bibliography {
let data: RawBib | false;
try {
data = this.engine.makeBibliography();
if (!data) {