Showing 25 of 80 total issues
Function handleIncomingWebhook
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
const handleIncomingWebhook = async (
api: SourceNodesArgs,
pluginConfig: CustomPluginOptions,
itemTypes: string[],
): Promise<void> => {
- 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 getKontentItemsSchemaNamingConfiguration
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getKontentItemsSchemaNamingConfiguration = (
config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
): string => {
return (
ItemsSchemaTemplate
Function ComplexMenu
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
const ComplexMenu = () => {
const data = useStaticQuery(graphql`
{
kontentItemNavigationItem(
system: { codename: { eq: "website_root_navigation" } }
Function handleDeleteItem
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const handleDeleteItem = async (
api: SourceNodesArgs,
pluginConfig: CustomPluginOptions
): Promise<string[]> => {
- 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 handleIncomingWebhook
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleIncomingWebhook = async (
api: SourceNodesArgs,
pluginConfig: CustomPluginOptions,
itemTypes: string[],
): Promise<void> => {
Function handleDeleteItem
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleDeleteItem = async (
api: SourceNodesArgs,
pluginConfig: CustomPluginOptions
): Promise<string[]> => {
Function linkLanguageVariants
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
const linkLanguageVariants = (api, typeCodename) => {
const {
actions: { createTypes },
schema,
} = api
Function createSchemaCustomization
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.createSchemaCustomization = async api => {
const {
actions: { createTypes },
schema,
} = api
Function Articles
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Articles = (props) => {
const { data } = props;
const articles = data.allKontentItemArticle.group.map(articleItem => {
const variants = articleItem
.nodes
Function createSchemaCustomization
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createSchemaCustomization = async (
api: CreateSchemaCustomizationArgs,
pluginConfig: CustomPluginOptions,
): Promise<void> => {
// TODO check https://github.com/gatsbyjs/gatsby/pull/14610/files/5c50c435ab49884b6d854cd07f20efd95d1e5f52#diff-29de3acf9ce1010435f2b2f0043dba8cR252
Function resolve
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
resolve: async (source, _args, context, _info) => {
const pluginInfo = await context.nodeModel.findOne({
query: {
filter: {
name: {
Function getServerData
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getServerData(context) {
try {
const response = await fetch(`https://graphql.kontent.ai/${projectId}`, {
method: "POST",
Function articles
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const articles = data.allKontentItemArticle.group.map(articleItem => {
const variants = articleItem
.nodes
.sort((a, b) => a.preferred_language < b.preferred_language ? 1 : -1)
.map(variant => {
Function resolve
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async resolve(
source: { value?: string[]; modular_content?: string[]; type: string },
_args: unknown,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
context: any,
Function linkUsedByContentItems
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const linkUsedByContentItems = (
api,
parentTypeCodename,
childTypeCodename,
linkedElementCodename,
Function replaceNode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const replaceNode = (
domNode: Element,
linkedItems: any[] | undefined,
resolveLinkedItem: Function | undefined,
images: any[] | undefined,
- 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 replaceNode
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const replaceNode = (
domNode: Element,
linkedItems: any[] | undefined,
resolveLinkedItem: Function | undefined,
images: any[] | undefined,
Function loadAllKontentItems
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const loadAllKontentItems = async (
config: CustomPluginOptions,
language: string,
): Promise<KontentItemInput[]> => {
let continuationToken = '';
Consider simplifying this complex logical expression. Open
else if ((api.webhookBody as IWebhookWorkflowResponse)?.message?.api_name === "content_management") {
const parsedBody = api.webhookBody as IWebhookWorkflowResponse;
const isCorrectStructure = parsedBody?.data?.items?.every(item => item.language && item.transition_from && item.transition_to && item.item.id)
&& parsedBody?.message?.api_name
Function handleUpsertItem
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const handleUpsertItem = async (
api: SourceNodesArgs,
pluginConfig: CustomPluginOptions,
itemId: string,
itemLanguage?: string,
- 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"