FSharpLint icon indicating copy to clipboard operation
FSharpLint copied to clipboard

Hint "x = true ===> x" is triggered by simple object creation or optional arguments

Open Grenkin1988 opened this issue 5 years ago • 2 comments

Description

Tool is reporting error (FL0065): Hints x = truemight be able to be refactored intox. for the simple object creation process or optional arguments

Repro steps

Optional argument:

  1. Http.AsyncRequest("someSite", silentHttpErrors = true) |> Async.RunSynchronously
  2. -> (FL0065): Hints - Error: x = truemight be able to be refactored intox. on the (48 - 48)

Object initialization:

  1. Given C# class:
public class MySimpleType
    {
        public int SimpleInt { get;set;}
        public bool SuperBoolProperty { get; set; }
        public string SimpleString { get;set;}
    }
  1. And initialize it in F#
let giveObject () =
    MySimpleType(
        SimpleInt = 12,
        SuperBoolProperty = true,
        SimpleString = "String")
  1. -> (FL0065): Hints - Error: x = truemight be able to be refactored intox. on the (20- 20)

Expected behavior

Should be no error

Actual behavior

Tool reports error

Grenkin1988 avatar May 18 '20 07:05 Grenkin1988

Actually same happens for the Hint "x = null ===> isNull x", Just modify:

let giveObject () =
    MySimpleType(
        SimpleInt = 12,
        SuperBoolProperty = true,
        SimpleString = null)

Grenkin1988 avatar May 18 '20 08:05 Grenkin1988

I am also facing the same issue for both true and false cases on property initialization in the ctor declaration.

Evangelink avatar Feb 26 '21 08:02 Evangelink