Showing 142 of 142 total issues
Function dislike
has 40 lines of code (exceeds 25 allowed). Consider refactoring. 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);
Similar blocks of code found in 2 locations. Consider refactoring. Open
case 'twitter':
await OpenUrlHelper.openUrl(`https://twitter.com/intent/tweet?url=${url}`);
util.setSuccess(200, `Article shared to ${req.params.channel}`, url);
return util.send(res);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 67.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
case 'facebook':
await OpenUrlHelper.openUrl(`https:www.facebook.com/sharer/sharer.php?u=${url}`);
util.setSuccess(200, `Article shared to ${req.params.channel}`, url);
return util.send(res);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 67.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function validateToken
has 39 lines of code (exceeds 25 allowed). Consider refactoring. 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 up
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Rates', {
id: {
allowNull: false,
autoIncrement: true,
Function checkQuery
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const checkQuery = (req, res, next) => {
let {
limit, page, popular, ...searchQueries
} = req.query;
const validQueries = ['author', 'keyword', 'tag', 'title'];
Function exports
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (sequelize, DataTypes) => {
const Article = sequelize.define('Article', {
slug: { type: DataTypes.STRING, allowNull: false },
title: { type: DataTypes.STRING, allowNull: false },
description: { type: DataTypes.TEXT, allowNull: false },
Function clap
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async clap(req, res) {
try {
if (req.body.author === req.body.userId) {
util.setError(401, 'You can not clap to your own post');
return util.send(res);
Function bodyHighlightedText
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async bodyHighlightedText(req, res) {
try {
const [{ id: userId }, { slug }, { startIndex, endIndex }] = [req.auth, req.params, req.query];
const start = Number(startIndex);
const end = Number(endIndex);
Function exports
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (sequelize, DataTypes) => {
const Comment = sequelize.define('Comment', {
userId: DataTypes.INTEGER,
articleSlug: {
type: DataTypes.STRING,
Similar blocks of code found in 2 locations. Consider refactoring. Open
{
firstname: 'admin',
lastname: 'admin',
email: 'admin@gmail.com',
password: hashedpass,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 63.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
{
firstname: 'user',
lastname: 'user',
email: 'user@gmail.com',
password: hashPassword,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 63.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function up
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Highlights', {
id: {
allowNull: false,
autoIncrement: true,
Function requestPasswordReset
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async requestPasswordReset(req, res) {
// check if email provided exists in db
const { email } = req.body;
if (!email) {
return res.status(400).send({
Function listOfFollowedUsers
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async listOfFollowedUsers(req, res, next) {
try {
const follower = await models.user.findOne({ where: { email: req.auth.email } });
const usersIfollow = await models.Follow.findAll({
where: { followerId: follower.id },
Function listOfFollowers
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async listOfFollowers(req, res, next) {
try {
const followedUser = await models.user.findOne({ where: { email: req.auth.email } });
const myFollowers = await models.Follow.findAll({
where: { followedUserId: followedUser.id },
Function getArticleRating
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async getArticleRating(req, res) {
try {
// Initialize rating data
const { articleSlug } = req.params;
// check if rate is arleady there
Similar blocks of code found in 3 locations. Consider refactoring. Open
ArticleTag.associate = function (models) {
ArticleTag.belongsTo(models.Article, { foreignKey: 'articleId' })
ArticleTag.belongsTo(models.Tag, { foreignKey: 'tagId' })
};
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 61.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
Rate.associate = function (models) {
Rate.belongsTo(models.user, {
foreignKey: 'userEmail',
});
Rate.belongsTo(models.Article, {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 61.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
BookMark.associate = function (models) {
BookMark.belongsTo(models.Article, { foreignKey: 'articleId' })
BookMark.belongsTo(models.user, { foreignKey: 'userId' })
};
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 61.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76