Showing 1,811 of 1,811 total issues
Function parseCSL
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function parseCSL(file: File): Promise<Style> {
const content = await readFile(file);
const xml = new DOMParser().parseFromString(content, 'application/xml');
const error = xml.querySelector('parsererror');
const label = xml.querySelector('info title');
Function setFootnotes
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function* setFootnotes() {
const items = select('abt/data').getFootnotes();
const blocksList = select('core/block-editor').getBlocks();
const footnoteBlockIndex = blocksList.findIndex(
({ name }) => name === 'abt/footnotes',
Function stripListItem
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function stripListItem(item: Element | string): string {
if (typeof item === 'string') {
const container = document.createElement('div');
container.innerHTML = item;
const child = container.querySelector('.csl-entry');
Function references
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function references(
state = INITIAL_STATE.references,
action: Action,
): State['references'] {
switch (action.type) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
people: [
{
key: 'author',
label: __('Author', 'academic-bloggers-toolkit'),
},
- Read upRead up
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 57.
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
people: [
{
key: 'author',
label: __('Scriptwriter', 'academic-bloggers-toolkit'),
},
- Read upRead up
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 57.
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
Method inject_author_meta
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function inject_author_meta() {
global $post;
if ( ! $post || ! is_singular() ) {
return;
}
Function removeReferences
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function* removeReferences(itemIds: string[]) {
const doc = getEditorDOM();
const toDelete = [
...doc.querySelectorAll<HTMLSpanElement>(CitationElement.selector),
].reduce(
Method render_options_page
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function render_options_page() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die(
esc_html__(
'You do not have sufficient permissions to access this page.',
Function AddReferenceDialog
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function AddReferenceDialog() {
const { addReference } = useDispatch('abt/data');
const [isOpen, setIsOpen] = useState(false);
const toggleDialog = () => setIsOpen(!isOpen);
return (
Function updateEditorCitations
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function* updateEditorCitations(citations: Processor.CitationMeta[]) {
const doc = getEditorDOM();
for (const { html, id, sortedItems } of citations) {
const node = doc.querySelector<HTMLElement>(
createSelector(
Function iterate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export function* iterate(
{ formats = [] }: Value,
formatType?: string,
): IterableIterator<Format> {
for (const fmts of formats) {
- 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
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 23 and the first side effect is on line 21. Open
<?php
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 19 and the first side effect is on line 12. Open
<?php
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 19 and the first side effect is on line 12. Open
<?php
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 19 and the first side effect is on line 12. Open
<?php
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 21 and the first side effect is on line 12. Open
<?php
- Exclude checks
Function init_editor_state
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function init_editor_state( int $post_id ) {
$meta = get_post_meta( $post_id );
if ( ! array_key_exists( '_abt_state', $meta ) || ! has_blocks( $post_id ) ) {
$state = (object) [
- 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 parseCSL
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export async function parseCSL(file: File): Promise<Style> {
const content = await readFile(file);
const xml = new DOMParser().parseFromString(content, 'application/xml');
const error = xml.querySelector('parsererror');
const label = xml.querySelector('info title');
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (node.firstElementChild) {
node.dataset.hasChildren = 'true';
node.firstElementChild.innerHTML =
ZERO_WIDTH_SPACE +
node.firstElementChild.innerHTML +
- Read upRead up
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 50.
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