Swiftformat: No header comments

Created on 8 Nov 2016  路  5Comments  路  Source: nicklockwood/SwiftFormat

I wanted to suggest another feature. I'd love a SwiftFormat rule to remove the default comments that Xcode adds in when creating a new file. They usually look like this:

//
//  File.swift
//  Company
//
//  Created by Name on Date.
//  Copyright 漏 Year Company. All rights reserved.
//

This would allow my team to stop using custom templates, or having to remember to remove the comments at the top of files.

Would love to hear what you think!

Most helpful comment

@mergesort @garnett ah, I see. That's certainly simpler, but most places I've worked at prefer to have a custom header format rather than strip it completely.

Still, I guess I can implement the simpler case first, and consider a custom header later.

All 5 comments

This is a great idea. The main challenge is how to implement the name and date substitution.

I guess the date could be the file creation date. The name could come from the system, but that wouldn't work if you were running SwiftFormat on a CI server.

@nicklockwood, I think @mergesort (please correct me if I am wrong) means to delete header comments completely, not shaping them in uniform format.
My team does the same, we are not interested in any header info like author / date, we have to manually delete them everytime.

@mergesort @garnett ah, I see. That's certainly simpler, but most places I've worked at prefer to have a custom header format rather than strip it completely.

Still, I guess I can implement the simpler case first, and consider a custom header later.

I did indeed want the simpler case, just to plainly to delete the headers. That said, the other options seem pretty cool too, and I'd throw a vote for them as well.

Stripping header comments is implemented in v0.17. Use --header strip as the command line option. (Replacing with a different header is not currently supported.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdiep picture mdiep  路  3Comments

meherkasam picture meherkasam  路  3Comments

DagAgren picture DagAgren  路  4Comments

shawnkoh picture shawnkoh  路  3Comments

DavinAhn picture DavinAhn  路  4Comments