quran/quran.com-frontend

View on GitHub

Showing 77 of 176 total issues

Function reducer has 179 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function reducer(state = initialState, action = {}) {
  switch (action.type) {
    case VERSES_CLEAR_CURRENT: {
      const stateFilesCurrent = state.files;

Severity: Major
Found in src/redux/modules/audioplayer.js - About 7 hrs to fix

    Function filterValidVerse has 134 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function filterValidVerse(replaceState, chapterId, verseRange) {
      const chapterToVersesMap = {
        1: 7,
        2: 286,
        3: 200,
    Severity: Major
    Found in src/utils/routeFilters.js - About 5 hrs to fix

      Function render has 108 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render() {
          const { open, handleOpen, children } = this.props;
      
          return (
            <div className={`${styles.container} sidebar ${open && styles.open}`}>
      Severity: Major
      Found in src/components/GlobalSidebar/index.js - About 4 hrs to fix

        Function exports has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(config) {
          config.set({
        
            // base path that will be used to resolve all patterns (eg. files, exclude)
            basePath: '',
        Severity: Major
        Found in karma.conf.js - About 3 hrs to fix

          Function render has 83 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            render() {
              const {
                chapter,
                chapters,
                setOption,
          Severity: Major
          Found in src/components/GlobalNav/Surah/index.js - About 3 hrs to fix

            Function renderRangeAyahs has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              renderRangeAyahs() {
                const { chapter, repeat, setRepeat } = this.props;
                const array = Array(chapter.versesCount).join().split(',');
            
                return (
            Severity: Major
            Found in src/components/Audioplayer/RepeatDropdown/index.js - About 2 hrs to fix

              Function reducer has 72 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function reducer(state = initialState, action = {}) {
                switch (action.type) {
                  case SET_CURRENT_VERSE: {
                    return {
                      ...state,
              Severity: Major
              Found in src/redux/modules/verses.js - About 2 hrs to fix

                File index.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React, { Component, PropTypes } from 'react';
                import * as customPropTypes from 'customPropTypes';
                import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
                import Popover from 'react-bootstrap/lib/Popover';
                import Nav from 'react-bootstrap/lib/Nav';
                Severity: Minor
                Found in src/components/Audioplayer/RepeatDropdown/index.js - About 2 hrs to fix

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

                    renderPopup() {
                      return (
                        <div>
                          <ul className={style.list}>
                            <li className={`text-center ${style.item}`}>
                  Severity: Major
                  Found in src/components/FontSizeDropdown/index.js - About 2 hrs to fix

                    Function reducer has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function reducer(state = initialState, action = {}) {
                      switch (action.type) {
                        case SET_OPTION: {
                          const payload = action.payload;
                          return {
                    Severity: Minor
                    Found in src/redux/modules/options.js - About 2 hrs to fix

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

                        export default function reducer(state = initialState, action = {}) {
                          switch (action.type) {
                            case SURAHS_SET_CURRENT:
                              return {
                                ...state,
                        Severity: Minor
                        Found in src/redux/modules/lines.js - About 1 hr to fix

                          Function renderRightControls has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            renderRightControls() {
                              const { user, rightControls } = this.props;
                          
                              return (
                                rightControls || [
                          Severity: Minor
                          Found in src/components/GlobalNav/index.js - About 1 hr to fix

                            Function reducer has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export default function reducer(state = initialState, action = {}) {
                              switch (action.type) {
                                case SAVE: {
                                  cookie.save('auth', {
                                    client: action.data.client_id,
                            Severity: Minor
                            Found in src/redux/modules/auth.js - About 1 hr to fix

                              Function reducer has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export default function reducer(state = initialState, action = {}) {
                                switch (action.type) {
                                  case VERSES_CLEAR_CURRENT: {
                                    const stateFilesCurrent = state.files;
                              
                              
                              Severity: Minor
                              Found in src/redux/modules/audioplayer.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 render has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                render() {
                                  const { repeat } = this.props;
                              
                                  const popover = (
                                    <Popover
                              Severity: Minor
                              Found in src/components/Audioplayer/RepeatDropdown/index.js - About 1 hr to fix

                                Function renderForm has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  renderForm() {
                                    return (
                                      <form className="form-horizontal" onSubmit={this.submitSupport}>
                                        <div className="form-group">
                                          <label htmlFor="name" className="col-sm-2 control-label">Name</label>
                                Severity: Minor
                                Found in src/containers/Contact/index.js - About 1 hr to fix

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

                                  export default function checkValidChapterOrVerse(nextState, replaceState) {
                                    const chapterId = parseInt(nextState.params.chapterId, 10);
                                    filterValidChapter(replaceState, chapterId);
                                  
                                    if (nextState.params.range) {
                                  Severity: Minor
                                  Found in src/utils/routeFilters.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 render has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    render() {
                                      const { leftControls, handleSidebarToggle, isStatic } = this.props;
                                      debug('component:GlobalNav', 'Render');
                                  
                                      return (
                                  Severity: Minor
                                  Found in src/components/GlobalNav/index.js - About 1 hr to fix

                                    Function render has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      render() {
                                        // Don't show banner when:
                                        // 1) if device isn't iOS or Android
                                        // 2) website is loaded in app,
                                        // 3) user dismissed banner,
                                    Severity: Minor
                                    Found in src/components/SmartBanner/index.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language