jquintozamora/react-taxonomypicker

View on GitHub

Showing 6 of 12 total issues

Function componentDidMount has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public componentDidMount() {
        const {
            termSetGuid,
            termSetName,
            termSetCountMaxSwapToAsync,
Severity: Major
Found in app/src/components/TaxonomyPicker/TaxonomyPicker.tsx - About 2 hrs to fix

    Function getSearchTermsByText has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static getSearchTermsByText(termSetGuid: string, termSetName: string, keyword: string, resultCollectionSize: number = 10, showOnlyAvailableForTag: boolean = true) {
            return new Promise((resolve, reject) => {
                if (keyword === "") { return resolve([]); }
                SP.SOD.executeFunc("sp.js", "SP.ClientContext", () => {
                    // Utils.getLayoutsPageUrl replaces SP.Utilities.Utility.getLayoutsPageUrl
    Severity: Minor
    Found in app/src/api/SP.Taxonomy.ts - About 1 hr to fix

      Function getAllTermsByTermSet has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static getAllTermsByTermSet(termSetGuid: string, termSetName: string, showOnlyAvailableForTag: boolean) {
              return new Promise((resolve, reject) => {
                  const termSetDataCacheExpiresMin: number = 1440;
                  const termSetDataCacheKey: string = "TermSetData_" + termSetName + termSetGuid;
                  const termSetDataCache: any = Cache.getStoredDataByKey(termSetDataCacheKey);
      Severity: Minor
      Found in app/src/api/SP.Taxonomy.ts - About 1 hr to fix

        Function _getSelectControl has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private _getSelectControl(async: boolean, minimumInput?: number) {
                const { placeholder, name, multi } = this.props;
                const { options, value } = this.state;
                return async ? (
                    <Select.Async
        Severity: Minor
        Found in app/src/components/TaxonomyPicker/TaxonomyPicker.tsx - About 1 hr to fix

          Function getTermSetCount has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static getTermSetCount(termSetGuid: string, termSetName: string) {
                  return new Promise((resolve: any, reject: any) => {
                      const termSetCountCacheExpiresMin: number = 10080;
                      const termSetCountCacheKey: string = "TermSetCount_" + termSetName + termSetGuid;
                      const termSetCountCache: any = Cache.getStoredDataByKey(termSetCountCacheKey);
          Severity: Minor
          Found in app/src/api/SP.Taxonomy.ts - About 1 hr to fix

            Function getStoredDataByKey has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public static getStoredDataByKey(key: string): any {
                    let returnData: any = null;
                    if (window.sessionStorage) {
            
                        const newKey: string = Cache.buildStorageKey(key);
            Severity: Minor
            Found in app/src/utils/Cache.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