Showing 67 of 142 total issues
File user.controller.js
has 367 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import UserService from '../services/user.service';
import Helper from '../helpers/helper';
import EmailHelper from '../helpers/verification-email';
import sendPasswordResetEmailHelper from '../services/resetpassword.service';
import errorMiddleware from '../middlewares/error.middleware';
Function up
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('users', {
id: {
allowNull: false,
autoIncrement: true,
Function createAdmin
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async createAdmin(req, res) {
try {
const theUser = await UserService.findOne(req.body.email, '');
const theUserName = await UserService.findOne('', req.body.username);
if (theUser) {
Function up
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Articles', {
id: {
allowNull: false,
autoIncrement: true,
Function getOneArticle
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async getOneArticle(req, res) {
const findArticle = await db.findOne({
where: { slug: req.params.slug }
});
if (!findArticle) {
Function getAllArticles
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async getAllArticles(req, res) {
const counter = await db.count();
if (req.offset >= counter) {
req.offset = 0;
}
Function processSearchQuery
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async processSearchQuery(req, res) {
const { q, offset, limit } = req.query;
const searchQuery = JSON.parse(q);
const articles = await ArticleModel.searchArticle(searchQuery.keyword, offset, limit);
const foundArticles = _.map(
Function updateProfile
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async updateProfile(req, res) {
let filename = '';
if (req.files.image) {
filename = req.files.image.path;
}
Function signup
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async signup(req, res) {
const newUser = req.body;
newUser.email = req.body.email.toLowerCase();
try {
const theUser = await UserService.findOne(req.body.email, '');
Function up
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Comments', {
id: {
allowNull: false,
autoIncrement: true,
Function up
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Likes', {
id: {
allowNull: false,
autoIncrement: true,
Function exports
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = (sequelize, DataTypes) => {
const user = sequelize.define('user', {
firstname: DataTypes.STRING,
lastname: DataTypes.STRING,
email: DataTypes.STRING,
Function login
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async login(req, res) {
try {
let theUser;
if (req.body.email) {
Function notifyViaEmailAndPush
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async notifyViaEmailAndPush(req, res, slug) {
try {
const followedUser = await models.user.findOne({ where: { email: req.auth.email } });
const myFollowers = await models.Follow.findAll({
where: { followedUserId: followedUser.id },
Function handlePasswordReset
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async handlePasswordReset(req, res) {
// verify token and if its not expired
const { token } = req.params;
const tokenDecoded = Helper.verifyToken(token);
if (tokenDecoded === 'invalid token') {
Function up
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('reportings', {
id: {
allowNull: false,
autoIncrement: true,
Function login
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async login(req, res) {
data = req.user;
const type = data.provider;
try {
let user;
Function dislike
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async dislike(req, res) {
try {
if (req.body.author === req.body.userId) {
util.setError(401, 'You can not dislike to your own post');
return util.send(res);
Function validateToken
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const validateToken = async (req, res, next) => {
let token = req.headers['x-access-token'] || req.headers.authorization;
if (!token) {
return res.status(401).send({
status: 401,
Function checkQuery
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const checkQuery = (req, res, next) => {
let {
limit, page, popular, ...searchQueries
} = req.query;
const validQueries = ['author', 'keyword', 'tag', 'title'];