quran/quran.com-frontend

View on GitHub
src/containers/Search/index.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function renderStatsBar has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderStatsBar() {
    const { totalCount, totalPages, currentPage, query, perPage } = this.props;
    const from = Math.max(...[(currentPage - 1) * perPage, 1]);
    const to = Math.min(...[currentPage * perPage, totalCount]);
    const values = { from, to, query, total: totalCount };
Severity: Minor
Found in src/containers/Search/index.js - About 1 hr to fix

    Function renderBody has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      renderBody() {
        const { isErrored, isLoading, results, entities, options, location: { query } } = this.props;
    
        if (!query || !query.q) {
          return (
    Severity: Minor
    Found in src/containers/Search/index.js - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

          return results.map(result => (
            <Verse
              verse={entities[result]}
              match={entities[result].match}
              key={entities[result].verseKey}
      Severity: Major
      Found in src/containers/Search/index.js - About 30 mins to fix

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

            if (isErrored) {
              return (
                <h3 className="text-center" style={{ padding: '15%' }}>
                  <LocaleFormattedMessage id="search.error" defaultMessage="Sorry, there was an error with your search." />
                </h3>
        Severity: Major
        Found in src/containers/Search/index.js and 2 other locations - About 55 mins to fix
        src/containers/Search/index.js on lines 99..105
        src/containers/Search/index.js on lines 119..125

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

        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 3 locations. Consider refactoring.
        Open

            if (!results.length) {
              return (
                <h3 className="text-center" style={{ padding: '15%' }}>
                  <LocaleFormattedMessage id="search.noResult" defaultMessage="No results found." />
                </h3>
        Severity: Major
        Found in src/containers/Search/index.js and 2 other locations - About 55 mins to fix
        src/containers/Search/index.js on lines 99..105
        src/containers/Search/index.js on lines 107..113

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

        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 3 locations. Consider refactoring.
        Open

            if (!query || !query.q) {
              return (
                <h3 className="text-center" style={{ padding: '15%' }}>
                  <LocaleFormattedMessage id="search.nothing" defaultMessage="No search query." />
                </h3>
        Severity: Major
        Found in src/containers/Search/index.js and 2 other locations - About 55 mins to fix
        src/containers/Search/index.js on lines 107..113
        src/containers/Search/index.js on lines 119..125

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

        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

        There are no issues that match your filters.

        Category
        Status