File drawCallState.ts
has 456 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { BaseState } from "../baseState";
import { WebGlConstants, WebGlConstantsByName, WebGlConstant, WebGlConstantsByValue } from "../../types/webglConstants";
import { DrawCallTextureInputState } from "./drawCallTextureInputState";
import { DrawCallUboInputState } from "./drawCallUboInputState";
import { ProgramRecompilerHelper } from "../../utils/programRecompilerHelper";
Function readFromContext
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
protected readFromContext(): void {
const program = this.context.getParameter(WebGlConstants.CURRENT_PROGRAM.value);
if (!program) {
return;
}
- 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
Function readFromContext
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected readFromContext(): void {
const program = this.context.getParameter(WebGlConstants.CURRENT_PROGRAM.value);
if (!program) {
return;
}
Function readUniformFromContext
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected readUniformFromContext(program: WebGLProgram, activeUniformIndex: number): {} {
const info = this.context.getActiveUniform(program, activeUniformIndex);
const location = this.context.getUniformLocation(program, info.name);
if (location) {
- 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
Function readFrameBufferFromContext
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected readFrameBufferFromContext(): any {
const frameBuffer = this.context.getParameter(WebGlConstants.FRAMEBUFFER_BINDING.value);
if (!frameBuffer) {
return 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
Function readFrameBufferAttachmentFromContext
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected readFrameBufferAttachmentFromContext(attachment: number): any {
const target = WebGlConstants.FRAMEBUFFER.value;
const type = this.context.getFramebufferAttachmentParameter(target, attachment, WebGlConstants.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.value);
if (type === WebGlConstants.NONE.value) {
return undefined;
- 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
Function readUniformFromContext
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected readUniformFromContext(program: WebGLProgram, activeUniformIndex: number): {} {
const info = this.context.getActiveUniform(program, activeUniformIndex);
const location = this.context.getUniformLocation(program, info.name);
if (location) {
Function readFrameBufferAttachmentFromContext
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected readFrameBufferAttachmentFromContext(attachment: number): any {
const target = WebGlConstants.FRAMEBUFFER.value;
const type = this.context.getFramebufferAttachmentParameter(target, attachment, WebGlConstants.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.value);
if (type === WebGlConstants.NONE.value) {
return undefined;
Function readTextureFromContext
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected readTextureFromContext(textureUnit: number, target: WebGlConstant): {} {
const activeTexture = this.context.getParameter(WebGlConstants.ACTIVE_TEXTURE.value);
this.context.activeTexture(WebGlConstants.TEXTURE0.value + textureUnit);
const textureState: any = {
Function readFrameBufferFromContext
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected readFrameBufferFromContext(): any {
const frameBuffer = this.context.getParameter(WebGlConstants.FRAMEBUFFER_BINDING.value);
if (!frameBuffer) {
return null;
}
Function appendBufferCustomData
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private appendBufferCustomData(state: any, buffer: WebGLBuffer) {
if (buffer) {
// Check for custom data.
const customData: IBufferRecorderData = (buffer as any).__SPECTOR_Object_CustomData;
if (customData) {
- 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
Function readAttributeFromContext
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected readAttributeFromContext(program: WebGLProgram, activeAttributeIndex: number): {} {
const info = this.context.getActiveAttrib(program, activeAttributeIndex);
const location = this.context.getAttribLocation(program, info.name);
if (location === -1) {
return {
Function readUniformsFromContextIntoState
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected readUniformsFromContextIntoState(program: WebGLProgram, uniformIndices: number[], uniformsState: any[], uniformBlockState: any[]) {
const context2 = this.context as WebGL2RenderingContext;
const typeValues = context2.getActiveUniforms(program, uniformIndices, WebGlConstants.UNIFORM_TYPE.value);
const sizes = context2.getActiveUniforms(program, uniformIndices, WebGlConstants.UNIFORM_SIZE.value);
Function readTextureFromContext
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected readTextureFromContext(textureUnit: number, target: WebGlConstant): {} {
const activeTexture = this.context.getParameter(WebGlConstants.ACTIVE_TEXTURE.value);
this.context.activeTexture(WebGlConstants.TEXTURE0.value + textureUnit);
const textureState: any = {
- 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
for (let j = 0; j < values.length; j++) {
uniformState.textures.push(this.readTextureFromContext(values[j].value, textureTarget));
}
Avoid deeply nested control flow statements. Open
if (value.length) {
value = Array.prototype.slice.call(value);
}
Avoid too many return
statements within this function. Open
return undefined;
Similar blocks of code found in 3 locations. Consider refactoring. Open
for (let i = 0; i < attributes; i++) {
const attributeState = this.readAttributeFromContext(program, i);
this.currentState.attributes.push(attributeState);
}
- 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 58.
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
for (let i = 0; i < transformFeedbacks; i++) {
const transformFeedbackState = this.readTransformFeedbackFromContext(program, i);
this.currentState.transformFeedbacks.push(transformFeedbackState);
}
- 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 58.
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
for (let i = 0; i < uniformBlocks; i++) {
const uniformBlockState = this.readUniformBlockFromContext(program, i);
this.currentState.uniformBlocks.push(uniformBlockState);
}
- 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 58.
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