Recent Changes - Search:

edit SideBar

JSCleaning

We would like to have clean JavaScript code.

JSHint

We use JSHint to check for warnings. To run it on the accessors: cd $PTII; ant jshint.

Create a file that contains the .js files of interest

This uses $PTII/adm/bin/ptIItxtfiles

$PTII/adm/bin/ptIItxtfiles >& /tmp/f
cat /tmp/f | egrep '.js$' > /tmp/js
cat /tmp/js | egrep '(actor/lib/jjs|org/terraswarm/accessor)' | egrep -v '(browser/modules|cordova.js|duk*/examples|duktape-sys|common/modules|events.js|ecma_eventloop.js|jsdoc/scripts|modules/testing|node_modules|node/test|test/auto|setTimeout-nashorn.js|test/manual|test/mocha|util.js|vendors)' > /tmp/jss

JS Formatters

See JS Formatters for how we reformat code.

Copyrights

A bit of a nightmare, really.

This uses $PTII/adm/copyright/insertcopyright

  1. Temporarily $PTII/copyright.txt and remove the first two lines that mention Ptolemy and the Version and the last few lines about copyright.txt. We want the accessors to be standalone and not mention Ptolemy
  2. Run the script:
    cat /tmp/jss | xargs ~/ptII/adm/copyright/insertcopyright -p >& /tmp/copyright.out
      # Review the output and look for files where we are adding the Ptolemy copyright but the file already has a copyright.
      # Run without -p
    cat /tmp/jss | xargs ~/ptII/adm/copyright/insertcopyright -p >& /tmp/copyright2.out
  3. svn revert $PTII/copyright.txt

Add Trailing Newlines

This uses $PTII/adm/bin/addtrailingnl

# Run addtrailingnl without actually doing anything:
cat /tmp/jss | xargs $PTII/adm/bin/addtrailingnl -n
# Run addtrailingnl with adding the new lines:
cat /tmp/jss | xargs $PTII/adm/bin/addtrailingnl

Fix Common Problems

This uses $PTII/adm/bin/fixjs-files

cat /tmp/jss | xargs ~/ptII/adm/bin/fixjs-files -n >& /tmp/ff

# Review the contents of /tmp/ff, then run it for real:

cat /tmp/jss | xargs ~/ptII/adm/bin/fixjs-files  >& /tmp/ff

Remove Tabs

This uses $PTII/util/testsuite/rmtabs

cat /tmp/jss | xargs ~/ptII/util/testsuite/rmtabs -n

# Inspect the output and then run for real:
cat /tmp/jss | xargs ~/ptII/util/testsuite/rmtabs

Remove Trailing Spaces

This uses $PTII/util/testsuite/rmtrailingspace

cat /tmp/jss | xargs ~/ptII/util/testsuite/rmtrailingspace -n

# Inspect the output and then run for real:
cat /tmp/jss | xargs ~/ptII/util/testsuite/rmtrailingspace

@Author

At least all the accessors should have @author tags:

cat /tmp/jss | xargs grep @author | awk -F : '{print $1}' | sort > /tmp/jauthor
cat /tmp/jss | xargs grep @accessor | awk -F : '{print $1}' | sort > /tmp/jaccessor
comm -23 /tmp/jaccessor /tmp/jauthor

Add @author tags.

Use svn log to find out the original authors. Don't add people who have not edited the file or otherwise assisted in the creation of the file

@Version

We use @version $$Id$$. The $$ is so that we avoid interpreting the value as a number in Ptolemy II

cat /tmp/jss | xargs grep @version | awk -F : '{print $1}' | sort > /tmp/jversion
cat /tmp/jss | xargs grep @accessor | awk -F : '{print $1}' | sort > /tmp/jaccessor
comm -23 /tmp/jaccessor /tmp/jversion

Then add @version $$Id$$.

Check with:

cat /tmp/jss| xargs grep @version | grep -v '@version \$\$Id:.*\$\$'

SVN Properties

Make sure that svn:keywords and svn:eol-style are set.

Run it separately for the ptII repo and for the accessors repo.

This uses $PTII/adm/bin/svnpropcheck

cd $PTII
cat /tmp/jss | grep -v accessors/web| xargs $PTII/adm/bin/svnpropcheck > /tmp/props
grep keywords: /tmp/props | grep / | awk '{print $1}' | egrep -v '.xml$' > /tmp/keys
grep eolstyle: /tmp/props | grep / | awk '{print $1}' | egrep -v '.xml$'> /tmp/eols
cat /tmp/keys | xargs svn propset svn:keywords "Author Date Id Revision"
cat /tmp/eols | xargs svn propset svn:eol-style native
svn commit -m "Added keywords and eol-style properties" `cat /tmp/eols /tmp/keys`

cd $PTII/org/terraswarm/accessors/accessors/web
cat /tmp/jss | grep accessors/web | sed 's@./org/terraswarm/accessor/accessors/web/@@' | xargs $PTII/adm/bin/svnpropcheck > /tmp/props
grep keywords: /tmp/props | grep / | awk '{print $1}' | egrep -v '.xml$' > /tmp/keys
grep eolstyle: /tmp/props | grep / | awk '{print $1}' | egrep -v '.xml$'> /tmp/eols
cat /tmp/keys | xargs svn propset svn:keywords "Author Date Id Revision"
cat /tmp/eols | xargs svn propset svn:eol-style native
svn commit -m "Added keywords and eol-style properties" `cat /tmp/eols /tmp/keys`

See Also

Edit - History - Print - Recent Changes - Search
Page last modified on November 23, 2016, at 01:04 am