jquintozamora/react-taxonomypicker

View on GitHub

Showing 12 of 12 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                                while (termEnumerator.moveNext()) {
                                    const currentTerm: any = termEnumerator.get_current();
                                    const isAvailableForTagging: boolean = showOnlyAvailableForTag ? currentTerm.get_isAvailableForTagging() : true;
                                    if (isAvailableForTagging) {
                                        const termObj: any = {
Severity: Major
Found in app/src/api/SP.Taxonomy.ts and 1 other location - About 4 hrs to fix
app/src/api/SP.Taxonomy.ts on lines 129..140

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 130.

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

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                                while (termEnumerator.moveNext()) {
                                    const currentTerm: any = termEnumerator.get_current();
                                    const isAvailableForTagging: boolean = showOnlyAvailableForTag ? currentTerm.get_isAvailableForTagging() : true;
                                    if (isAvailableForTagging) {
                                        const termObj: any = {
Severity: Major
Found in app/src/api/SP.Taxonomy.ts and 1 other location - About 4 hrs to fix
app/src/api/SP.Taxonomy.ts on lines 76..87

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 130.

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

Further Reading

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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                                  : this.getAllTerms()
                                        .then((options: any) => {
                                            this.setState({
                                                ...this.state,
                                                options,
        Severity: Major
        Found in app/src/components/TaxonomyPicker/TaxonomyPicker.tsx and 1 other location - About 1 hr to fix
        app/src/components/TaxonomyPicker/TaxonomyPicker.tsx on lines 57..91

        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 67.

        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

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                    ? TaxonomyAPI.getTermSetCount(termSetGuid, termSetName)
                          .then((termSetCount: number) => {
                              termSetCount > termSetCountMaxSwapToAsync
                                  ? this.setState({
                                        ...this.state,
        Severity: Major
        Found in app/src/components/TaxonomyPicker/TaxonomyPicker.tsx and 1 other location - About 1 hr to fix
        app/src/components/TaxonomyPicker/TaxonomyPicker.tsx on lines 65..81

        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 67.

        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

        Further Reading

        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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    if (
                        window &&
                        window.hasOwnProperty("location") &&
                        window.location.hasOwnProperty("protocol") &&
                        window.location.hasOwnProperty("host")
            Severity: Minor
            Found in app/src/utils/Utils.ts and 1 other location - About 35 mins to fix
            app/src/utils/Cache.ts on lines 5..7

            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 46.

            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

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    if (window && window.hasOwnProperty("location") && window.location.hasOwnProperty("host") && window.location.hasOwnProperty("pathname")) {
                        prefix = window.location.host + window.location.pathname;
                    }
            Severity: Minor
            Found in app/src/utils/Cache.ts and 1 other location - About 35 mins to fix
            app/src/utils/Utils.ts on lines 95..102

            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 46.

            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

            Further Reading

            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