Influxdb task getting reformatted

Hello,

I have a function that is repeated 64 times in my task. I had each manipulation formatted as a single line.
This way it is easier to maintain an overview of all manipulations (extracted bits in this case).

bit0 = sts1 |> map( fn: (r) => ({r with _field: "Prog", _value: bitwise.uand(a: uint(v: r._value), b: uint(v: 1)) >0}))
bit1 = sts1 |> map( fn: (r) => ({r with _field: "Oper", _value: bitwise.uand(a: uint(v: r._value), b: uint(v: 2)) >0}))

But when saving the task it reformats all my functions to multiple lines making the task 8 times longer (in lines of code). This way the entire overview is lost.

bit0 =
    sts1
        |> map(
            fn: (r) =>
                ({r with _field: "Prog",
                    _value: bitwise.uand(a: uint(v: r._value), b: uint(v: 1)) >0,
                }),
        )

Is there a way to disable this auto-formatting behavior?

@JeroenVH Whenever you create or edit tasks through the InfluxDB UI, it will auto-format the Flux. I don’t think there’s any way to disable this. However, if you create or update tasks directly through the API, I don’t believe it will apply the Flux formatter, but I’m not 100% sure.

One thing you could do is kind of hack the formatter. For example, you could create a custom function that parameterizes the values that change through each iteration:

remap = (input=sts1, newField, b) =>
    input
        |> map(fn: (r) => ({r with _field: newField, _value: bitwise.uand(a: uint(v: r._value), b: uint(v: b)) > 0}))

bit0 = remap(newField: "Prog", b: 1)
bit1 = remap(newField: "Oper", b: 2)
// etc.

@scott thank you for pointing me in this direction. Now only the function itself and the union at the end are reformatted.

The function approach is also a lot cleaner to do the bit extraction.