提交 7d07fb0b 编写于 作者: S Skylot

chore: fix issues reported by lgtm.com

上级 99935bad
......@@ -2,6 +2,7 @@
[![Build Status](https://travis-ci.org/skylot/jadx.png?branch=master)](https://travis-ci.org/skylot/jadx)
[![Code Coverage](https://codecov.io/gh/skylot/jadx/branch/master/graph/badge.svg)](https://codecov.io/gh/skylot/jadx)
[![Alerts from lgtm.com](https://img.shields.io/lgtm/alerts/g/skylot/jadx.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/skylot/jadx/alerts/)
[![SonarQube Bugs](https://sonarcloud.io/api/project_badges/measure?project=jadx&metric=bugs)](https://sonarcloud.io/dashboard?id=jadx)
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
......
package jadx.core.clsp;
import java.util.Arrays;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -82,7 +84,7 @@ public class NMethod implements Comparable<NMethod> {
@Override
public String toString() {
return "NMethod{'" + shortId + '\''
+ ", argTypes=" + genericArgs
+ ", argTypes=" + Arrays.toString(genericArgs)
+ ", retType=" + retType
+ ", varArgs=" + varArgs
+ '}';
......
......@@ -193,7 +193,7 @@ public class JsonCodeGen {
jsonCodeLine.setSourceLine(lineMapping.get(line));
Object obj = annotations.get(new CodePosition(line, 0));
if (obj instanceof InsnNode) {
int offset = ((InsnNode) obj).getOffset();
long offset = ((InsnNode) obj).getOffset();
jsonCodeLine.setOffset("0x" + Long.toHexString(mthCodeOffset + offset * 2));
}
codeLines.add(jsonCodeLine);
......
......@@ -180,8 +180,11 @@ public class Utils {
if (len == 0) {
return Collections.emptyMap();
}
if (len % 2 != 0) {
throw new IllegalArgumentException("Incorrect arguments count: " + len);
}
Map<String, String> result = new HashMap<>(len / 2);
for (int i = 0; i < len; i += 2) {
for (int i = 0; i < len - 1; i += 2) {
result.put(parameters[i], parameters[i + 1]);
}
return Collections.unmodifiableMap(result);
......
......@@ -50,12 +50,12 @@ public class Res9patchStreamDecoder {
drawVLine(im2, w + 1, np.padTop + 1, h - np.padBottom);
int[] xDivs = np.xDivs;
for (int i = 0; i < xDivs.length; i += 2) {
for (int i = 0; i < xDivs.length - 1; i += 2) {
drawHLine(im2, 0, xDivs[i] + 1, xDivs[i + 1]);
}
int[] yDivs = np.yDivs;
for (int i = 0; i < yDivs.length; i += 2) {
for (int i = 0; i < yDivs.length - 1; i += 2) {
drawVLine(im2, 0, yDivs[i] + 1, yDivs[i + 1]);
}
......
......@@ -40,11 +40,12 @@ public class ValuesParser extends ParserConstants {
}
private static void decodeAndroid(RootNode root) throws IOException {
InputStream inputStream = new BufferedInputStream(ValuesParser.class.getResourceAsStream("/resources.arsc"));
ResTableParser androidParser = new ResTableParser(root);
androidParser.decode(inputStream);
androidStrings = androidParser.getStrings();
androidResMap = androidParser.getResStorage().getResourcesNames();
try (InputStream inputStream = new BufferedInputStream(ValuesParser.class.getResourceAsStream("/resources.arsc"))) {
ResTableParser androidParser = new ResTableParser(root);
androidParser.decode(inputStream);
androidStrings = androidParser.getStrings();
androidResMap = androidParser.getResStorage().getResourcesNames();
}
}
@Nullable
......
......@@ -13,6 +13,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
......@@ -924,12 +925,12 @@ public class MainWindow extends JFrame {
}
private void setEditorTheme(String editorThemePath) {
try {
editorTheme = Theme.load(getClass().getResourceAsStream(editorThemePath));
try (InputStream is = getClass().getResourceAsStream(editorThemePath)) {
editorTheme = Theme.load(is);
} catch (Exception e) {
LOG.error("Can't load editor theme from classpath: {}", editorThemePath);
try {
editorTheme = Theme.load(new FileInputStream(editorThemePath));
try (InputStream is = new FileInputStream(editorThemePath)) {
editorTheme = Theme.load(is);
} catch (Exception ex) {
LOG.error("Can't load editor theme from file: {}", editorThemePath);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册