olehmell/subsocial-sdk

View on GitHub

Showing 21 of 393 total issues

File types-lookup.ts has 2579 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */

// import type lookup before we augment - in some environments
// this is required to allow for ambient/previous definitions
Severity: Major
Found in packages/definitions/src/interfaces/types-lookup.ts - About 1 wk to fix

    File lookup.ts has 2107 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Auto-generated via `yarn polkadot-types-from-defs`, do not edit
    /* eslint-disable */
    
    /* eslint-disable sort-keys */
    
    
    Severity: Major
    Found in packages/definitions/src/interfaces/lookup.ts - About 5 days to fix

      File augment-types.ts has 1212 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // Auto-generated via `yarn polkadot-types-from-defs`, do not edit
      /* eslint-disable */
      
      // import type lookup before we augment - in some environments
      // this is required to allow for ambient/previous definitions
      Severity: Major
      Found in packages/definitions/src/interfaces/augment-types.ts - About 3 days to fix

        SubsocialSubstrateApi has 44 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class SubsocialSubstrateApi {
        
          private _api: SubstrateApi // Polkadot API (connected)
        
          constructor ({ api }: SubstrateApiProps) {
        Severity: Minor
        Found in packages/api/src/substrate/index.ts - About 6 hrs to fix

          Function loadRelatedStructs has 114 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function loadRelatedStructs (posts: RawPostData[], finders: FindStructsFns, opts?: PostDetailsOpts) {
            const { withSpace, withOwner } = opts || {}
            const { findSpaces, findPosts, findProfileSpaces } = finders
          
            const ownerByIdMap = new Map<string, RawSpaceData>()
          Severity: Major
          Found in packages/api/src/utils/loadPostStructs.ts - About 4 hrs to fix

            SubsocialApi has 28 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class SubsocialApi implements ISubsocialApi {
              private readonly _base: BasicSubsocialApi
            
              constructor (props: SubsocialApiProps) {
                this._base = new BasicSubsocialApi(props)
            Severity: Minor
            Found in packages/api/src/subsocial/index.ts - About 3 hrs to fix

              Function loadRelatedStructs has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              async function loadRelatedStructs (posts: RawPostData[], finders: FindStructsFns, opts?: PostDetailsOpts) {
                const { withSpace, withOwner } = opts || {}
                const { findSpaces, findPosts, findProfileSpaces } = finders
              
                const ownerByIdMap = new Map<string, RawSpaceData>()
              Severity: Minor
              Found in packages/api/src/utils/loadPostStructs.ts - About 2 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

              BasicSubsocialApi has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export class BasicSubsocialApi extends InnerSubsocialApi {
              
                private structFinders: FindStructsFns = {
                  findSpaces: this.findPublicSpaces.bind(this),
                  findPosts: this.findPublicPosts.bind(this),
              Severity: Minor
              Found in packages/api/src/subsocial/basic.ts - About 2 hrs to fix

                File index.ts has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { ApiPromise as SubstrateApi } from '@polkadot/api';
                import { bool, GenericAccountId, Tuple } from '@polkadot/types';
                import { Space, SpaceId, Post, PostId, Reaction, ReactionId, RoleId, User } from '../types/substrate';
                import { getFirstOrUndefined, idToBn, isEmptyArray, newLogger, pluralize } from '@subsocial/utils';
                import { asAccountId, getUniqueIds, SupportedSubstrateId, SupportedSubstrateResult } from '../utils';
                Severity: Minor
                Found in packages/api/src/substrate/index.ts - About 2 hrs to fix

                  Function onDocumentPointerUp has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      onDocumentPointerUp(e: Event) {
                          if (hasPointerMoved) return;
                          if (this.active) {
                              if ((e.target as HTMLElement).closest(".col-menu")) {
                                  const link = (e.target as HTMLElement).closest("a");
                  Severity: Minor
                  Found in themes/docs-theme/assets/js/src/typedoc/components/Toggle.ts - About 1 hr 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 loadAndSetPostRelatedStructs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export async function loadAndSetPostRelatedStructs (posts: RawPostData[], finders: FindStructsFns, opts?: PostDetailsOpts): Promise<RawPostWithSomeDetails[]> {
                    const { withSpace, withOwner, visibility } = opts || {}
                    const {
                      spaceByIdMap,
                      ownerByIdMap,
                  Severity: Minor
                  Found in packages/api/src/utils/loadPostStructs.ts - About 1 hr 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 initSearch has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function initSearch() {
                      const searchEl = document.getElementById("tsd-search");
                      if (!searchEl) return;
                  
                      const searchScript = document.getElementById(
                  Severity: Minor
                  Found in themes/docs-theme/assets/js/src/typedoc/components/Search.ts - About 1 hr to fix

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

                    export async function loadAndSetPostRelatedStructs (posts: RawPostData[], finders: FindStructsFns, opts?: PostDetailsOpts): Promise<RawPostWithSomeDetails[]> {
                      const { withSpace, withOwner, visibility } = opts || {}
                      const {
                        spaceByIdMap,
                        ownerByIdMap,
                    Severity: Minor
                    Found in packages/api/src/utils/loadPostStructs.ts - About 1 hr to fix

                      Function pluralize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function pluralize ({ count, singularText, pluralText, hideCount }: Props) {
                        if (!count) {
                          count = ZERO;
                        } else if (typeof count === 'string') {
                      
                      
                      Severity: Minor
                      Found in packages/utils/src/pluralize.ts - About 1 hr 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 bindEvents has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function bindEvents(
                          searchEl: HTMLElement,
                          results: HTMLElement,
                          field: HTMLInputElement,
                          state: SearchState
                      Severity: Minor
                      Found in themes/docs-theme/assets/js/src/typedoc/components/Search.ts - About 1 hr to fix

                        Function findStructs has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private async findStructs<T extends SupportedSubstrateResult>
                          (storageItem: StorageItem, ids: SupportedSubstrateId[]): Promise<T[]> {
                            const storage = storageItem.storage
                        
                            try {
                        Severity: Minor
                        Found in packages/api/src/substrate/index.ts - About 1 hr to fix

                          Function setCurrentResult has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function setCurrentResult(results: HTMLElement, dir: number) {
                              let current = results.querySelector(".current");
                              if (!current) {
                                  current = results.querySelector(
                                      dir == 1 ? "li:first-child" : "li:last-child"
                          Severity: Minor
                          Found in themes/docs-theme/assets/js/src/typedoc/components/Search.ts - About 1 hr 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 initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected initialize() {
                                  document.documentElement.classList.add(
                                      "toggle-" + this.key + this.value
                                  );
                          
                          
                          Severity: Minor
                          Found in themes/docs-theme/assets/js/src/typedoc/components/Filter.ts - About 1 hr to fix

                            Function onScroll has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private onScroll(event: CustomEvent<{ scrollTop: number }>) {
                                    const scrollTop = event.detail.scrollTop + 5;
                                    const anchors = this.anchors;
                                    const count = anchors.length - 1;
                                    let index = this.index;
                            Severity: Minor
                            Found in themes/docs-theme/assets/js/src/typedoc/components/MenuHighlight.ts - About 55 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 getPostIdFromExtension has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export const getPostIdFromExtension = (postData?: HasPostStruct): PostId | undefined => {
                              if (!postData) return undefined;
                            
                              const ext = postData.struct.extension
                            
                            
                            Severity: Minor
                            Found in packages/api/src/utils/common.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