Showing 77 of 176 total issues
Function reducer
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function reducer(state = initialState, action = {}) {
switch (action.type) {
case SET_CURRENT:
return {
...state,
Function Home
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Home = (props) => {
debug('component:Index', 'Render');
const lastVisit = cookie.load('lastVisit') || null;
Function render
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { user, bookmarks } = this.props;
return (
<div className="min-container">
Function constructor
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(req) {
methods.forEach((method) => {
this[method] = (path, { params, data, arrayFormat } = {}) =>
new Promise((resolve, reject) => {
const request = superagent[method](formatUrl(path));
Function renderTimes
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderTimes() {
const { repeat, setRepeat, intl } = this.props;
const times = Array(10).join().split(',');
return (
Function setSettings
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
setSettings(forceDeviceType) {
const agent = useragent.parse(window.navigator.userAgent);
let deviceType = '';
const osVersion = parseInt(agent.version, 10);
- Read upRead up
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
Open
renderBody() {
const { isErrored, isLoading, results, entities, options, location: { query } } = this.props;
if (!query || !query.q) {
return (
Function reducer
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function reducer(state = initialState, action = {}) {
switch (action.type) {
case LOAD_SUCCESS: {
const entities = state.entities;
const { bookmarks } = action.result.entities;
Function checkValidChapterOrVerse
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function checkValidChapterOrVerse(nextState, replaceState) {
const chapterId = parseInt(nextState.params.chapterId, 10);
filterValidChapter(replaceState, chapterId);
if (nextState.params.range) {
Function render
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { tooltip, word, currentVerse, isPlaying, audioPosition, useTextFont } = this.props;
let text;
let spacer;
Function positionTooltip
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function reducer
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
export default function reducer(state = initialState, action = {}) {
switch (action.type) {
case SET_CURRENT_VERSE: {
return {
...state,
- Read upRead up
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
Open
export default function reducer(state = initialState, action = {}) {
switch (action.type) {
case SEARCH:
return {
...state,
Function renderSingleAyah
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderSingleAyah() {
const { repeat, setRepeat, chapter } = this.props;
const array = Array(chapter.versesCount).join().split(',');
return (
Function handleItemKeyDown
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
handleItemKeyDown(event, item) {
const items = this.menu.getElementsByTagName('li');
if (!items.length) {
return;
Function elements
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
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;
Function mapStateToProps
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function SurahsList
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const SurahsList = (props) => {
debug('component:Index', 'SurahsList');
return (
<ul className="col-md-4 list-unstyled">
Function render
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { chapter, options } = this.props; // eslint-disable-line no-shadow
debug('component:Surah', 'Render');
if (!this.hasVerses()) {
Function render
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { translations, translationOptions } = this.props;
return (
<MenuItem