Chalarangelo/30-seconds-of-code

View on GitHub

Showing 4,537 of 4,537 total issues

File globals.js has 816 lines of code (exceeds 250 allowed). Consider refactoring.
Open

export default {
  __dirname: false,
  __filename: false,
  AbortController: false,
  AbortSignal: false,
Severity: Major
Found in globals.js - About 1 day to fix

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

    export const exportCollectionData = collectionData => {
      /* eslint-disable camelcase */
      return collectionData.map(collection => {
        return {
          model: 'Collection',
    Severity: Major
    Found in src/lib/contentUtils/modelWorkers/collection.js and 1 other location - About 6 hrs to fix
    src/lib/contentUtils/modelWorkers/snippet.js on lines 68..89

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

    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

    export const exportSnippetData = snippetData => {
      /* eslint-disable camelcase */
      return snippetData.map(snippet => {
        return {
          model: 'Snippet',
    Severity: Major
    Found in src/lib/contentUtils/modelWorkers/snippet.js and 1 other location - About 6 hrs to fix
    src/lib/contentUtils/modelWorkers/collection.js on lines 70..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 163.

    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 stem has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    const stem = str => {
      // Exit early
      if (str.length < 3) return str;
    
      let firstCharacterWasLowerCaseY;
    Severity: Minor
    Found in src/lib/search/search.js - 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

    File settings.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    export default {
      serverStopWords: [
        'a',
        'about',
        'above',
    Severity: Minor
    Found in src/lib/search/settings.js - About 3 hrs to fix

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

      const parseTokens = str =>
        deduplicateTokens(
          cleanServerStopWords(tokenize(str)).map(tkn => stem(tkn))
        ).filter(
          tkn =>
      Severity: Major
      Found in src/lib/search/search.js and 1 other location - About 2 hrs to fix
      src/lib/search/search.js on lines 200..209

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

      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

      export const quickParseTokens = str =>
        deduplicateTokens(
          cleanClientStopWords(tokenize(str)).map(tkn => stem(tkn))
        ).filter(
          tkn =>
      Severity: Major
      Found in src/lib/search/search.js and 1 other location - About 2 hrs to fix
      src/lib/search/search.js on lines 186..195

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

      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 recommendSnippets has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        recommendSnippets() {
          const recommendableSnippets = this.recommendableSnippets(
            this.object.languageId,
            this.object.primaryTag
          );
      Severity: Major
      Found in src/presenters/recommendationPresenter.js - About 2 hrs to fix

        Function extractCollectionSnippetData has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const extractCollectionSnippetData = (collections, snippets) => {
          const rankedSnippets = [...snippets].sort((a, b) => b.ranking - a.ranking);
        
          const collectionSnippets = collections
            .map(collection => {
        Severity: Major
        Found in src/lib/contentUtils/modelWorkers/collectionSnippet.js - About 2 hrs to fix

          Function collectionSnippets has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              .map(collection => {
                const {
                  id: collectionId,
                  snippetIds,
                  matchers,
          Severity: Major
          Found in src/lib/contentUtils/modelWorkers/collectionSnippet.js - About 2 hrs to fix

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

            export const extractCollectionData = async (collectionGlob, hub) => {
              const { featuredListings } = hub;
              const collections = await FileHandler.read(collectionGlob);
            
              return await Promise.all(
            Severity: Major
            Found in src/lib/contentUtils/modelWorkers/collection.js - About 2 hrs to fix

              Function extractSnippetData has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const extractSnippetData = async (snippetGlob, languageData) => {
                const snipppetData = await FileHandler.read(snippetGlob);
              
                return await Promise.all(
                  snipppetData.map(async snippet => {
              Severity: Major
              Found in src/lib/contentUtils/modelWorkers/snippet.js - About 2 hrs to fix

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

                  coverSuffix(full = false) {
                    return this.object.isSnippet
                      ? full
                        ? settings.covers.suffix.snippetFull
                        : settings.covers.suffix.snippet
                Severity: Major
                Found in src/presenters/coverPresenter.js and 1 other location - About 1 hr to fix
                src/presenters/coverPresenter.js on lines 50..56

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

                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

                  coverSizes(full = false) {
                    return this.object.isSnippet
                      ? full
                        ? settings.covers.size.snippetFull
                        : settings.covers.size.snippet
                Severity: Major
                Found in src/presenters/coverPresenter.js and 1 other location - About 1 hr to fix
                src/presenters/coverPresenter.js on lines 58..64

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

                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 stem has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const stem = str => {
                  // Exit early
                  if (str.length < 3) return str;
                
                  let firstCharacterWasLowerCaseY;
                Severity: Minor
                Found in src/lib/search/search.js - About 1 hr to fix

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

                    static async processAssets({ force = false }) {
                      const convertedAssets = [
                        ...new Set(
                          globSync(convertedAssetGlobPattern).map(asset =>
                            asset
                  Severity: Minor
                  Found in src/lib/contentUtils/assetHandler.js - About 1 hr to fix

                    Function extractCollectionSnippetData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const extractCollectionSnippetData = (collections, snippets) => {
                      const rankedSnippets = [...snippets].sort((a, b) => b.ranking - a.ranking);
                    
                      const collectionSnippets = collections
                        .map(collection => {
                    Severity: Minor
                    Found in src/lib/contentUtils/modelWorkers/collectionSnippet.js - 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

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

                        const groupedCandidates = this.candidates.reduce((acc, snippet) => {
                          if (!acc[snippet.languageId]) acc[snippet.languageId] = [];
                          acc[snippet.languageId].push(snippet);
                          return acc;
                        }, {});
                    Severity: Major
                    Found in src/presenters/recommendationPresenter.js and 1 other location - About 1 hr to fix
                    src/presenters/recommendationPresenter.js on lines 27..31

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

                    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

                            const tagGroupedSnippets = languageSnippets.reduce((acc, snippet) => {
                              if (!acc[snippet.primaryTag]) acc[snippet.primaryTag] = [];
                              acc[snippet.primaryTag].push(snippet);
                              return acc;
                            }, {});
                    Severity: Major
                    Found in src/presenters/recommendationPresenter.js and 1 other location - About 1 hr to fix
                    src/presenters/recommendationPresenter.js on lines 12..16

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

                    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 searchByKeyphrase has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      searchByKeyphrase(keyphrase) {
                        let q = keyphrase.toLowerCase().trim();
                        if (q.length <= 1) return [];
                        let results = [];
                        if (q.length) {
                    Severity: Minor
                    Found in src/astro/components/Omnisearch.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language