Method processItem
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
private static final Media processItem(Desktop desktop, FileItem fi, boolean alwaysNative,
org.zkoss.zk.ui.sys.DiskFileItemFactory factory) throws IOException {
String name = getBaseName(fi);
if (name != null) {
//Not sure whether a name might contain ;jsessionid or similar
- 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
File AuMultipartUploader.java
has 552 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* AuMultipartUploader.java
Purpose:
Description:
Method processItem
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static final Media processItem(Desktop desktop, FileItem fi, boolean alwaysNative,
org.zkoss.zk.ui.sys.DiskFileItemFactory factory) throws IOException {
String name = getBaseName(fi);
if (name != null) {
//Not sure whether a name might contain ;jsessionid or similar
Method getCharset
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static String getCharset(String ctype) {
final String ctypelc = ctype.toLowerCase(java.util.Locale.ENGLISH);
for (int j = 0; (j = ctypelc.indexOf("charset", j)) >= 0; j += 7) {
int k = org.zkoss.lang.Strings.skipWhitespacesBackward(ctype, j - 1);
if (k < 0 || ctype.charAt(k) == ';') {
- 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 parseRequest
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static AuDecoder parseRequest(HttpServletRequest request, AuDecoder decoder) {
Map<String, Object> params = getFileuploadMetaPerWebApp(
WebApps.getCurrent());
AbstractFileUpload upload = newServletDiskFileUpload(new DiskFileItemFactory.Builder()
.setBufferSize((Integer) params.get("sizeThreadHold"))
- 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 parseRequest
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static AuDecoder parseRequest(HttpServletRequest request, AuDecoder decoder) {
Map<String, Object> params = getFileuploadMetaPerWebApp(
WebApps.getCurrent());
AbstractFileUpload upload = newServletDiskFileUpload(new DiskFileItemFactory.Builder()
.setBufferSize((Integer) params.get("sizeThreadHold"))
Method getFileuploadMetaPerWebApp
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static Map<String, Object> getFileuploadMetaPerWebApp(WebApp webApp) {
final Map<String, Object> params = new HashMap<String, Object>();
final Configuration conf = webApp.getConfiguration();
int thrs = conf.getFileSizeThreshold();
Method reconstructPacket
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static Object reconstructPacket(Object data, Map<String, Object> reqData, Desktop desktop,
Map<String, Object> params) throws IOException {
if (data instanceof List) {
int i = 0;
List listData = (List) data;
Method decode
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public List<AuRequest> decode(Object request, Desktop desktop) {
List<AuRequest> auRequests = _origin.decode(
new MultipartRequestWrapper((HttpServletRequest) request,
_queryData), desktop);
Method uploadErrorMessage
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static String uploadErrorMessage(Throwable ex) {
log.error("Failed to upload", ex);
if (ex instanceof FileUploadSizeException) {
try {
FileUploadSizeException fex = (FileUploadSizeException) ex;
Method reconstructPacket
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static Object reconstructPacket(Object data, Map<String, Object> reqData, Desktop desktop,
Map<String, Object> params) throws IOException {
if (data instanceof List) {
int i = 0;
List listData = (List) data;
- 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 getFileuploadMetaPerWebApp
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static Map<String, Object> getFileuploadMetaPerWebApp(WebApp webApp) {
final Map<String, Object> params = new HashMap<String, Object>();
final Configuration conf = webApp.getConfiguration();
int thrs = conf.getFileSizeThreshold();
- 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 getFileuploadMetaPerComp
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static Map<String, Object> getFileuploadMetaPerComp(Map<String, Object> params, Desktop desktop, String uuid) {
// stateless may not have comp at server.
Component comp = desktop.getComponentByUuidIfAny(uuid);
if (comp != null) {
- 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 fi.isInMemory() ? new AImage(name, fi.get()) : new AImage(name, fi.getInputStream());
Avoid too many return
statements within this method. Open
return fi.isInMemory() ? new AMedia(name, null, ctype, fi.get()) : new StreamMedia(name, null, ctype, fi);
Similar blocks of code found in 2 locations. Consider refactoring. Open
private static class StreamVideo extends AVideo {
private final FileItem _fi;
private String _format;
private String _ctype;
- 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 121.
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
private static class StreamAudio extends AAudio {
private final FileItem _fi;
private String _format;
private String _ctype;
- 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 121.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
} else if (ctypelc.startsWith("video/")) {
try {
return fi.isInMemory() ? new AVideo(name, fi.get()) : new StreamVideo(name, fi, ctypelc);
} catch (Throwable ex) {
if (log.isDebugEnabled())
- 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 52.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
} else if (ctypelc.startsWith("audio/")) {
try {
return fi.isInMemory() ? new AAudio(name, fi.get()) : new StreamAudio(name, fi, ctypelc);
} catch (Throwable ex) {
if (log.isDebugEnabled())
- 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 52.
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