Showing 49 of 160 total issues
Function render
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
if (this.props.auth === "user") {
return (
<div className="Account">
<h2>User Account Information</h2>
File index.js
has 300 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React, { Component } from "react";
import { connect } from "react-redux";
import { Link } from "react-router-dom";
import { bindActionCreators } from "redux";
import Form from "./../../Components/Form";
File index.js
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React from "react";
import PropTypes from "prop-types";
const Form = ({
username,
Function render
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
if (this.props.auth === "counsellor") {
return (
<div className="Sms">
<h2>SMS Settings</h2>
Function validateForm
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
validateForm(fields, renderError) {
const { password, passwordConfirm } = this.state;
if (password !== passwordConfirm) {
renderError("Passwords must match.");
Function default
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function(state = initialState.user, action) {
switch (action.type) {
case SUBMIT_SURVEY:
return {
...state,
Function handleOnSubmit
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
handleOnSubmit(ev) {
ev.preventDefault();
var ID;
var fields;
var validated = false;
Function server
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.server = function(database, databaseMode) {
// DB setup
database.connect(databaseMode, function(err) {
if (err) {
console.log('Unable to connect to MySQL.');
Function default
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function(state = initialState.counsellor, action) {
switch (action.type) {
case ADD_COUNSELLOR:
return {
...state,
Function abstractSignup
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function abstractSignup(user, requiredCredentials, role, res, model) {
var error = false;
var missingCredentials = [];
Object.keys(requiredCredentials).forEach(function (property) {
Function changePassword
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.changePassword = async function (req, res, model) {
var id = req.query.ID;
var oldPassword = req.body.oldPassword;
let err, oldPasswordHashed, newPasswordHashed, users, isMatch;
Function validateForm
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
validateForm(fields, renderError) {
const { password, passwordConfirm } = this.state;
if (password !== passwordConfirm) {
renderError("Passwords must match.");
- 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 getCounsellor
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getCounsellor(id) {
return function(dispatch) {
const token = localStorage.getItem("token");
const header = {
headers: {
Function default
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function(state = initialState.sms, action) {
switch (action.type) {
case GET_SMS_SETTINGS:
return {
...state,
Function getUser
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getUser(id) {
return function(dispatch) {
const token = localStorage.getItem("token");
const header = {
headers: {
Function default
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function(state = initialState.auth, action) {
switch (action.type) {
case AUTH_USER:
return {
...state,
Function default
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function(ComposedComponent) {
class AuthenticationForUser extends Component {
static contextTypes = {
router: React.PropTypes.object
};
Function checkRoleAndGetInfo
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.checkRoleAndGetInfo = async function (req, res) {
try {
const tokenContents = jwt.decode(req.body.token, config.secret);
const role = tokenContents.role;
Function renderLinks
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderLinks() {
if (this.props.auth !== "") {
return [
<li className="nav-item" key={1}>
<Link className="nav-link" to="/account">
Function renderLinks
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderLinks() {
if (this.props.auth !== "") {
return [
<li className="nav-item" key={1}>
<Link className="nav-link" to="/account">