Skip to content

Commit 8593333

Browse files
authored
Merge pull request #102 from PLUS-POSTECH/general-improvements
General improvements
2 parents 45ae713 + 6c11e2d commit 8593333

28 files changed

+706
-545
lines changed

Cargo.lock

Lines changed: 111 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
[package]
22
name = "soma"
33
version = "0.1.0"
4-
authors = ["Yechan Bae <qwazpia@gmail.com>", "Kangsu Kim <pica744@gmail.com>"]
54
edition = "2018"
5+
authors = ["Yechan Bae <qwazpia@gmail.com>", "Kangsu Kim <pica744@gmail.com>"]
6+
license = "MIT OR Apache-2.0"
7+
description = "Your one-stop CTF problem management tool"
8+
repository = "https://github.com/PLUS-POSTECH/soma"
9+
keywords = ["ctf", "hacking"]
10+
categories = ["command-line-utilities", "config"]
11+
readme = "README.md"
612

713

814
[dependencies]
9-
bollard = "0.1.3"
15+
bollard = "0.2.0"
1016
clap = "~2.32.0"
11-
crossterm = "0.5.5"
17+
crossterm = "0.6.0"
1218
dirs = "1.0.4"
1319
failure = "0.1.5"
1420
flate2 = "1.0.6"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ Soma team is hoping to ship it in the first quarter of 2019.
8080

8181
* Install Rust stable toolchain.
8282
* Install `openssl` (Required by `openssl-sys` crate).
83-
* Install `rustfmt`.
84-
* `rustup component add rustfmt`
83+
* Install `clippy` and `rustfmt`.
84+
* `rustup component add clippy rustfmt`
8585
* Copy files in `hooks` directory to `.git/hooks`.
8686

8787

azure-pipelines.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ resources:
1010
image: rust:latest
1111

1212
jobs:
13-
- job: style_check
14-
displayName: Code Style Check
13+
- job: quality_check
14+
displayName: Code Quality Check
1515
pool:
1616
vmImage: 'ubuntu-16.04'
1717
container: rust
1818
steps:
19-
- script: rustup component add rustfmt
20-
displayName: 'Install rustfmt'
19+
- script: rustup component add clippy rustfmt
20+
displayName: 'Install Prerequisites'
2121
- script: cargo fmt --all -- --check
22-
displayName: 'Check code style'
22+
displayName: 'Check Formatting'
23+
- script: cargo clippy --all-targets --all-features -- -D warnings
24+
displayName: 'Run Lint'
2325

2426
- job: linux_build
2527
displayName: Linux Build

hooks/pre-commit

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

33
# Copyright 2016 Google Inc. All Rights Reserved.
4-
# Modified by PLUS Owl team
4+
# Modified by PLUS Soma team
55
#
66
# Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
77
# This file may not be copied, modified, or distributed except according to those terms.
88

99
#
10-
# Pre-commit hook for the tarpc repository. To use this hook, copy it to .git/hooks in your
10+
# Pre-commit hook for the Soma repository. To use this hook, copy it to .git/hooks in your
1111
# repository root.
1212
#
1313
# This precommit checks the following:
@@ -59,25 +59,20 @@ else
5959
fi
6060

6161
printf "${PREFIX} Checking for rustfmt ... "
62-
command -v cargo fmt &>/dev/null
63-
if [ $? == 0 ]; then
64-
printf "${SUCCESS}\n"
65-
else
62+
command -v cargo-fmt &>/dev/null
63+
if [ $? != 0 ]; then
6664
printf "${FAILURE}\n"
6765
exit 1
66+
else
67+
printf "${SUCCESS}\n"
6868
fi
6969

7070
# Just check that running rustfmt doesn't do anything to the file. I do this instead of
7171
# modifying the file because I don't want to mess with the developer's index, which may
7272
# not only contain discrete files.
7373
printf "${PREFIX} Checking formatting ... "
74-
FMTRESULT=0
7574
diff="$(cargo fmt --all -- --check)"
76-
if grep --quiet "at line" <<< "$diff"; then
77-
FMTRESULT=1
78-
fi
79-
80-
if [ ${FMTRESULT} != 0 ]; then
75+
if [ $? != 0 ]; then
8176
FAILED=1
8277
printf "${FAILURE}\n"
8378
echo "$diff"

hooks/pre-push

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 Google Inc. All Rights Reserved.
4+
# Modified by PLUS Soma team
5+
#
6+
# Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
7+
# This file may not be copied, modified, or distributed except according to those terms.
8+
9+
#
10+
# Pre-push hook for the Soma repository. To use this hook, copy it to .git/hooks in your
11+
# repository root.
12+
#
13+
# This prepush checks the following:
14+
# 1. clippy is installed
15+
# 2. clippy suggests nothing on code
16+
17+
RED='\033[0;31m'
18+
GREEN='\033[0;32m'
19+
YELLOW='\033[0;33m'
20+
NC='\033[0m' # No Color
21+
22+
PREFIX="${GREEN}[PREPUSH]${NC}"
23+
FAILURE="${RED}FAILED${NC}"
24+
WARNING="${RED}[WARNING]${NC}"
25+
SKIPPED="${YELLOW}SKIPPED${NC}"
26+
SUCCESS="${GREEN}ok${NC}"
27+
28+
FAILED=0
29+
30+
printf "${PREFIX} Checking for clippy ... "
31+
command -v cargo-clippy &>/dev/null
32+
if [ $? != 0 ]; then
33+
printf "${FAILURE}\n"
34+
exit 1
35+
else
36+
printf "${SUCCESS}\n"
37+
fi
38+
39+
printf "${PREFIX} Check lint ... "
40+
lint_output="$(cargo clippy --all-targets --all-features -- -D warnings)"
41+
if [ $? != 0 ]; then
42+
FAILED=1
43+
printf "${FAILURE}\n"
44+
echo "${lint_output}"
45+
else
46+
printf "${SUCCESS}\n"
47+
fi
48+
49+
exit ${FAILED}

src/bin/soma/commands/clean.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ impl SomaCommand for CleanCommand {
3030

3131
fn handle_match(
3232
&self,
33-
mut env: Environment<impl Connect, impl Printer>,
33+
env: Environment<impl Connect, impl Printer>,
3434
matches: &ArgMatches,
3535
) -> SomaResult<()> {
3636
clean(
37-
&mut env,
37+
&env,
3838
matches.value_of("problem").unwrap(),
3939
&mut default_runtime(),
4040
)

src/bin/soma/commands/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl SomaCommand for ListCommand {
2929
) -> SomaResult<()> {
3030
let mut repo_iter = env.repo_manager().list_repo().peekable();
3131

32-
if let None = repo_iter.peek() {
32+
if repo_iter.peek().is_none() {
3333
env.printer().write_line("No repository was added.");
3434
} else {
3535
for repository in repo_iter {

src/bin/soma/commands/stop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ impl SomaCommand for StopCommand {
3030

3131
fn handle_match(
3232
&self,
33-
mut env: Environment<impl Connect, impl Printer>,
33+
env: Environment<impl Connect, impl Printer>,
3434
matches: &ArgMatches,
3535
) -> SomaResult<()> {
3636
stop(
37-
&mut env,
37+
&env,
3838
matches.value_of("problem").unwrap(),
3939
&mut default_runtime(),
4040
)

src/bin/soma/terminal_printer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crossterm::terminal::ClearType;
2-
use crossterm::{cursor, terminal, Terminal, TerminalCursor};
1+
use crossterm::{cursor, terminal, ClearType, Terminal, TerminalCursor};
32

43
use soma::prelude::*;
54
use soma::Printer;

0 commit comments

Comments
 (0)