From 4d97032c11b8c65936e53a61607d4522d45a29ea Mon Sep 17 00:00:00 2001
From: zxchen <czxczf@gmail.com>
Date: Fri, 11 Dec 2020 00:57:04 +0100
Subject: [PATCH] Add .editorconfig and format code style (#115)

* Add .editorconfig and format code style

* Enforce line length to be smaller than 100
---
 .editorconfig       | 22 ++++++++++++++++++++++
 node/src/service.rs |  6 +++---
 runtime/src/lib.rs  | 21 ++++++++++++++-------
 scripts/init.sh     |  6 +++---
 4 files changed, 42 insertions(+), 13 deletions(-)
 create mode 100644 .editorconfig

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..4a9b13969
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,22 @@
+root = true
+[*.rs]
+indent_style=tab
+indent_size=tab
+tab_width=4
+end_of_line=lf
+charset=utf-8
+trim_trailing_whitespace=true
+max_line_length=100
+insert_final_newline=true
+
+[*.yml]
+indent_style=space
+indent_size=2
+tab_width=8
+end_of_line=lf
+
+[*.sh]
+indent_style=space
+indent_size=2
+tab_width=8
+end_of_line=lf
diff --git a/node/src/service.rs b/node/src/service.rs
index 3de31dc61..dff7a3988 100644
--- a/node/src/service.rs
+++ b/node/src/service.rs
@@ -295,9 +295,9 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
 		network,
 		network_status_sinks,
 		system_rpc_tx,
-	 })?;
+	})?;
 
-	 network_starter.start_network();
+	network_starter.start_network();
 
-	 Ok(task_manager)
+	Ok(task_manager)
 }
diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs
index 1e84ad7f0..9d36900c2 100644
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -349,7 +349,8 @@ impl_runtime_apis! {
 			Executive::finalize_block()
 		}
 
-		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
+		fn inherent_extrinsics(data: sp_inherents::InherentData) ->
+			Vec<<Block as BlockT>::Extrinsic> {
 			data.create_extrinsics()
 		}
 
@@ -434,7 +435,8 @@ impl_runtime_apis! {
 		}
 	}
 
-	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
+	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+		for Runtime {
 		fn query_info(
 			uxt: <Block as BlockT>::Extrinsic,
 			len: u32,
@@ -455,15 +457,20 @@ impl_runtime_apis! {
 
 			let whitelist: Vec<TrackedStorageKey> = vec![
 				// Block Number
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
+				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac")
+					.to_vec().into(),
 				// Total Issuance
-				hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
+				hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80")
+					.to_vec().into(),
 				// Execution Phase
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
+				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a")
+					.to_vec().into(),
 				// Event Count
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
+				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850")
+					.to_vec().into(),
 				// System Events
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
+				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7")
+					.to_vec().into(),
 			];
 
 			let mut batches = Vec::<BenchmarkBatch>::new();
diff --git a/scripts/init.sh b/scripts/init.sh
index 5020ec253..92f6f2e51 100755
--- a/scripts/init.sh
+++ b/scripts/init.sh
@@ -5,9 +5,9 @@ set -e
 echo "*** Initializing WASM build environment"
 
 if [ -z $CI_PROJECT_NAME ] ; then
-   rustup update nightly
-   rustup update nightly-2020-10-05
-   rustup update stable
+    rustup update nightly
+    rustup update nightly-2020-10-05
+    rustup update stable
 fi
 
 rustup target add wasm32-unknown-unknown --toolchain nightly
-- 
GitLab