TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function body_class has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function body_class(options) { // eslint-disable-line camelcase
    let classes = [];
    const context = options.data.root.context || [];
    const obj = this.post || this.page;
    const tags = obj && obj.tags ? obj.tags : [];
Severity: Minor
Found in ghost/core/core/frontend/helpers/body_class.js - About 1 hr to fix

    Function clickHandler has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function clickHandler(event) {
                el.removeEventListener('click', clickHandler);
                event.preventDefault();
    
                if (errorEl) {
    Severity: Minor
    Found in apps/portal/src/data-attributes.js - About 1 hr to fix

      Function MigrationOptions has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const MigrationOptions: React.FC = () => {
          const {mutateAsync: deleteAllContent} = useDeleteAllContent();
          const client = useQueryClient();
          const handleError = useHandleError();
      
      

        Function confirmSuspend has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            const confirmSuspend = async (_user: User) => {
                if (_user.status === 'inactive' && _user.roles[0].name !== 'Contributor') {
                    try {
                        await limiter?.errorIfWouldGoOverLimit('staff');
                    } catch (error) {

          Function viteConfig has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default (function viteConfig() {
              return defineConfig({
                  logLevel: process.env.CI ? 'info' : 'warn',
                  plugins: [
                      react()
          Severity: Minor
          Found in apps/admin-x-framework/vite.config.ts - About 1 hr to fix

            Function generate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                generate() {
                    const source = this.generateSource();
            
                    // We need to add all properties here already otherwise CSV imports won't know all the columns
                    let attribution = {
            Severity: Minor
            Found in ghost/data-generator/lib/importers/MembersCreatedEventsImporter.js - About 1 hr to fix

            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 amount has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                amount(model) {
                    if (model.amount === '' || model.amount === undefined) {
                        model.errors.add('amount', 'Please enter the amount.');
            
                        return this.invalidate();
            Severity: Minor
            Found in ghost/admin/app/validators/offer.js - About 1 hr to fix

            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 get has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                async get(result, apiConfigHeaders = {}, frame) {
                    let headers = {};
            
                    if (apiConfigHeaders.disposition) {
                        const dispositionHeader = await disposition[apiConfigHeaders.disposition.type](result, apiConfigHeaders.disposition);
            Severity: Minor
            Found in ghost/api-framework/lib/headers.js - About 1 hr to fix

            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 attachSubscriptionsToMember has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                attachSubscriptionsToMember(member) {
                    if (!member.products || !Array.isArray(member.products)) {
                        return member;
                    }
            
            
            Severity: Minor
            Found in ghost/members-api/lib/services/MemberBREADService.js - About 1 hr to fix

            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 author has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            const author = (attrs, frame) => {
                if (localUtils.isContentAPI(frame)) {
                    delete attrs.created_at;
                    delete attrs.updated_at;
                    delete attrs.last_seen;

            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 add has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                async add(attrs, options = {}) {
                    // create newsletter and assign members in the same transaction
                    if (options.opt_in_existing && !options.transacting) {
                        return this.NewsletterModel.transaction((transacting) => {
                            options.transacting = transacting;
            Severity: Minor
            Found in ghost/core/core/server/services/newsletters/NewslettersService.js - About 1 hr to fix

            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 up has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                async function up(knex) {
                    logging.info('Adjusting MRR based on Offer Redemptions');
                    const offerRedemptions = await knex
                        .select('or.*', 'o.discount_type', 'o.discount_amount', 'o.interval AS discount_interval', 's.mrr AS mrr', 's.id AS subscription_id', 'p.amount AS amount', 'p.interval AS interval')
                        .from('offer_redemptions AS or')

            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 bootGhost has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            async function bootGhost({backend = true, frontend = true, server = true} = {}) {
                // Metrics
                const startTime = Date.now();
                debug('Begin Boot');
            
            
            Severity: Minor
            Found in ghost/core/core/boot.js - About 1 hr to fix

            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 tags has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function tags(options) {
                options = options || {};
                options.hash = options.hash || {};
            
                const autolink = !(isString(options.hash.autolink) && options.hash.autolink === 'false');
            Severity: Minor
            Found in ghost/core/core/frontend/helpers/tags.js - About 1 hr to fix

            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 price has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function price(planOrAmount, options) {
                let plan;
                let amount;
                if (arguments.length === 1) {
                    options = planOrAmount;
            Severity: Minor
            Found in ghost/core/core/frontend/helpers/price.js - About 1 hr to fix

            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 collectionController has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function collectionController(req, res, next) {
                debug('collectionController beging', req.params, res.routerOptions);
            
                const pathOptions = {
                    page: req.params.page !== undefined ? req.params.page : 1,
            Severity: Minor
            Found in ghost/core/core/frontend/services/routing/controllers/collection.js - About 1 hr to fix

            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 getClassNames has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                getClassNames() {
                    const {site, pageQuery} = this.context;
                    const plansData = getSitePrices({site, pageQuery});
                    const fields = this.getInputFields({state: this.state});
                    let sectionClass = '';
            Severity: Minor
            Found in apps/portal/src/components/pages/SignupPage.js - About 1 hr to fix

            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 WebhookModal has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            const WebhookModal: React.FC<WebhookModalProps> = ({webhook, integrationId}) => {
                const modal = useModal();
                const {mutateAsync: createWebhook} = useCreateWebhook();
                const {mutateAsync: editWebhook} = useEditWebhook();
                const handleError = useHandleError();

            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 validateTwitterUrl has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            export function validateTwitterUrl(newUrl: string) {
                if (!newUrl) {
                    return '';
                }
                if (newUrl.match(/(?:x\.com\/)(\S+)/) || newUrl.match(/([a-z\d.]+)/i)) {
            Severity: Minor
            Found in apps/admin-x-settings/src/utils/socialUrls.ts - About 1 hr to fix

            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 PortalModal has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            const PortalModal: React.FC = () => {
                const {updateRoute} = useRouting();
            
                const [selectedPreviewTab, setSelectedPreviewTab] = useState('signup');
            
            

            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

            Severity
            Category
            Status
            Source
            Language