Skip to content

Commit

Permalink
Cleanup and Formatting applied
Browse files Browse the repository at this point in the history
  • Loading branch information
rajatkhanna1994 committed Apr 18, 2018
1 parent 5c8bfba commit 90cb3e2
Show file tree
Hide file tree
Showing 2,137 changed files with 226,291 additions and 231,910 deletions.
61 changes: 61 additions & 0 deletions codingstyle/EclipseCodeCleanup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="2">
<profile kind="CleanUpProfile" name="eclipse-cs soot" version="2">
<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.organize_imports" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="false"/>
<setting id="cleanup.format_source_code_changes_only" value="false"/>
<setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_generated_serial_version_id" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class" value="false"/>
<setting id="cleanup.remove_redundant_type_arguments" value="false"/>
<setting id="cleanup.remove_unused_imports" value="false"/>
<setting id="cleanup.insert_inferred_type_arguments" value="false"/>
<setting id="cleanup.make_private_fields_final" value="true"/>
<setting id="cleanup.use_lambda" value="true"/>
<setting id="cleanup.always_use_blocks" value="true"/>
<setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="true"/>
<setting id="cleanup.sort_members_all" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces_all" value="true"/>
<setting id="cleanup.add_missing_annotations" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_field_access" value="false"/>
<setting id="cleanup.make_parameters_final" value="false"/>
<setting id="cleanup.sort_members" value="false"/>
<setting id="cleanup.remove_private_constructors" value="true"/>
<setting id="cleanup.always_use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.remove_unused_local_variables" value="false"/>
<setting id="cleanup.convert_to_enhanced_for_loop" value="false"/>
<setting id="cleanup.remove_unused_private_fields" value="true"/>
<setting id="cleanup.never_use_blocks" value="false"/>
<setting id="cleanup.add_missing_deprecated_annotations" value="false"/>
<setting id="cleanup.use_this_for_non_static_field_access" value="false"/>
<setting id="cleanup.remove_unnecessary_nls_tags" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="false"/>
<setting id="cleanup.add_missing_nls_tags" value="false"/>
<setting id="cleanup.remove_unnecessary_casts" value="false"/>
<setting id="cleanup.use_blocks_only_for_return_and_throw" value="false"/>
<setting id="cleanup.format_source_code" value="false"/>
<setting id="cleanup.convert_functional_interfaces" value="false"/>
<setting id="cleanup.add_default_serial_version_id" value="true"/>
<setting id="cleanup.remove_unused_private_methods" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces" value="false"/>
<setting id="cleanup.make_type_abstract_if_missing_method" value="false"/>
<setting id="cleanup.add_serial_version_id" value="false"/>
<setting id="cleanup.use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="true"/>
<setting id="cleanup.use_anonymous_class_creation" value="false"/>
<setting id="cleanup.add_missing_override_annotations_interface_methods" value="false"/>
<setting id="cleanup.remove_unused_private_members" value="false"/>
<setting id="cleanup.make_local_variable_final" value="true"/>
<setting id="cleanup.add_missing_methods" value="false"/>
<setting id="cleanup.never_use_parentheses_in_expressions" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.add_missing_override_annotations" value="false"/>
<setting id="cleanup.use_blocks" value="true"/>
<setting id="cleanup.make_variable_declarations_final" value="false"/>
<setting id="cleanup.correct_indentation" value="false"/>
<setting id="cleanup.remove_unused_private_types" value="true"/>
</profile>
</profiles>
315 changes: 315 additions & 0 deletions codingstyle/SootEclipseChecks.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions codingstyle/SootEclipseImport.importorder
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#Organize Import Order
#Sun Apr 15 15:42:23 CEST 2018
6=
5=org
4=javax
3=java
2=heros
1=com
0=\#
7=soot
9 changes: 9 additions & 0 deletions codingstyle/checkstyle_supressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<suppress files="[/\\]generated[/\\]" checks=".*"/>
</suppressions>
Binary file added codingstyle/google-java-format-1.5-all-deps.jar
Binary file not shown.
62 changes: 62 additions & 0 deletions codingstyle/pre-commit.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
# Auto format changed java files using google-java-format.
# To install, copy this file into $repo/.git/hooks and remove the .template extension.
echo "Running auto-formatter for any changed Java files"
echo "(formatting changes will be automatically added to your commit)"

# Grab root directory to help with creating an absolute path for changed files.
root_dir="$(git rev-parse --show-toplevel)"
[ -d "${root_dir}" ] || exit 1

jar_path="formatting/google-java-format-1.5-all-deps.jar"
formatter_jar="${root_dir}/${jar_path}"

# To avoid any unexpected behavior, we need to "stash" any unstaged changes.
# We could use "git stash" but the situation gets complicated because we
# need to make additional changes with the formatter.
# Here's how we could do this if we didn't need to make additional changes:
# http://stackoverflow.com/a/20480591
# But since we do, we follow the same general pattern as the "pre-commit" lib:
# https://github.com/pre-commit/pre-commit/blob/master/pre_commit/staged_files_only.py#L15
# Basically we just diff the unstaged changes, store the patch, and apply it later.
# In the future, we should consider migrating to using that library.
staged_changes_diff=$(mktemp -t format_patch)
git diff --ignore-submodules --binary --exit-code --no-color > $staged_changes_diff
if [ $? -eq 1 ]; then
echo "Found unstaged changes, storing in ${staged_changes_diff}"
echo "Clearing unstaged changes for formatting, will restore after formatting."
git checkout -- ${root_dir}
stored_staged_changes=true
else
stored_staged_changes=false
fi

formatter_cmd="java -jar ${formatter_jar}"
# Format file in-place and use 4-space style (AOSP).
# TODO add --aosp flag if you want 4-space style.
formatter_args="--replace"

# filter=ACMR shows only added, changed, modified, or renamed files.
# Get only java files and prepend the root directory to make the paths absolute.
changed_java_files=($(git diff --cached --name-only --diff-filter=ACMR \
| grep ".*java$" \
| sed "s:^:${root_dir}/:"))
# If we have changed java files, format them!
if [ ${#changed_java_files[@]} -gt 0 ]; then
# Do the formatting, stage the changes, and print out which files were changed.
eval ${formatter_cmd} ${formatter_args} "${changed_java_files[@]}"
git add "${changed_java_files[@]}"
echo "${changed_java_files[@]}" | xargs basename | sed "s/^/ Formatting: /"
fi

echo "Finished formatting."

if $stored_staged_changes ; then
echo "Restoring unstaged changes"
git apply "${staged_changes_diff}"

if [ $? -eq 1 ]; then
echo "Shoot! We failed to re-apply your unstaged changes."
echo "The patch for these changes is preserved at ${staged_changes_diff}"
fi
fi
Loading

0 comments on commit 90cb3e2

Please sign in to comment.