Showing 46 of 148 total issues
Method initEngine
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public void initEngine(Model model, HardwareConfig hardwareConfig) {
if (!isInit) {
synchronized (this) {
if (!isInit) {
initLogger(false, false, false);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method onMessage
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
suspend fun onMessage(event: GroupMessageEvent) {
when(event.message.getPlainText()) {
"${COMMAND_PREFIX}摸鱼", "${COMMAND_PREFIX}摸鱼!", "${COMMAND_PREFIX}摸鱼.",
"${COMMAND_PREFIX}摸鱼!", "${COMMAND_PREFIX}摸鱼。" -> {
if (ModuleStateConfig.moyu) {
Method copyFileFromJar
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static synchronized void copyFileFromJar(String filePath, String aimDir, boolean load, boolean deleteOnExit) throws IOException {
// 获取文件名并校验
String[] parts = filePath.split("/");
String filename = (parts.length > 1) ? parts[parts.length - 1] : null;
Method resolveGameType
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
fun resolveGameType(gametype: String): String {
return when (gametype) {
"QUAKECRAFT" -> "Quake"
"WALLS" -> "Walls"
"PAINTBALL" -> "Paintball"
Method findLibLoader
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static LibraryLoader findLibLoader(String engine) {
Properties props = new Properties();
try {
props.load(new StringReader(loaders));
Method onPush
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
suspend fun onPush(event: JSONObject) {
val repo = event.getJSONObject("repository").getString("full_name")
event.getJSONArray("commits").forEach { rawcommit ->
val commit = rawcommit as JSONObject
val author = commit.getJSONObject("author")
Method loadFileIfNeeded
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SneakyThrows
public static void loadFileIfNeeded(Model model) {
String modelType = model.getModelType();
if (InferenceEngine.nativeLoader == null && (isLibraryLoaded.compareAndSet(false, true))) {
synchronized (InferenceEngine.class) {
Method unFormatted
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
fun String.unFormatted(): String {
return this.replace("§0", "")
.replace("§1", "")
.replace("§2", "")
.replace("§3", "")
Method trainOn
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Pair<Integer, Integer> trainOn(DataSet dataSet, double learningRate) {
int t = 0, f = 0;
if (!(layers[layers.length - 1] instanceof JudgeLayer)) {
throw new RuntimeException("Last layer is not output layer");
}
Method trainAndGetWA
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public List<DataEntry> trainAndGetWA(DataSet dataSet, double learningRate) {
LinkedList<DataEntry> entries = new LinkedList<>();
if (!(layers[layers.length - 1] instanceof JudgeLayer)) {
throw new RuntimeException("Last layer is not output layer");
}
Method parseLine
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static AbstractLayer parseLine(String line) {
String[] tokens = line.split(" ");
switch (tokens[0]) {
case "D":
int inputSize = Integer.parseInt(tokens[1]);
Method onNudge
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
suspend fun onNudge(e: NudgeEvent) {
val from = e.from as User
val timestamp = Instant.now().epochSecond
if (e.target != e.bot) return // 只处理对机器人的戳一戳
Method detectInput
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
OcrInput input, int padding, int maxSideLen,
float boxScoreThresh, float boxThresh,
float unClipRatio, boolean doAngle, boolean mostAngle
Method detect
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
String input, int padding, int maxSideLen,
float boxScoreThresh, float boxThresh,
float unClipRatio, boolean doAngle, boolean mostAngle
Method testOn
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public Pair<Integer, Integer> testOn(DataSet dataSet) {
int t = 0, f = 0;
for (DataEntry dataEntry : dataSet.split) {
layers[0].input = dataEntry.values;
for (int i = 0; i < layers.length; i++) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if (CharUtils.isEnglishLetter(ch)) {
builder.append(ch);
i = until;
}
else break;
Method testAndGetWA
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public List<DataEntry> testAndGetWA(DataSet dataSet) {
LinkedList<DataEntry> entries = new LinkedList<>();
for (DataEntry dataEntry : dataSet.split) {
layers[0].input = dataEntry.values;
for (int i = 0; i < layers.length; i++) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if (s.contains(substring) || substring.contains(s)) {
updateVocab(s);
break;
}
Method initModels
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public native boolean initModels(String modelsDir, String detName, String clsName, String recName, String keysName);
Method equals
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TextBlock textBlock = (TextBlock) o;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"