RocketChat/Rocket.Chat

View on GitHub
apps/meteor/app/api/server/v1/settings.ts

Summary

Maintainability
B
4 hrs
Test Coverage

Function action has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            async action(): Promise<ResultFor<'POST', '/v1/settings/:_id'>> {
                if (!(await hasPermissionAsync(this.userId, 'edit-privileged-setting'))) {
                    return API.v1.unauthorized();
                }

Severity: Minor
Found in apps/meteor/app/api/server/v1/settings.ts - About 1 hr to fix

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

                async action(): Promise<ResultFor<'POST', '/v1/settings/:_id'>> {
                    if (!(await hasPermissionAsync(this.userId, 'edit-privileged-setting'))) {
                        return API.v1.unauthorized();
                    }
    
    
    Severity: Minor
    Found in apps/meteor/app/api/server/v1/settings.ts - About 55 mins 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 fetchSettings has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        query: Parameters<typeof Settings.find>[0],
        sort: FindOptions<ISetting>['sort'],
        offset: FindOptions<ISetting>['skip'],
        count: FindOptions<ISetting>['limit'],
        fields: FindOptions<ISetting>['projection'],
    Severity: Minor
    Found in apps/meteor/app/api/server/v1/settings.ts - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

                      return API.v1.failure();
      Severity: Major
      Found in apps/meteor/app/api/server/v1/settings.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                                return API.v1.failure();
        Severity: Major
        Found in apps/meteor/app/api/server/v1/settings.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return API.v1.success();
          Severity: Major
          Found in apps/meteor/app/api/server/v1/settings.ts - About 30 mins to fix

            Function get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    async get() {
                        const oAuthServicesEnabled = await LoginServiceConfigurationModel.find({}, { projection: { secret: 0 } }).toArray();
            
                        return API.v1.success({
                            services: oAuthServicesEnabled.map((service) => {
            Severity: Minor
            Found in apps/meteor/app/api/server/v1/settings.ts - About 25 mins 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

            There are no issues that match your filters.

            Category
            Status