RHeactorJS/server

View on GitHub

Showing 21 of 21 total issues

Function default has 119 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function (app, config, emitter, userRepository, tokenAuth, sendHttpProblem) {
  /**
   * A user may request a to use a new email address, by supplying it to this endpoint
   * which will generate a token that is sent to the new address.
   */
Severity: Major
Found in src/api/route/profile.js - About 4 hrs to fix

    Function default has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function (app, config, emitter, userRepository, tokenAuth, sendHttpProblem) {
      app.post('/api/password-change', function (req, res) {
        Promise
          .try(() => {
            let schema = Joi.object().keys({
    Severity: Major
    Found in src/api/route/password-change.js - About 2 hrs to fix

      Function tokenRoutes has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const tokenRoutes = (app, config, tokenAuth, jsonld, sendHttpProblem) => {
        app.post('/api/token/verify', (req, res) => Promise
          .try(() => {
            const match = req.headers.authorization && req.headers.authorization.match(/^Bearer (.+)/)
            if (!match[1]) return res.status(400).send()
      Severity: Major
      Found in src/api/route/token.js - About 2 hrs to fix

        Function rheactorjsExpressBaseConfig has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const rheactorjsExpressBaseConfig = (environment, mimeType, app) => {
          StringType(environment, ['rheactorjsServerExpressBaseConfiguration', 'environment:String'])
          StringType(mimeType, ['rheactorjsServerExpressBaseConfiguration', 'mimeType:String'])
        
          replaceWithFastURLParser()
        Severity: Major
        Found in src/config/express/base.js - About 2 hrs to fix

          Function sendHttpProblem has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          export const sendHttpProblem = (environment, res, err) => {
            let status = 500
            let punish = false
            let punishTime = environment === 'production' ? 1000 : 0
            if (err.name === 'TokenExpiredError' || err.name === AccessDeniedError.name) {
          Severity: Minor
          Found in src/api/send-http-problem.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 sendHttpProblem has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const sendHttpProblem = (environment, res, err) => {
            let status = 500
            let punish = false
            let punishTime = environment === 'production' ? 1000 : 0
            if (err.name === 'TokenExpiredError' || err.name === AccessDeniedError.name) {
          Severity: Minor
          Found in src/api/send-http-problem.js - About 1 hr to fix

            Function action has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              action: (backend, email, author, options) => Promise
                .join(
                  backend.repositories.user.getByEmail(new EmailValue(email)),
                  backend.repositories.user.getByEmail(new EmailValue(author))
                )
            Severity: Minor
            Found in src/console-command/user-update.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 default has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function (config, redis) {
              const environment = config.get('environment')
            // Generate RSA keys for JWT
              return Promise
                .join(
            Severity: Minor
            Found in src/services/keys.js - About 1 hr to fix

              Function applyEvent has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                static applyEvent (event, user) {
                  const {name, data: {email, firstname, lastname, password, isActive, avatar, preferences, property, value}, createdAt, aggregateId} = event
                  switch (name) {
                    case UserCreatedEvent:
                      return new UserModel(new EmailValue(email), firstname, lastname, password, isActive, avatar ? new URIValue(avatar) : undefined, {}, undefined, undefined, false, new AggregateMeta(aggregateId, 1, createdAt))
              Severity: Minor
              Found in src/model/user.js - About 1 hr to fix

                Function default has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function (app, config, emitter, userRepository, sendHttpProblem) {
                  /**
                   * Register a new account, needs to be activated afterwards
                   */
                  app.post('/api/registration', (req, res) => Promise
                Severity: Minor
                Found in src/api/route/registration.js - About 1 hr to fix

                  Function rheactorjsExpressConfig has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function rheactorjsExpressConfig (app, config, webConfig, repositories, emitter, transformer = transform, jsonld = undefined, tokenParsers = []) {
                    const apiHost = new URIValue(config.get('api_host'))
                    if (!jsonld) {
                      jsonld = JSONLD(apiHost)
                    }
                  Severity: Minor
                  Found in src/config/express/rheactorjs-express-config.js - About 1 hr to fix

                    Function createPaginationLinks has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export const createPaginationLinks = (result, urlTemplate) => {
                      PaginatedResultType(result)
                      URIValueType(urlTemplate)
                      let links = []
                      links.push(new Link(
                    Severity: Minor
                    Found in src/api/pagination.js - About 1 hr to fix

                      Function rheactorjsExpressConfig has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      export function rheactorjsExpressConfig (app, config, webConfig, repositories, emitter, transformer = transform, jsonld = undefined, tokenParsers = []) {
                      Severity: Major
                      Found in src/config/express/rheactorjs-express-config.js - About 1 hr to fix

                        Function default has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        export default function (app, config, emitter, userRepository, tokenAuth, sendHttpProblem) {
                        Severity: Minor
                        Found in src/api/route/activate-account.js - About 45 mins to fix

                          Function default has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          export default function (app, config, emitter, userRepository, tokenAuth, sendHttpProblem) {
                          Severity: Minor
                          Found in src/api/route/profile.js - About 45 mins to fix

                            Function default has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            export default function (app, config, emitter, userRepository, tokenAuth, sendHttpProblem) {
                            Severity: Minor
                            Found in src/api/route/password-change.js - About 45 mins to fix

                              Function rheactorjsCommandHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              export function rheactorjsCommandHandler (repos, emitter, config, webConfig, templateMailerClient) {
                              Severity: Minor
                              Found in src/config/command-handler.js - About 35 mins to fix

                                Function default has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                export default function (app, config, emitter, userRepository, sendHttpProblem) {
                                Severity: Minor
                                Found in src/api/route/registration.js - About 35 mins to fix

                                  TODO found
                                  Open

                                  # TODO
                                  Severity: Minor
                                  Found in TODO.md by fixme

                                  TODO found
                                  Open

                                     * TODO: support search my (partial) name and email
                                  Severity: Minor
                                  Found in src/api/route/user.js by fixme
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language