30-seconds/30-seconds-of-code

View on GitHub

Showing 20 of 36 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

    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

      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

                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

                    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

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

                        static prepareRecommendableSnippets() {
                          this.candidates = Snippet.scope('published', 'byRanking');
                      
                          const groupedCandidates = this.candidates.reduce((acc, snippet) => {
                            if (!acc[snippet.languageId]) acc[snippet.languageId] = [];
                      Severity: Minor
                      Found in src/presenters/recommendationPresenter.js - About 1 hr to fix

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

                          static prepare(model, indexes) {
                            const name = model.name;
                        
                            // Create an array for each model to store instances
                            if (!Model.instances[name]) Model.instances[name] = [];
                        Severity: Minor
                        Found in src/core/model.js - About 1 hr to fix

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

                            static generate() {
                              const { name, description, url } = settings.website;
                          
                              const data = `\
                          <rss
                          Severity: Minor
                          Found in src/lib/feed.js - About 1 hr to fix

                            Avoid too many return statements within this function.
                            Open

                                        return;
                            Severity: Major
                            Found in src/presenters/recommendationPresenter.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return;
                              Severity: Major
                              Found in src/presenters/recommendationPresenter.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                      return collectionSnippets.map((snippet, index) => ({
                                        collectionId,
                                        snippetId: snippet.id,
                                        position: snippet.listed ? index : -1,
                                        dateModified: snippet.dateModified,
                                Severity: Major
                                Found in src/lib/contentUtils/modelWorkers/collectionSnippet.js - About 30 mins to fix

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

                                    static prepare(model, indexes) {
                                      const name = model.name;
                                  
                                      // Create an array for each model to store instances
                                      if (!Model.instances[name]) Model.instances[name] = [];
                                  Severity: Minor
                                  Found in src/core/model.js - 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

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

                                    get sublinks() {
                                      if (this.object.isMain) {
                                        return Collection.scope('primary', 'byRanking')
                                          .map(collection => this.toSublink(collection))
                                          .flat()
                                  Severity: Minor
                                  Found in src/presenters/sublinkPresenter.js - 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