Skip to content

Code formatting #272

@ufechner7

Description

@ufechner7

The formatting of the source code is a bit unusual.

Example: Current code:

function logger(fname::String="WaterLily")
    ENV["JULIA_DEBUG"] = all
    logger = FormatLogger(ifelse(fname[end-3:end]==".log",fname[1:end-4],fname)*".log"; append=false) do io, args
        args.level == _psolver && print(io, args.message)
    end;
    global_logger(logger);
    # put header in file
    @log "p/c, iter, r∞, r₂\n"
end

Formatted with Julia Formatter (in VSCode: right click, format document):

function logger(fname::String="WaterLily")
    ENV["JULIA_DEBUG"] = all
    logger = FormatLogger(ifelse(fname[end-3:end] == ".log", fname[1:end-4], fname) * ".log"; append=false) do io, args
        args.level == _psolver && print(io, args.message)
    end
    global_logger(logger)
    # put header in file
    @log "p/c, iter, r∞, r₂\n"
end

I find the formatted version easier to read, but your mileage might vary. If the current formatting style is intended, it should be documented in the contribution guidelines (normally, that would be the file CONTRIBUTING.md). Main difference: Spaces around operators, spaces after commas, and no semicolon at the end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions