TryGhost/Ghost

View on GitHub

Showing 1,756 of 3,886 total issues

Function edit has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    edit(apiConfig, frame) {
        const errors = [];

        _.each(frame.data.settings, (setting) => {
            // TODO: the below array is INCOMPLETE

    Function testRoutes has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function testRoutes() {
        const router = express.Router('testmode');
    
        router.get('/500', (req, res) => res.sendStatus(500));
        router.get('/400', (req, res) => res.sendStatus(400));
    Severity: Major
    Found in ghost/core/core/server/web/api/testmode/routes.js - About 2 hrs to fix

      Function validateCollections has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      _private.validateCollections = function validateCollections(collections) {
          if (collections.constructor !== Object) {
              throw new errors.ValidationError({
                  message: tpl(messages.validationError, {
                      at: collections,
      Severity: Major
      Found in ghost/core/core/server/services/route-settings/validate.js - About 2 hrs to fix

        Function SlackModal has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const SlackModal = NiceModal.create(() => {
            const {updateRoute} = useRouting();
            const modal = NiceModal.useModal();
        
            const {localSettings, updateSetting, handleSave, validate, errors, clearError} = useSettingGroup({

          Function add has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              add({api, InviteModel, invites, options, user}) {
                  let invite;
                  let emailData;
          
                  return InviteModel.findOne({email: invites[0].email}, options)
          Severity: Major
          Found in ghost/core/core/server/services/invites/Invites.js - About 2 hrs to fix

            Function init has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async init() {
                    if (this.didInit) {
                        return;
                    }
                    this.didInit = true;
            Severity: Major
            Found in ghost/core/core/server/services/mentions/service.js - About 2 hrs to fix

              Function initServices has 73 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function initServices() {
                  debug('Begin: initServices');
              
                  debug('Begin: Services');
                  const stripe = require('./server/services/stripe');
              Severity: Major
              Found in ghost/core/core/boot.js - About 2 hrs to fix

                Function BuiltInIntegrations has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const BuiltInIntegrations: React.FC = () => {
                    const {config} = useGlobalData();
                    const {updateRoute} = useRouting();
                
                    const openModal = (modal: string) => {

                  Function create has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static async create(data, uniqueChecker) {
                          let isNew = false;
                          let id;
                  
                          if (data.id instanceof ObjectID) {
                  Severity: Minor
                  Found in ghost/offers/lib/domain/models/Offer.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 error has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                          error(error, transition) {
                              // unauthoirized errors are already handled in the ajax service
                              if (isUnauthorizedError(error)) {
                                  return false;
                              }
                  Severity: Minor
                  Found in ghost/admin/app/routes/application.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 beforeSend has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const beforeSend = function (event, hint) {
                      try {
                          const exception = hint.originalException;
                          const code = exception?.code ?? null;
                          const context = exception?.context ?? null;
                  Severity: Minor
                  Found in ghost/core/core/shared/sentry.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 setupFirstPromoter has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      setupFirstPromoter({site, member}) {
                          if (hasMode(['test'])) {
                              return null;
                          }
                          const firstPromoterId = getFirstpromoterId({site});
                  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 getPageFromLinkPath has a Cognitive Complexity of 21 (exceeds 5 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+?)\/?$/;
                  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 TierDetailPreview has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const TierDetailPreview: React.FC<TierDetailPreviewProps> = ({tier, isFreeTier}) => {
                      const [showingYearly, setShowingYearly] = useState(false);
                  
                      const name = tier?.name || '';
                      const description = tier?.description || '';

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

                  export const Avatar: React.FC<AvatarProps> = ({comment}) => {
                      const {member, avatarSaturation, t} = useAppContext();
                      const dimensionClasses = getDimensionClasses();
                  
                      const memberName = member?.name ?? comment?.member?.name;
                  Severity: Minor
                  Found in apps/comments-ui/src/components/content/Avatar.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 useForm has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const useForm = <State>({initialState, savingDelay, savedDelay = 2000, onSave, onSaveError, onSavedStateReset: onSaveCompleted, onValidate}: {
                      initialState: State;
                      savingDelay?: number;
                      savedDelay?: number;
                      onSave: (state: State) => void | Promise<void>;
                  Severity: Minor
                  Found in apps/admin-x-framework/src/hooks/useForm.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 pipeline has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const pipeline = (apiController, apiUtils, apiType) => {
                      if (controllerMap.has(apiController)) {
                          return controllerMap.get(apiController);
                      }
                  
                  
                  Severity: Major
                  Found in ghost/api-framework/lib/pipeline.js - About 2 hrs to fix

                    Function edit has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        edit: function edit(data, unfilteredOptions) {
                            const options = this.filterOptions(unfilteredOptions, 'edit');
                            const self = this;
                            const ops = [];
                    
                    
                    Severity: Major
                    Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

                      Function exports has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      module.exports = createIrreversibleMigration(async (knex) => {
                          logging.info('Populating slack_url and slack_username setting values');
                      
                          const slackURLSetting = await knex('settings')
                              .select('value')

                        Function filterRelations has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            filterRelations() {
                                return {
                                    labels: {
                                        tableName: 'labels',
                                        type: 'manyToMany',
                        Severity: Major
                        Found in ghost/core/core/server/models/member.js - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language