File ClassWebResource.java
has 527 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* ClassWebResource.java
Purpose:
Description:
Method web0
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
private void web0(HttpServletRequest request, HttpServletResponse response, String pi, String ext)
throws ServletException, IOException {
if (ext != null) {
//Invoke the resource processor (Extendlet)
final Extendlet extlet = getExtendlet(ext);
- 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
ClassWebResource
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
public class ClassWebResource {
private static final Logger log = LoggerFactory.getLogger(ClassWebResource.class);
private final ServletContext _ctx;
/** mapping URI including PATH_PREFIX. */
Method web0
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void web0(HttpServletRequest request, HttpServletResponse response, String pi, String ext)
throws ServletException, IOException {
if (ext != null) {
//Invoke the resource processor (Extendlet)
final Extendlet extlet = getExtendlet(ext);
Method encodeURL
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public String encodeURL(ServletRequest request, ServletResponse response, String uri)
throws ServletException, UnsupportedEncodingException {
uri = Servlets.locate(_ctx, request, uri, getLocator()); //resolves "*"
uri = (_encURLPrefix != null ? _mappingURI + _encURLPrefix : _mappingURI) + uri; //prefix with mapping
- 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 encodeURL
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public String encodeURL(ServletRequest request, ServletResponse response, String uri)
throws ServletException, UnsupportedEncodingException {
uri = Servlets.locate(_ctx, request, uri, getLocator()); //resolves "*"
uri = (_encURLPrefix != null ? _mappingURI + _encURLPrefix : _mappingURI) + uri; //prefix with mapping
Method getFilters
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public Filter[] getFilters(String ext, int flag) {
if (ext == null)
return null;
ext = ext.toLowerCase(java.util.Locale.ENGLISH);
- 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 modifyPath
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public String modifyPath(String path) throws UnsupportedEncodingException {
if (path.startsWith(ZVER)) {
final int j = path.indexOf('/', ZVER.length());
if (j >= 0)
path = path.substring(j);
- 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 encodeRedirectURL
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public String encodeRedirectURL(HttpServletRequest request, HttpServletResponse response, String uri,
Map params, int mode) {
Method getExtendlet
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public Extendlet getExtendlet(String ext, boolean lookup) {
if (ext == null)
return null;
ext = ext.toLowerCase(java.util.Locale.ENGLISH);
- 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 addFilter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public void addFilter(String ext, Filter filter, int flags) {
if (ext == null || filter == null)
throw new IllegalArgumentException("null");
filter.init(new FilterConfig() {
- 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 rmFilter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static boolean rmFilter(Map<String, FastReadArray<Filter>> filters, String ext, Filter filter) {
FastReadArray<Filter> ary = filters.get(ext);
if (ary != null && ary.remove(filter)) {
if (ary.isEmpty())
ary = filters.remove(ext);
- 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 include
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public void include(HttpServletRequest request, HttpServletResponse response, String uri, Map params)
throws ServletException, IOException {
//Note: it is caller's job to convert related path to ~./
if (uri.startsWith("~./") && uri.indexOf('?') < 0 && isDirectInclude(uri)) {
Object old = request.getAttribute(Attributes.ARG);
- 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 getResourceAsStream
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public InputStream getResourceAsStream(String uri) {
uri = fixURI(uri);
if (_extraloc != null) {
final InputStream is = _extraloc.getResourceAsStream(uri);
if (is != 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
Method removeFilter
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public boolean removeFilter(String ext, Filter filter, int flags) {
if (ext == null || filter == null)
return false;
ext = ext.toLowerCase(java.util.Locale.ENGLISH);
- 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 getResource
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public URL getResource(String uri) {
uri = fixURI(uri);
if (_extraloc != null) {
final URL url = _extraloc.getResource(uri);
if (url != 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
public URL getResource(String uri) {
uri = fixURI(uri);
if (_extraloc != null) {
final URL url = _extraloc.getResource(uri);
if (url != null)
- 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 114.
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
public InputStream getResourceAsStream(String uri) {
uri = fixURI(uri);
if (_extraloc != null) {
final InputStream is = _extraloc.getResourceAsStream(uri);
if (is != null)
- 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 114.
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