fsprojects / FSharpLint

Lint tool for F#
https://fsprojects.github.io/FSharpLint/
MIT License
303 stars 73 forks source link

MaxLinesInFunction: counts commented lines #634

Closed Mersho closed 9 months ago

Mersho commented 9 months ago

Description

MaxLinesInFunction also counts commented lines, which is incorrect.

Steps To Reproduce

• 1. Make sure MaxLinesInFunction is enabled in fsharplint.json and set the maxLines to 2.

• 2. The following files should be included in an example project:

ConsoleApp.fsproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <WarnOn>3390;$(WarnOn)</WarnOn>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

</Project>

Program.fs

module Program

let dog x =
    // Foo
    // Bar
    // Buzz
    ()

• 3. dotnet fsharplint lint ..\ConsoleApp\ConsoleApp\ConsoleApp.fsproj

Current Results

========== Linting C:\Users\PC\source\repos\ConsoleApp\ConsoleApp\obj\Debug\net5.0\ConsoleApp.AssemblyInfo.fs ==========
========== Finished: 0 warnings ==========
========== Linting C:\Users\PC\source\repos\ConsoleApp\ConsoleApp\Program.fs ==========
Function was 4 lines long, suggested to be less than 2 lines long.
Error on line 3 starting at column 4
let dog x =
    ^
--------------------------------------------------------------------------------
========== Finished: 1 warnings ==========
========== Summary: 1 warnings ==========

Expected behavior

The rule shouldn't counts commented lines.

Related information