Showing 15 of 71 total issues

PnutRepositoryImpl has 55 functions (exceeds 20 allowed). Consider refactoring.
Open

export class PnutRepositoryImpl implements PnutRepository {
  constructor(private readonly axios: NuxtAxiosInstance) {}
  updateAvatar(file: File): Promise<PnutResponse<User>> {
    const fd = new FormData()
    fd.append('avatar', file)
Severity: Major
Found in src/plugins/infrastructure/repository/pnutRepositoryImpl.ts - About 7 hrs to fix

Function createCompose has 138 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createCompose(composeOptions: ComposeOptions) {
  @Component
  class ComposeAbstract extends Mixins(textCount) {
    @Prop({
      type: String,
Severity: Major
Found in src/components/organisms/ComposeAbstract.ts - About 5 hrs to fix

File pnutRepositoryImpl.ts has 326 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { NuxtAxiosInstance } from '@nuxtjs/axios'
import { PnutRepository } from '~/plugins/domain/repository/pnutRepository'
import { PnutResponse } from '~/entity/pnut-response'
import { Post } from '~/entity/post'
import {
Severity: Minor
Found in src/plugins/infrastructure/repository/pnutRepositoryImpl.ts - About 3 hrs to fix

Function createCompose has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

export function createCompose(composeOptions: ComposeOptions) {
  @Component
  class ComposeAbstract extends Mixins(textCount) {
    @Prop({
      type: String,
Severity: Minor
Found in src/components/organisms/ComposeAbstract.ts - About 3 hrs 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 getHtmlMeta has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function getHtmlMeta(post?: Post) {
  if (!post || !post.user || !post.content) return
  const name = post.user.name
    ? `${post.user.name}(@${post.user.username})`
    : `@${post.user?.username}`
Severity: Major
Found in src/plugins/domain/util/postUtil.ts - About 2 hrs to fix

Function getDefaultSubscriptionIds has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async getDefaultSubscriptionIds(connection_id: string) {
    const subscribedChannelPromise = this.pnutRepository.getSubscribedChannels({
      connection_id,
      include_read: false,
    })
Severity: Major
Found in src/plugins/domain/usecases/createConnection.ts - About 2 hrs to fix

Function bind has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function bind(context: Context) {
  container
    .register(PnutRepository.token, {
      useValue: new PnutRepositoryImpl(context.$axios),
    })
Severity: Minor
Found in src/plugins/di/bind.ts - About 1 hr to fix

Function createSettingsMenu has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createSettingsMenu(): MenuItem[] {
  return [
    { type: 'heading', label: 'User' },
    {
      label: 'Profile',
Severity: Minor
Found in src/components/organisms/sidebar/Settings.ts - About 1 hr to fix

Function createListInfo has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function createListInfo<T>(
  getPnutResponse: GetPnutResponse<T>
): Promise<ListInfo<T>> {
  const { meta: initialMeta, data: initialData } = await getPnutResponse()
  const olderMeta = {
Severity: Minor
Found in src/plugins/domain/util/util.ts - About 1 hr to fix

Function run has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async run(input: Input): Promise<Output> {
    const title = getTitle({ q: input.params?.q, type: input.type })
    const commonDefaultParams: Input['params'] = {
      order: 'id',
    }
Severity: Minor
Found in src/plugins/domain/usecases/search.ts - About 1 hr to fix

Function createVideoEmbedRaw has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createVideoEmbedRaw(text: string): OEmbed.Video[] {
  return detectGenerators
    .reduce<ResObj[]>((rawHtmls, detectGenerator) => {
      let matcher
      while ((matcher = detectGenerator.regexp.exec(text)) !== null) {
Severity: Minor
Found in src/assets/ts/oembed.ts - About 1 hr to fix

Function insertText has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    insertText(text: string) {
      const textarea = this.$refs.textarea
      const selection = (document as any).selection
      if (selection) {
        textarea.focus()
Severity: Minor
Found in src/components/organisms/ComposeAbstract.ts - About 1 hr to fix

Function messageHandler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  async messageHandler(input: Input, obj: object) {
    if (isConnection(obj)) {
      const { subscriptionMap, unreads } = await this.getDefaultSubscriptionIds(
        obj.meta.connection_id
      )
Severity: Minor
Found in src/plugins/domain/usecases/createConnection.ts - About 45 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 sendPostNotification has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function sendPostNotification(posts: Post[]) {
  const enabled = localStorage.getItem('notification:posts') === 'true'
  if (!enabled || !isEnabledNotification()) return
  if (posts.length === 1) {
    const [post] = posts
Severity: Minor
Found in src/assets/ts/notification-wrapper.ts - About 35 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 getHtmlMeta has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function getHtmlMeta(post?: Post) {
  if (!post || !post.user || !post.content) return
  const name = post.user.name
    ? `${post.user.name}(@${post.user.username})`
    : `@${post.user?.username}`
Severity: Minor
Found in src/plugins/domain/util/postUtil.ts - 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