petrsvihlik/WopiHost

View on GitHub

Showing 35 of 59 total issues

File FilesController.cs has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

using System.Net.Mime;
using System.Security.Claims;
using System.Text.Json;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
Severity: Minor
Found in src/WopiHost.Core/Controllers/FilesController.cs - About 5 hrs to fix

    Method OnGet has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    public async Task<ActionResult> OnGet(CancellationToken cancellationToken = default)
    {
    ViewData["Title"] = "Welcome to WOPI HOST test page";
    try
    {
    Severity: Major
    Found in sample/WopiHost.Validator/Pages/Index.cshtml.cs - About 2 hrs to fix

      Method HandleLockOrPut has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      private IActionResult HandleLockOrPut(string id, string? oldLockIdentifier, string? newLockIdentifier, bool lockAcquired, WopiLockInfo? existingLock)
      {
      ArgumentNullException.ThrowIfNull(lockProvider);
      if (oldLockIdentifier is null)
      {
      Severity: Major
      Found in src/WopiHost.Core/Controllers/FilesController.cs - About 2 hrs to fix

        Method HandleLockOrPut has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
        Open

        private IActionResult HandleLockOrPut(string id, string? oldLockIdentifier, string? newLockIdentifier, bool lockAcquired, WopiLockInfo? existingLock)
        {
        ArgumentNullException.ThrowIfNull(lockProvider);
        if (oldLockIdentifier is null)
        {
        Severity: Minor
        Found in src/WopiHost.Core/Controllers/FilesController.cs - About 2 hrs to fix

        Method GetRootContainer has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        [HttpPost]
        [Produces(MediaTypeNames.Application.Json)]
        public async Task<IActionResult> GetRootContainer(
        [FromHeader(Name = WopiHeaders.ECOSYSTEM_OPERATION)] string? ecosystemOperation = null,
        [FromHeader(Name = WopiHeaders.WOPI_SRC)] string? wopiSrc = null,
        Severity: Major
        Found in src/WopiHost.Core/Controllers/WopiBootstrapperController.cs - About 2 hrs to fix

          Method HandleAuthenticateAsync has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
          {
          try
          {
          //TODO: implement access_token_ttl https://learn.microsoft.com/openspecs/office_protocols/ms-wopi/adb48ba9-118a-43b6-82d7-9a508aad1583
          Severity: Minor
          Found in src/WopiHost.Core/Security/Authentication/AccessTokenHandler.cs - About 1 hr to fix

            Method GetCobaltFile has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            private async Task<CobaltFile> GetCobaltFile(IWopiFile file, ClaimsPrincipal principal)
            {
            var disposal = new DisposalEscrow(file.Owner);
            var content = new CobaltFilePartitionConfig
            {
            Severity: Minor
            Found in src/WopiHost.Cobalt/CobaltSession.cs - About 1 hr to fix

              Method CreateChildContainer has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              [HttpPost("{id}")]
              [Produces(MediaTypeNames.Application.Json)]
              [WopiOverrideHeader(WopiContainerOperations.CreateChildContainer)]
              [WopiAuthorize(WopiResourceType.Container, Permission.Create)]
              public async Task<IActionResult> CreateChildContainer(
              Severity: Minor
              Found in src/WopiHost.Core/Controllers/ContainersController.cs - About 1 hr to fix

                Method GetWopiCheckFileInfo has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                public static WopiCheckFileInfo GetWopiCheckFileInfo(this IWopiFile file, WopiHostCapabilities? capabilities = null)
                {
                // #181 make sure the BaseFileName always has an extensions
                var baseFileName = file.Name.EndsWith(file.Extension, StringComparison.OrdinalIgnoreCase)
                ? file.Name
                Severity: Minor
                Found in src/WopiHost.Core/Extensions/FileExtensions.cs - About 1 hr to fix

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

                  [HttpPost("{id}")]
                  [Produces(MediaTypeNames.Application.Json)]
                  [WopiOverrideHeader(WopiContainerOperations.RenameContainer)]
                  [WopiAuthorize(WopiResourceType.Container, Permission.Rename)]
                  public async Task<IActionResult> RenameContainer(
                  Severity: Minor
                  Found in src/WopiHost.Core/Controllers/ContainersController.cs - About 1 hr to fix

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

                    private async Task<WopiCheckFileInfo> BuildCheckFileInfo(
                    IWopiFile file,
                    CancellationToken cancellationToken = default)
                    {
                    ArgumentNullException.ThrowIfNull(file);
                    Severity: Minor
                    Found in src/WopiHost.Core/Controllers/FilesController.cs - About 1 hr to fix

                      Method HandleUnlock has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      private IActionResult HandleUnlock(string id, string? newLockIdentifier, bool lockAcquired, WopiLockInfo? existingLock)
                      {
                      ArgumentNullException.ThrowIfNull(lockProvider);
                       
                      if (lockAcquired)
                      Severity: Minor
                      Found in src/WopiHost.Core/Controllers/FilesController.cs - About 1 hr to fix

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

                        public override async Task ExecuteResultAsync(ActionContext context)
                        {
                        var response = context.HttpContext.Response;
                        response.ContentType = ContentType;
                        var targetStream = response.Body;
                        Severity: Minor
                        Found in src/WopiHost.Core/Results/FileResult.cs - About 1 hr to fix

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

                          public static Task<WopiCheckFileInfo> OnGetWopiCheckFileInfo(WopiCheckFileInfoContext context)
                          {
                          var wopiCheckFileInfo = context.CheckFileInfo;
                          wopiCheckFileInfo.AllowAdditionalMicrosoftServices = true;
                          wopiCheckFileInfo.AllowErrorReportPrompt = true;
                          Severity: Minor
                          Found in sample/WopiHost.Validator/Infrastructure/WopiEvents.cs - About 1 hr to fix

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

                            public async Task<ActionResult> Index()
                            {
                            ViewData["Title"] = "Welcome to WOPI HOST test page";
                            try
                            {
                            Severity: Minor
                            Found in sample/WopiHost.Web/Controllers/HomeController.cs - About 1 hr to fix

                              Method DeleteContainer has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              [HttpPost("{id}")]
                              [WopiOverrideHeader(WopiContainerOperations.DeleteContainer)]
                              [WopiAuthorize(WopiResourceType.Container, Permission.Delete)]
                              public async Task<IActionResult> DeleteContainer(string id, CancellationToken cancellationToken = default)
                              {
                              Severity: Minor
                              Found in src/WopiHost.Core/Controllers/ContainersController.cs - About 1 hr to fix

                                Method PutFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                [HttpPut("{id}/contents")]
                                [HttpPost("{id}/contents")]
                                [WopiAuthorize(WopiResourceType.File, Permission.Update)]
                                public async Task<IActionResult> PutFile(
                                string id,
                                Severity: Minor
                                Found in src/WopiHost.Core/Controllers/FilesController.cs - About 1 hr to fix

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

                                  private IActionResult HandleLockOrPut(string id, string? oldLockIdentifier, string? newLockIdentifier, bool lockAcquired, WopiLockInfo? existingLock)
                                  Severity: Minor
                                  Found in src/WopiHost.Core/Controllers/FilesController.cs - About 35 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                    return new ConflictResult();
                                    Severity: Major
                                    Found in src/WopiHost.Core/Controllers/ContainersController.cs - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                      return new LockMismatchResult(Response, reason: "Missing new lock identifier");
                                      Severity: Major
                                      Found in src/WopiHost.Core/Controllers/FilesController.cs - About 30 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language