quran/quran.com-frontend

View on GitHub

Showing 77 of 176 total issues

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

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

    Function Home has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Home = (props) => {
      debug('component:Index', 'Render');
    
      const lastVisit = cookie.load('lastVisit') || null;
    
    
    Severity: Minor
    Found in src/containers/Home/index.js - About 1 hr to fix

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

        render() {
          const { user, bookmarks } = this.props;
      
          return (
            <div className="min-container">
      Severity: Minor
      Found in src/containers/Profile/index.js - About 1 hr to fix

        Function constructor has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor(req) {
            methods.forEach((method) => {
              this[method] = (path, { params, data, arrayFormat } = {}) =>
              new Promise((resolve, reject) => {
                const request = superagent[method](formatUrl(path));
        Severity: Minor
        Found in src/helpers/ApiClient.js - About 1 hr to fix

          Function renderTimes has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            renderTimes() {
              const { repeat, setRepeat, intl } = this.props;
              const times = Array(10).join().split(',');
          
              return (
          Severity: Minor
          Found in src/components/Audioplayer/RepeatDropdown/index.js - About 1 hr to fix

            Function setSettings has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              setSettings(forceDeviceType) {
                const agent = useragent.parse(window.navigator.userAgent);
                let deviceType = '';
                const osVersion = parseInt(agent.version, 10);
            
            
            Severity: Minor
            Found in src/components/SmartBanner/index.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 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

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

              export default function reducer(state = initialState, action = {}) {
                switch (action.type) {
                  case LOAD_SUCCESS: {
                    const entities = state.entities;
                    const { bookmarks } = action.result.entities;
              Severity: Minor
              Found in src/redux/modules/bookmarks.js - About 1 hr to fix

                Function checkValidChapterOrVerse has 35 lines of code (exceeds 25 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

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

                    render() {
                      const { tooltip, word, currentVerse, isPlaying, audioPosition, useTextFont } = this.props;
                  
                      let text;
                      let spacer;
                  Severity: Minor
                  Found in src/components/Word/index.js - About 1 hr to fix

                    Function positionTooltip has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const positionTooltip = (target, tooltip) => {
                      if (window.innerWidth < tooltip.offsetWidth * 1.5) {
                        tooltip.style.maxWidth = window.innerWidth / 2; // eslint-disable-line
                      } else {
                        tooltip.style.maxWidth = 340; // eslint-disable-line
                    Severity: Minor
                    Found in src/utils/bindTooltip.js - About 1 hr to fix

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

                      export default function reducer(state = initialState, action = {}) {
                        switch (action.type) {
                          case SET_CURRENT_VERSE: {
                            return {
                              ...state,
                      Severity: Minor
                      Found in src/redux/modules/verses.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 reducer has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

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

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

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

                            handleItemKeyDown(event, item) {
                              const items = this.menu.getElementsByTagName('li');
                          
                              if (!items.length) {
                                return;
                          Severity: Minor
                          Found in src/components/SearchAutocomplete/index.js - About 1 hr to fix

                            Function elements has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              const elements = keys.map((lineNum, index) => {
                                const nextNum = keys[index + 1];
                                const pageNum = lineNum.split('-')[0];
                                const line = lines[lineNum];
                                const renderText = false; // userAgent.isBot;
                            Severity: Minor
                            Found in src/components/PageView/index.js - About 1 hr to fix

                              Function mapStateToProps has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function mapStateToProps(state, ownProps) {
                                const chapterId = parseInt(ownProps.params.chapterId, 10);
                                const chapter: Object = state.chapters.entities[chapterId];
                                const verses: Object = state.verses.entities[chapterId];
                                const verseArray = verses
                              Severity: Minor
                              Found in src/containers/Pdf/index.js - About 1 hr to fix

                                Function SurahsList has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const SurahsList = (props) => {
                                  debug('component:Index', 'SurahsList');
                                
                                  return (
                                    <ul className="col-md-4 list-unstyled">
                                Severity: Minor
                                Found in src/components/Home/SurahsList/index.js - About 1 hr to fix

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

                                    render() {
                                      const { chapter, options } = this.props; // eslint-disable-line no-shadow
                                      debug('component:Surah', 'Render');
                                  
                                      if (!this.hasVerses()) {
                                  Severity: Minor
                                  Found in src/containers/Pdf/index.js - About 1 hr to fix

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

                                      render() {
                                        const { translations, translationOptions } = this.props;
                                    
                                        return (
                                          <MenuItem
                                    Severity: Minor
                                    Found in src/components/ContentDropdown/index.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language