deveel/deveel.identity.mongodb

View on GitHub

Showing 24 of 24 total issues

Class MongoDbUserStore has 61 methods (exceeds 20 allowed). Consider refactoring.
Open

    public class MongoDbUserStore<TUser> : MongoDbStoreBase<TUser>,
        IQueryableUserStore<TUser>,
        IProtectedUserStore<TUser>,
        IUserPasswordStore<TUser>,
        IUserEmailStore<TUser>,
Severity: Major
Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs - About 1 day to fix

    File MongoDbUserStore_T.cs has 397 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Linq.Expressions;
    using System.Security.Claims;
    Severity: Minor
    Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs - About 5 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              public async Task<IdentityResult> DeleteAsync(TRole role, CancellationToken cancellationToken) {
                  if (role is null)
                      throw new ArgumentNullException(nameof(role));
      
                  ThrowIfDisposed();
      Severity: Major
      Found in src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs and 1 other location - About 4 hrs to fix
      src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs on lines 180..213

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 285.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              public virtual async Task<IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken) {
                  if (user is null)
                      throw new ArgumentNullException(nameof(user));
      
                  ThrowIfDisposed();
      Severity: Major
      Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs and 1 other location - About 4 hrs to fix
      src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs on lines 153..187

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 285.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Class IdentityBuilderExtensions has 33 methods (exceeds 20 allowed). Consider refactoring.
      Open

          public static class IdentityBuilderExtensions {
              public static IdentityBuilder ConfigureMongo(this IdentityBuilder builder, IConfiguration configuration, string sectionName) {
                  builder.Services.ConfigureMongoIdentity(configuration, sectionName);
      
                  return builder;
      Severity: Minor
      Found in src/Deveel.Identity.MongoDb/Security/IdentityBuilderExtensions.cs - About 4 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    try {
                        Trace("Updating the user with ID {UserId} in", user.Id);
        
                        var options = new ReplaceOptions { IsUpsert = false };
                        var result = await Collection.ReplaceOneAsync(IdFilter(user.Id), user, options, cancellationToken);
        Severity: Major
        Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs and 1 other location - About 3 hrs to fix
        src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs on lines 116..143

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 227.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    try {
                        Trace("Updating the role with ID '{RoleId}' in", role.Id);
        
                        var options = new ReplaceOptions { IsUpsert = false };
                        var result = await Collection.ReplaceOneAsync(IdFilter(role.Id), role, options, cancellationToken);
        Severity: Major
        Found in src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs and 1 other location - About 3 hrs to fix
        src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs on lines 234..261

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 227.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                protected async Task<TUser> FindUserAsync(FilterDefinition<TUser> filter, CancellationToken cancellationToken) {
                    ThrowIfDisposed();
                    cancellationToken.ThrowIfCancellationRequested();
        
                    try {
        Severity: Major
        Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs and 1 other location - About 2 hrs to fix
        src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs on lines 57..82

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 198.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                private async Task<TRole> FindAsync(FilterDefinition<TRole> filter, CancellationToken cancellationToken) {
                    ThrowIfDisposed();
                    cancellationToken.ThrowIfCancellationRequested();
        
                    try {
        Severity: Major
        Found in src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs and 1 other location - About 2 hrs to fix
        src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs on lines 105..130

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 198.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                public virtual async Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken) {
                    ThrowIfDisposed();
                    cancellationToken.ThrowIfCancellationRequested();
        
                    try {
        Severity: Major
        Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs and 1 other location - About 2 hrs to fix
        src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs on lines 84..110

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 185.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                public async Task<IdentityResult> CreateAsync(TRole role, CancellationToken cancellationToken) {
                    ThrowIfDisposed();
                    cancellationToken.ThrowIfCancellationRequested();
        
                    try {
        Severity: Major
        Found in src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs and 1 other location - About 2 hrs to fix
        src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs on lines 152..178

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 185.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method UpdateAsync has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public virtual async Task<IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken) {
                    ThrowIfDisposed();
                    cancellationToken.ThrowIfCancellationRequested();
        
                    try {
        Severity: Minor
        Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs - About 1 hr to fix

          Method UpdateAsync has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public async Task<IdentityResult> UpdateAsync(TRole role, CancellationToken cancellationToken) {
                      ThrowIfDisposed();
                      cancellationToken.ThrowIfCancellationRequested();
          
                      try {
          Severity: Minor
          Found in src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs - About 1 hr to fix

            Method DeleteAsync has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public async Task<IdentityResult> DeleteAsync(TRole role, CancellationToken cancellationToken) {
                        if (role is null)
                            throw new ArgumentNullException(nameof(role));
            
                        ThrowIfDisposed();
            Severity: Minor
            Found in src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs - About 1 hr to fix

              Method DeleteAsync has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public virtual async Task<IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken) {
                          if (user is null)
                              throw new ArgumentNullException(nameof(user));
              
                          ThrowIfDisposed();
              Severity: Minor
              Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        public virtual async Task<TUser> FindByIdAsync(string userId, CancellationToken cancellationToken) {
                            if (!ObjectId.TryParse(userId, out var id))
                                throw new ArgumentException($"The provided user ID {userId} is not in a valid 24-digits format");
                
                            Trace("Trying to find a user with ID '{UserId}' in", userId);
                Severity: Major
                Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs and 1 other location - About 1 hr to fix
                src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs on lines 204..211

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 91.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        public async Task<TRole> FindByIdAsync(string roleId, CancellationToken cancellationToken) {
                            if (!ObjectId.TryParse(roleId, out var id))
                                throw new ArgumentException($"The provided user ID {roleId} is not in a valid 24-digits format");
                
                            Trace("Trying to find a role with ID '{RoleId}' in", roleId);
                Severity: Major
                Found in src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs and 1 other location - About 1 hr to fix
                src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs on lines 215..222

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 91.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        public Task<IList<Claim>> GetClaimsAsync(TRole role, CancellationToken cancellationToken)
                            => GetAsync(() => (IList<Claim>)role.Claims?.Select(x => x.ToClaim()).ToList(), cancellationToken);
                Severity: Minor
                Found in src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs and 1 other location - About 40 mins to fix
                src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs on lines 491..492

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 72.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        public virtual Task<IList<Claim>> GetClaimsAsync(TUser user, CancellationToken cancellationToken)
                            => GetAsync(() => (IList<Claim>)user.Claims?.Select(x => x.ToClaim()).ToList(), cancellationToken);
                Severity: Minor
                Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs and 1 other location - About 40 mins to fix
                src/Deveel.Identity.MongoDb/Security/MongoDbRoleStore_T.cs on lines 219..220

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 72.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method SetTokenAsync has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        public virtual Task SetTokenAsync(TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)
                Severity: Minor
                Found in src/Deveel.Identity.MongoDb/Security/MongoDbUserStore_T.cs - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language