Showing 35 of 102 total issues
Function process
has 223 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const process = function(event, callback, teamConfig) {
const mainRegexp = new RegExp(escapeRegExp(config.checkWeb.url), 'g');
const checkURLPattern = escapeRegExp(config.checkWeb.url) + '(?:\/([^/]+)\/project\/([0-9]+)\/media\/([0-9]+)|\/([^/]+)\/media\/([0-9]+))';
const regexp = new RegExp(checkURLPattern, 'g');
File index.test.js
has 496 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
const btoa = require('btoa');
const atob = require('atob');
let aws = require('aws-sdk');
const awsMock = require('aws-sdk-mock');
const md5 = require('js-md5');
File index.js
has 460 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
const config = require('./config.js'),
https = require('https'),
request = require('request'),
qs = require('querystring'),
aws = require('aws-sdk'),
Function process
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
Open
const process = function(event, callback, teamConfig) {
const mainRegexp = new RegExp(escapeRegExp(config.checkWeb.url), 'g');
const checkURLPattern = escapeRegExp(config.checkWeb.url) + '(?:\/([^/]+)\/project\/([0-9]+)\/media\/([0-9]+)|\/([^/]+)\/media\/([0-9]+))';
const regexp = new RegExp(checkURLPattern, 'g');
- 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 formatMessageFromData
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const formatMessageFromData = function(data) {
// Build a list of verification statuses (core or custom) to be selected
// Get the current status (label and color)
File slash-response.js
has 310 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// This function adds a ProjectMedia to Check and sends a message back to Slack
const config = require('./config.js'),
request = require('request'),
util = require('util'),
Function sendActionToSmoochBot
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const sendActionToSmoochBot = function(payload, redisKey, callback, action) {
let message = ''
const redis = getRedisClient();
redis.on('connect', function() {
redis.get(redisKey, function(err, reply) {
File slash-response.test.js
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
const btoa = require('btoa');
const fetch = require('node-fetch');
let config = require('./config');
const sr = require('./slash-response');
Function process
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Open
const process = function(body, token, callback) {
const setProjectRegexp = new RegExp(/set <(.+)>/, 'g');
const showProjectRegexp = new RegExp(/^show/, 'g');
const addUrlRegexp = new RegExp(/<(.+)>/, 'g');
const activateBotRegexp = new RegExp(/^bot activate/, 'g');
- 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
File helpers.js
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
const config = require('./config.js'),
Lokka = require('lokka').Lokka,
Transport = require('lokka-transport-http').Transport,
header = require('basic-auth-header'),
request = require('request'),
Function changeStatus
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const changeStatus = function(data, token, callback) {
const value = JSON.parse(data.callback_id);
const vars = {
id: value.last_status_id,
setFields: JSON.stringify({
Function process
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const process = function(data, callback, context) {
if (data.token === VERIFICATION_TOKEN) {
getCheckSlackUser(data.user.id,
function(err) {
Function handler
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.handler = function(data, context, callback) {
let options = {
url: 'https://www.google.com/searchbyimage',
qs: { image_url: data.image_url, sbisrc: '4chanx', safe: 'off' },
headers: { 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36', 'accept-language': 'en-US,en;q=0.5' }
Function process
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const process = function(body, token, callback) {
const setProjectRegexp = new RegExp(/set <(.+)>/, 'g');
const showProjectRegexp = new RegExp(/^show/, 'g');
const addUrlRegexp = new RegExp(/<(.+)>/, 'g');
const activateBotRegexp = new RegExp(/^bot activate/, 'g');
Function updateTitleOrDescription
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const updateTitleOrDescription = function(attribute, event, data, token, callback, done) {
const id = data.last_status_id,
text = event.text;
const mutationQuery = `($setFields: String!, $id: ID!, $clientMutationId: String!) {
Function getProjectMedia
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const getProjectMedia = function(teamSlug, projectId, projectMediaId, callback, done) {
const client = getGraphqlClient(teamSlug, config.checkApi.apiKey, callback);
const projectMediaQuery = `
query project_media($ids: String!) {
Function sendSmoochImage
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const sendSmoochImage = function(payload, callback) {
const redis = getRedisClient();
redis.on('connect', function() {
const redisKey = 'slack_channel_smooch:' + config.redisPrefix + ':' + payload.body.channel;
redis.get(redisKey, function(err, reply) {
Function showTips
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const showTips = function(payload, callback) {
let message = {
response_type: 'ephemeral',
text: ':wave: ' + t('need_some_help_with') + ' `' + payload.body.command + '`?',
attachments: [
Function testEditMedia
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const testEditMedia = async (field) => {
let outputData = '';
storeLog = inputs => (outputData += inputs);
console['log'] = jest.fn(storeLog);
Function fieldCallback
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const fieldCallback = function(resp) {
if (!resp && n < 60) {
n++;
setTimeout(function() { getField(query, callback, fieldCallback) }, 5000);
}