Giter Club home page Giter Club logo

clorox's Introduction

Build PyPI Version

Motivation

//
// TableViewController.m
// MyProject
//
// Created by My Name on 3/13/16.
// Copyright (c) 2016 My Company. All rights reserved.
//

I've never liked these 8 lines above (7 comment lines + 1 blank one). It does nothing but puts a lot of unuseful information in the beginning of your Objective-C/Swift files. If it is an open source project or if it is gonna be distributed, then ok, it makes sense to have it. Otherwise, it's just a waste of LOC. I'll tell you why, line by line:

Line Explanation
1️⃣ Blank comment
2️⃣ File name: static. Xcode does not change it if you rename the file
3️⃣ Project name: static. Xcode does not change it if you rename the project
4️⃣ Blank comment
5️⃣ File's creator and date: It just says who created the file (even if that person never touches it again) and when. Both infos are easily fetched with a simple git log or a git blame (which would be much more valuable)
6️⃣ Copyright, year and company: static. Xcode does not update the copyright with its current year. And also, it does not update the company name if changed (ok, maybe this is an uncommon case)
7️⃣ Blank comment
8️⃣ Blank line

Installation

clorox was written in python 🐍 and distributed via pypi. As your MacOS already comes with python installed, you can easily install it using the commands below:

sudo easy_install pip  # in case you don't have it already installed
sudo pip install clorox

Usage

⚠️ WARNING: Make sure that your project is backed up through source control before doing anything.

In its basic usage, the command takes only one argument, which is the root path you want to run the cleaning:

clorox --path MyProject

The following screenshots show the execution output and the diff of some modified files:

clorox in action screen shot 2016-03-29 at 11 10 12 pm

Advanced Usage

Inspection

If you are not comfortable running the command and want to see which files would be affected by its execution, simply add the option --inspection or -i, like this:

clorox --path MyProject --inspection

Report

By default, clorox prints out a colored tree indicating which files were modified (or inspected). If you're using clorox as a step of your development process, you might consider passing a --report argument. Currently, the only type of report that clorox supports is json. So you would do something like:

clorox --path MyProject --report json

Note

clorox only removes already existent file comment headers from existent source files. So it is useful when you have a project with a bunch of files and then decide to get rid of them all. For new files, Xcode will still add the cruft. To change that, you need to modify the file templates you want.

First, check which templates you have installed under your Xcode directory:

ls -al /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/Source/

It should print something like:

drwxr-xr-x  15 root  wheel  510 Mar 15 18:56 .
drwxr-xr-x   7 root  wheel  238 Mar 15 20:19 ..
drwxr-xr-x   7 root  wheel  238 Mar 15 18:56 C File.xctemplate
drwxr-xr-x   7 root  wheel  238 Mar 15 18:56 C++ File.xctemplate
drwxr-xr-x  21 root  wheel  714 Mar 15 18:56 Cocoa Class.xctemplate
drwxr-xr-x   6 root  wheel  204 Mar 15 18:56 Header File.xctemplate
drwxr-xr-x   9 root  wheel  306 Mar 15 18:56 Objective-C File.xctemplate
drwxr-xr-x   5 root  wheel  170 Mar 15 18:56 Objective-C new superclass.xctemplate
drwxr-xr-x   4 root  wheel  136 Mar 15 18:56 Playground Page.xctemplate
drwxr-xr-x   8 root  wheel  272 Mar 15 20:40 Playground with Platform Choice.xctemplate
drwxr-xr-x   6 root  wheel  204 Mar 15 20:40 Playground.xctemplate
drwxr-xr-x   4 root  wheel  136 Mar 15 18:56 Sources Folder Swift File.xctemplate
drwxr-xr-x   6 root  wheel  204 Mar 15 18:56 Swift File.xctemplate
drwxr-xr-x   7 root  wheel  238 Mar 15 18:56 UI Test Case Class.xctemplate
drwxr-xr-x   7 root  wheel  238 Mar 15 18:56 Unit Test Case Class.xctemplate

Then look for files named ___FILEBASENAME___.* inside the folder you want and clean its content.

Acknowlegdements

Author

Gustavo Barbosa. :octocat: GitHub 🐦 Twitter

License

This project is distributed under the MIT License.

clorox's People

Contributors

barbosa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

clorox's Issues

Add option to remove all leading whitespace

I really enjoy Clorox and we even enforce it's usage using the danger plugin, however I have some files with trailing whitespaces/newlines before the actual code so when I run it these files start being flagged as with errors due to the SwiftLint Leading Whitespace rule.

How do you feel about adding an option to enable the complete removal of leading whitespace?

Thanks for the awesome job so far! 🎉

SyntaxError: Missing parentheses in call to 'print'

Whenever I try to run clorox I get the following error:

$ clorox --path ProjectX
Traceback (most recent call last):
  File "/usr/local/bin/clorox", line 9, in <module>
    load_entry_point('clorox==0.5', 'console_scripts', 'clorox')()
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/setuptools-9.1-py3.4.egg/pkg_resources/__init__.py", line 474, in load_entry_point
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/setuptools-9.1-py3.4.egg/pkg_resources/__init__.py", line 2569, in load_entry_point
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/setuptools-9.1-py3.4.egg/pkg_resources/__init__.py", line 2260, in load
  File "/usr/local/lib/python3.4/site-packages/clorox/clorox.py", line 88
    print 'You must provide a directory to be cleaned using the --dir option'
                                                                            ^
SyntaxError: Missing parentheses in call to 'print'

Environment

  • macOS 10.12
  • Python 3.4.2 installed via hombebrew
  • pip 7.1.2 from /usr/local/lib/python3.4/site-packages (python 3.4)
  • clorox-0.5
  • couleur-0.6.2

Reproducible

  • Always

Am I doing something wrong?

pip: command not found

Actually, the pip its not available in every macOS installation as it says on the readme.

So if you need to install it just use this command:
sudo easy_install pip

Thanks! 🚀

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.