petrsvihlik/WopiHost

View on GitHub

Showing 59 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

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

      [HttpGet("{id}/ancestry")]
      [WopiAuthorize(WopiResourceType.File, Permission.Read)]
      [Produces(MediaTypeNames.Application.Json)]
      public async Task<IActionResult> EnumerateAncestors(string id, CancellationToken cancellationToken = default)
      {
      Severity: Major
      Found in src/WopiHost.Core/Controllers/FilesController.cs and 1 other location - About 2 hrs to fix
      src/WopiHost.Core/Controllers/ContainersController.cs on lines 262..278

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

      [HttpGet("{id}/ancestry")]
      [WopiAuthorize(WopiResourceType.Container, Permission.Read)]
      [Produces(MediaTypeNames.Application.Json)]
      public async Task<IActionResult> EnumerateAncestors(string id, CancellationToken cancellationToken = default)
      {
      Severity: Major
      Found in src/WopiHost.Core/Controllers/ContainersController.cs and 1 other location - About 2 hrs to fix
      src/WopiHost.Core/Controllers/FilesController.cs on lines 157..174

      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

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

            [HttpGet("{id}/ecosystem_pointer")]
            [WopiAuthorize(WopiResourceType.Container, Permission.Read)]
            [Produces(MediaTypeNames.Application.Json)]
            public IActionResult GetEcosystem(string id)
            {
            Severity: Major
            Found in src/WopiHost.Core/Controllers/ContainersController.cs and 1 other location - About 1 hr to fix
            src/WopiHost.Core/Controllers/FilesController.cs on lines 133..147

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

            [HttpGet("{id}/ecosystem_pointer")]
            [WopiAuthorize(WopiResourceType.File, Permission.Read)]
            [Produces(MediaTypeNames.Application.Json)]
            public IActionResult GetEcosystem(string id)
            {
            Severity: Major
            Found in src/WopiHost.Core/Controllers/FilesController.cs and 1 other location - About 1 hr to fix
            src/WopiHost.Core/Controllers/ContainersController.cs on lines 238..252

            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

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

                        var query = (await GetAppsAsync())
                        .Where(e => e.Descendants(ElementAction).Any(d => d.Attribute(AttrActionExtension)?.Value == extension))
                        .Select(e => e.Attribute(AttrAppName)?.Value);
                        Severity: Major
                        Found in src/WopiHost.Discovery/WopiDiscoverer.cs and 1 other location - About 1 hr to fix
                        src/WopiHost.Discovery/WopiDiscoverer.cs on lines 128..130

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

                        var query = (await GetAppsAsync())
                        .Where(e => e.Descendants(ElementAction).Any(d => d.Attribute(AttrActionExtension)?.Value == extension))
                        .Select(e => e.Attribute(AttrAppFavicon)?.Value);
                        Severity: Major
                        Found in src/WopiHost.Discovery/WopiDiscoverer.cs and 1 other location - About 1 hr to fix
                        src/WopiHost.Discovery/WopiDiscoverer.cs on lines 118..120

                        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
                            Severity
                            Category
                            Status
                            Source
                            Language