TryGhost/Ghost

View on GitHub

Showing 1,756 of 3,886 total issues

Function updateSubscription has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async updateSubscription(data, options) {
        const sharedOptions = {
            transacting: options ? options.transacting : null
        };
        if (!this._stripeAPIService.configured) {
Severity: Major
Found in ghost/members-api/lib/repositories/MemberRepository.js - About 3 hrs to fix

    Anchor has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Anchor extends Component {
        @service dashboardStats;
        @service feature;
        @tracked chartDisplay = 'mrr';
        @tracked resizing = false;
    Severity: Minor
    Found in ghost/admin/app/components/dashboard/charts/anchor-attribution.js - About 3 hrs to fix

      ModalPostPreviewSocialComponent has 29 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class ModalPostPreviewSocialComponent extends Component {
          @service settings;
          @service ghostPaths;
      
          @inject config;
      Severity: Minor
      Found in ghost/admin/app/components/editor/modals/preview/social.js - About 3 hrs to fix

        Function Http has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            return async function Http(req, res, next) {
                debug(`External API request to ${req.url}`);
                let apiKey = null;
                let integration = null;
                let user = null;
        Severity: Major
        Found in ghost/api-framework/lib/http.js - About 3 hrs to fix

          File posts.js has 311 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          const urlUtils = require('../../../shared/url-utils');
          const models = require('../../models');
          const getPostServiceInstance = require('../../services/posts/posts-service');
          const allowedIncludes = [
              'tags',
          Severity: Minor
          Found in ghost/core/core/server/api/endpoints/posts.js - About 3 hrs to fix

            Function add has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                add(apiConfig, frame, options = {add: true}) {
                    debug('add');
            
                    if (_.get(frame,'options.source')) {
                        const html = frame.data.posts[0].html;
            Severity: Minor
            Found in ghost/core/core/server/api/endpoints/utils/serializers/input/posts.js - About 3 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 add has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                add(apiConfig, frame, options = {add: true}) {
                    debug('add');
            
                    if (_.get(frame,'options.source')) {
                        const html = frame.data.pages[0].html;
            Severity: Minor
            Found in ghost/core/core/server/api/endpoints/utils/serializers/input/pages.js - About 3 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 beforeImport has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                beforeImport() {
                    debug('beforeImport');
            
                    const activeTheme = _.find(this.dataToImport, {key: 'active_theme'});
            
            

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

            const RecommendationItem = (recommendation) => {
                const {t, onAction, member, site} = useContext(AppContext);
                const {title, url, description, favicon, one_click_subscribe: oneClickSubscribe, featured_image: featuredImage} = recommendation;
                const allowOneClickSubscribe = member && oneClickSubscribe;
                const [subscribed, setSubscribed] = useState(false);
            Severity: Minor
            Found in apps/portal/src/components/pages/RecommendationsPage.js - About 3 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 fetchLinkData has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                fetchLinkData(site) {
                    const qParams = new URLSearchParams(window.location.search);
                    if (qParams.get('uuid') && qParams.get('action') === 'unsubscribe') {
                        return {
                            showPopup: true,
            Severity: Minor
            Found in apps/portal/src/App.js - About 3 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 permissible has 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    permissible: function permissible(postModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
                        const self = this;
                        const postModel = postModelOrId;
                        let origArgs;
                        let isContributor;
            Severity: Major
            Found in ghost/core/core/server/models/relations/authors.js - About 3 hrs to fix

              Function AboutModal has 85 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const AboutModal = NiceModal.create<RoutingModalProps>(({}) => {
                  const {updateRoute} = useRouting();
                  const globalData = useGlobalData();
                  let config = globalData.config;
                  const upgradeStatus = useUpgradeStatus();
              Severity: Major
              Found in apps/admin-x-settings/src/components/settings/general/About.tsx - About 3 hrs to fix

                exports has 28 functions (exceeds 20 allowed). Consider refactoring.
                Open

                module.exports = class MemberRepository {
                    /**
                     * @param {object} deps
                     * @param {any} deps.Member
                     * @param {any} deps.MemberNewsletter
                Severity: Minor
                Found in ghost/members-api/lib/repositories/MemberRepository.js - About 3 hrs to fix

                  Function onTitleKeydown has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      @action
                      onTitleKeydown(event) {
                          if (this.feature.editorExcerpt) {
                              // move cursor to the excerpt on
                              // - Tab (handled by browser)
                  Severity: Minor
                  Found in ghost/admin/app/components/gh-koenig-editor-lexical.js - About 3 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 exports has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                  module.exports = function (Bookshelf) {
                      Bookshelf.Model = Bookshelf.Model.extend({
                          getNullableStringProperties() {
                              const table = schema.tables[this.tableName];
                              return Object.keys(table).filter(column => table[column].nullable);
                  Severity: Minor
                  Found in ghost/core/core/server/models/base/plugins/data-manipulation.js - About 3 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 setResponseContext has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function setResponseContext(req, res, data) {
                      const pageParam = req.params && req.params.page !== undefined ? parseInt(req.params.page, 10) : 1;
                  
                      res.locals = res.locals || {};
                      res.locals.context = [];
                  Severity: Minor
                  Found in ghost/core/core/frontend/services/rendering/context.js - About 3 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 UnsubscribePage has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default function UnsubscribePage() {
                      const {site, api, pageData, member: loggedInMember, onAction, t} = useContext(AppContext);
                      // member is the member data fetched from the API based on the uuid and its state is limited to just this modal, not all of Portal
                      const [member, setMember] = useState();
                      const [loading, setLoading] = useState(true);
                  Severity: Minor
                  Found in apps/portal/src/components/pages/UnsubscribePage.js - About 3 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 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                          validate: () => void}> = ({clearError, errors, offer, updateOffer}) => {
                              const {siteData} = useGlobalData();
                              const [isCopied, setIsCopied] = useState(false);
                              const handleError = useHandleError();
                              const {mutateAsync: editOffer} = useEditOffer();

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

                  export const formatUrl = (value: string, baseUrl?: string, nullable?: boolean) => {
                      if (nullable && !value) {
                          return {save: null, display: ''};
                      }
                  
                  
                  Severity: Minor
                  Found in apps/admin-x-design-system/src/global/form/URLTextField.tsx - About 3 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 replaceIdentifiers has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      replaceIdentifiers() {
                          const ownerUserId = _.find(this.requiredExistingData.users, (user) => {
                              if (user.roles[0].name === 'Owner') {
                                  return true;
                              }
                  Severity: Major
                  Found in ghost/core/core/server/data/importer/importers/data/Base.js - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language