Showing 1,756 of 3,886 total issues
Function up
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function up(knex) {
logging.info('Populating members_paid_subscription_events from members_stripe_customers_subscriptions');
const allSubscriptions = await knex
.select(
'c.member_id',
Function getPageFromLinkPath
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPageFromLinkPath(path, useSite) {
const customPricesSignupRegex = /^signup\/?(?:\/(\w+?))?\/?$/;
const customMonthlyProductSignup = /^signup\/?(?:\/(\w+?))\/monthly\/?$/;
const customYearlyProductSignup = /^signup\/?(?:\/(\w+?))\/yearly\/?$/;
const customOfferRegex = /^offers\/(\w+?)\/?$/;
Function fetchQueryStrData
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
fetchQueryStrData(qs = '') {
const qsParams = new URLSearchParams(qs);
const data = {
site: {
plans: {}
Function draw
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
draw: function () {
var ctx = this._chart.ctx;
var vm = this._view;
var left, right, top, bottom, borderSkipped, radius;
File test-fixtures.js
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable no-unused-vars*/
import {getFreeProduct, getMemberData, getOfferData, getPriceData, getProductData, getSiteData, getSubscriptionData, getNewsletterData} from './fixtures-generator';
export const transformTierFixture = [
getFreeProduct({
Consider simplifying this complex logical expression. Open
if (!member) {
const metadataName = _.get(session, 'metadata.name');
const metadataNewsletters = _.get(session, 'metadata.newsletters');
const attribution = {
id: session.metadata.attribution_id ?? null,
File import-manager.js
has 319 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const fs = require('fs-extra');
const path = require('path');
const os = require('os');
const glob = require('glob');
Function sendMagicLink
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
async sendMagicLink(req, res) {
const {email, autoRedirect} = req.body;
let {emailType, redirect} = req.body;
let referer = req.get('referer');
Function renderForm
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
renderForm() {
const fields = this.getInputFields({state: this.state});
const {site, pageQuery, t} = this.context;
if (this.state.showNewsletterSelection) {
Function Connect
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Connect: React.FC = () => {
const [submitEnabled, setSubmitEnabled] = useState(false);
const [token, setToken] = useState('');
const [testMode, setTestMode] = useState(false);
const [error, setError] = useState('');
Function getIcon
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
getIcon(event) {
let icon;
if (event.type === 'login_event') {
icon = 'logged-in';
- 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 willTransition
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
@action
willTransition(transition) {
let isExploreTransition = false;
if (transition) {
- 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 generatePassword
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
export default function generatePassword(length, memorable, pattern, prefix) {
var char = '', n, i, validChars = [];
if (length === null || typeof (length) === 'undefined') {
length = 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 chartOptions
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
get chartOptions() {
const that = this;
let activeDays = this.dashboardStats.chartDays;
let barColor = this.feature.nightShift ? 'rgba(200, 204, 217, 0.25)' : 'rgba(200, 204, 217, 0.65)';
- 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 getAdapter
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
getAdapter(adapterName, adapterClassName, config) {
if (!adapterName || !adapterClassName) {
throw new errors.IncorrectUsageError({
message: 'getAdapter must be called with a adapterName and a adapterClassName.'
});
- 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 replace
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
async replace(html, replaceLink, options = {}) {
const {tokenize} = require('html5parser');
const entities = require('entities');
try {
- 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 http
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
const http = (apiImpl) => {
/**
* @param {import('express').Request} req - Express request object.
* @param {import('express').Response} res - Express response object.
* @param {import('express').NextFunction} next - Express next function.
Function forceStripeSubscriptionToProduct
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
async forceStripeSubscriptionToProduct(data, options) {
if (!this._stripeAPIService.configured) {
throw new DataImportError({
message: tpl(messages.noStripeConnection, {action: 'force subscription to product'})
});
File MemberBREADService.js
has 315 lines of code (exceeds 250 allowed). Consider refactoring. Open
const errors = require('@tryghost/errors');
const logging = require('@tryghost/logging');
const tpl = require('@tryghost/tpl');
const moment = require('moment');
Function chartData
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
get chartData() {
const totalCadence = this.dashboardStats.paidMembersByCadence.month + this.dashboardStats.paidMembersByCadence.year;
const monthlyPercentage = Math.round(this.dashboardStats.paidMembersByCadence.month / totalCadence * 100);
const annualPercentage = Math.round(this.dashboardStats.paidMembersByCadence.year / totalCadence * 100);
const barThickness = 5;