TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function configure has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function configure(dbConfig) {
    const client = dbConfig.client;

    if (client === 'sqlite3') {
        // Backwards compatibility with old knex behaviour
Severity: Minor
Found in ghost/core/core/server/data/db/connection.js - About 2 hrs 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 has has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function has(options) {
    options = options || {};
    options.hash = options.hash || {};
    options.data = options.data || {};

Severity: Minor
Found in ghost/core/core/frontend/helpers/has.js - About 2 hrs 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 handleImageSizes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function handleImageSizes(req, res, next) {
    // In admin we need to read images and calculate the average color (blocked by CORS otherwise)
    res.setHeader('Access-Control-Allow-Origin', '*');

    if (!SIZE_PATH_REGEX.test(req.url)) {
Severity: Minor
Found in ghost/core/core/frontend/web/middleware/handle-image-sizes.js - About 2 hrs 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 FreeProductCard has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function FreeProductCard({products, handleChooseSignup, error}) {
    const {site, action, t} = useContext(AppContext);
    const {selectedProduct, setSelectedProduct} = useContext(ProductsContext);

    let cardClass = selectedProduct === 'free' ? 'gh-portal-product-card free checked' : 'gh-portal-product-card free';
Severity: Minor
Found in apps/portal/src/components/common/ProductsSection.js - About 2 hrs 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 createPublicFileMiddleware has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function createPublicFileMiddleware(location, file, mime, maxAge, options = {}) {
    let cache;
    // These files are provided by Ghost, and therefore live inside of the core folder
    const staticFilePath = config.get('paths').publicFilePath;
    // These files are built on the fly, and must be saved in the content folder
Severity: Minor
Found in ghost/core/core/frontend/web/middleware/serve-public-file.js - About 2 hrs 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 fetchOfferQueryStrData has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    fetchOfferQueryStrData(qs = '') {
        const qsParams = new URLSearchParams(qs);
        const data = {};
        // Handle the query params key/value pairs
        for (let pair of qsParams.entries()) {
Severity: Minor
Found in apps/portal/src/App.js - About 2 hrs 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 Sidebar has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

const Sidebar: React.FC<SidebarProps> = ({tierOptions,
    handleTierChange,
    selectedTier,
    // handleTextInput,
    typeOptions,

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

const Recommendations: React.FC<{ keywords: string[] }> = ({keywords}) => {
    const {
        saveState,
        handleSave
    } = useSettingGroup();

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

const Table: React.FC<TableProps> = ({
    header,
    children,
    borderTop,
    hint,
Severity: Minor
Found in apps/admin-x-design-system/src/global/Table.tsx - About 2 hrs 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 Select has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

const Select: React.FC<SelectProps> = ({
    async,
    title,
    hideTitle,
    size = 'md',
Severity: Minor
Found in apps/admin-x-design-system/src/global/form/Select.tsx - About 2 hrs 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 ColorPickerField has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

const ColorPickerField: React.FC<ColorPickerFieldProps> = ({testId, title, direction, value, hint, error, eyedropper, clearButtonValue, onChange, swatches = [], alwaysOpen = false, debounceMs}) => {
    const [isExpanded, setExpanded] = useState(false);
    const [localValue, setLocalValue] = useState(value);
    const context = useContext(ColorPickerContext);
    const id = useId();
Severity: Minor
Found in apps/admin-x-design-system/src/global/form/ColorPickerField.tsx - About 2 hrs 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 handleResponse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

const handleResponse = async (response: Response) => {
    if (response.status === 0) {
        throw new ServerUnreachableError();
    } else if (response.status === 503) {
        throw new MaintenanceError(response, await response.text());
Severity: Minor
Found in apps/admin-x-framework/src/utils/api/handleResponse.ts - About 2 hrs 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 generate has 56 lines of code (exceeds 25 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: Major
Found in ghost/data-generator/lib/importers/MembersCreatedEventsImporter.js - About 2 hrs to fix

    Function handleSetupEvent has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async handleSetupEvent(session) {
            const setupIntent = await this.api.getSetupIntent(session.setup_intent);
    
            const memberRepository = this.deps.memberRepository;
            const member = await memberRepository.get({
    Severity: Major
    Found in ghost/stripe/lib/services/webhook/CheckoutSessionEventService.js - About 2 hrs to fix

      Function getMetaData has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getMetaData(data, root) {
          const metaData = {
              url: getUrl(data, true),
              canonicalUrl: getCanonicalUrl(data),
              ampUrl: getAmpUrl(data),
      Severity: Major
      Found in ghost/core/core/frontend/meta/get-meta.js - About 2 hrs to fix

        Function chooseBestErrorMessage has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function chooseBestErrorMessage(error, alreadyTranslatedDefaultMessage, t) {
            // helper functions
            const translateMessage = (message, number = null) => {
                if (number) {
                    return t(message, {number});
        Severity: Major
        Found in apps/portal/src/utils/errors.js - About 2 hrs to fix

          Function handleSendInvitation has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const handleSendInvitation = async () => {
                  if (saveState === 'saving') {
                      return;
                  }
          
          

            File StripeConnectModal.tsx has 259 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import BookmarkThumb from '../../../../assets/images/stripe-thumb.jpg';
            import GhostLogo from '../../../../assets/images/orb-squircle.png';
            import GhostLogoPink from '../../../../assets/images/orb-pink.png';
            import NiceModal, {useModal} from '@ebay/nice-modal-react';
            import React, {useState} from 'react';

              Function getSentryConfig has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function getSentryConfig(dsn, environment, appVersion, transport) {
                  const extraIntegrations = [];
              
                  const config = {
                      dsn,
              Severity: Major
              Found in ghost/admin/app/utils/sentry.js - About 2 hrs to fix

                Function chartData has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    get chartData() {
                        let stats;
                        let labels;
                        let data;
                
                
                Severity: Major
                Found in ghost/admin/app/components/dashboard/charts/anchor-attribution.js - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language