| Conditions | 1 |
| Paths | 1 |
| Total Lines | 93 |
| Code Lines | 76 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 6 | public static function get() |
||
| 7 | { |
||
| 8 | $default_env=["LANG=en_US.UTF-8", "LANGUAGE=en_US:en", "LC_ALL=en_US.UTF-8"]; |
||
| 9 | return [ |
||
| 10 | 'c_lang_config' => [ |
||
| 11 | 'compile' => [ |
||
| 12 | 'src_name' => 'main.c', |
||
| 13 | 'exe_name' => 'main', |
||
| 14 | 'max_cpu_time' => 3000, |
||
| 15 | 'max_real_time' => 10000, |
||
| 16 | 'max_memory' => 1024 * 1024 * 1024, |
||
| 17 | 'compile_command' => '/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c99 -static {src_path} -lm -o {exe_path}', |
||
| 18 | ], |
||
| 19 | 'run' => [ |
||
| 20 | 'command' => '{exe_path}', |
||
| 21 | 'seccomp_rule' => 'c_cpp', |
||
| 22 | 'env' => $default_env |
||
| 23 | ] |
||
| 24 | ], |
||
| 25 | 'c_lang_spj_compile' => [ |
||
| 26 | 'src_name' => 'spj-{spj_version}.c', |
||
| 27 | 'exe_name' => 'spj-{spj_version}', |
||
| 28 | 'max_cpu_time' => 3000, |
||
| 29 | 'max_real_time' => 10000, |
||
| 30 | 'max_memory' => 1024 * 1024 * 1024, |
||
| 31 | 'compile_command' => '/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c99 {src_path} -lm -o {exe_path}' |
||
| 32 | ], |
||
| 33 | 'c_lang_spj_config' => [ |
||
| 34 | 'exe_name' => 'spj-{spj_version}', |
||
| 35 | 'command' => '{exe_path} {in_file_path} {user_out_file_path}', |
||
| 36 | 'seccomp_rule' => 'c_cpp', |
||
| 37 | 'env' => $default_env |
||
| 38 | ], |
||
| 39 | 'cpp_lang_config' => [ |
||
| 40 | 'name' => 'cpp', |
||
| 41 | 'compile' => [ |
||
| 42 | 'src_name' => 'main.cpp', |
||
| 43 | 'exe_name' => 'main', |
||
| 44 | 'max_cpu_time' => 3000, |
||
| 45 | 'max_real_time' => 10000, |
||
| 46 | 'max_memory' => 1024 * 1024 * 1024, |
||
| 47 | 'compile_command' => '/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c++11 {src_path} -lm -o {exe_path}', |
||
| 48 | ], |
||
| 49 | 'run' => [ |
||
| 50 | 'command' => '{exe_path}', |
||
| 51 | 'seccomp_rule' => 'c_cpp', |
||
| 52 | ] |
||
| 53 | ], |
||
| 54 | 'java_lang_config' => [ |
||
| 55 | 'name' => 'java', |
||
| 56 | 'compile' => [ |
||
| 57 | 'src_name' => 'Main.java', |
||
| 58 | 'exe_name' => 'Main', |
||
| 59 | 'max_cpu_time' => 3000, |
||
| 60 | 'max_real_time' => 10000, |
||
| 61 | 'max_memory' => -1, |
||
| 62 | 'compile_command' => '/usr/bin/javac {src_path} -d {exe_dir} -encoding UTF8' |
||
| 63 | ], |
||
| 64 | 'run' => [ |
||
| 65 | 'command' => '/usr/bin/java -cp {exe_dir} -Xss1M -Xms16M -Xmx{max_memory}k -Djava.security.manager -Djava.security.policy==/etc/java_policy -Djava.awt.headless=true Main', |
||
| 66 | 'seccomp_rule' => null, |
||
| 67 | 'env' => $default_env, |
||
| 68 | 'memory_limit_check_only' => 1 |
||
| 69 | ] |
||
| 70 | ], |
||
| 71 | 'py2_lang_config' => [ |
||
| 72 | 'compile' => [ |
||
| 73 | 'src_name' => 'solution.py', |
||
| 74 | 'exe_name' => 'solution.pyc', |
||
| 75 | 'max_cpu_time' => 3000, |
||
| 76 | 'max_real_time' => 10000, |
||
| 77 | 'max_memory' => 1024 * 1024 * 1024, |
||
| 78 | 'compile_command' => '/usr/bin/python -m py_compile {src_path}', |
||
| 79 | ], |
||
| 80 | 'run' => [ |
||
| 81 | 'command' => '/usr/bin/python {exe_path}', |
||
| 82 | 'seccomp_rule' => null, |
||
| 83 | 'env' => $default_env |
||
| 84 | ] |
||
| 85 | ], |
||
| 86 | 'py3_lang_config' => [ |
||
| 87 | 'compile' => [ |
||
| 88 | 'src_name' => 'solution.py', |
||
| 89 | 'exe_name' => '__pycache__/solution.cpython-35.pyc', |
||
| 90 | 'max_cpu_time' => 3000, |
||
| 91 | 'max_real_time' => 10000, |
||
| 92 | 'max_memory' => 1024 * 1024 * 1024, |
||
| 93 | 'compile_command' => '/usr/bin/python3 -m py_compile {src_path}', |
||
| 94 | ], |
||
| 95 | 'run' => [ |
||
| 96 | 'command' => '/usr/bin/python3 {exe_path}', |
||
| 97 | 'seccomp_rule' => 'general', |
||
| 98 | 'env' => array_merge(['MALLOC_ARENA_MAX=1'], $default_env) |
||
| 99 | ] |
||
| 104 |