Showing 1,345 of 1,345 total issues
File CurlOption.ts
has 1521 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Copyright (c) Jonathan Cardoso Machado. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
File Curl.ts
has 736 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Copyright (c) Jonathan Cardoso Machado. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
Function create
has 222 lines of code (exceeds 25 allowed). Consider refactoring. Open
const create = (defaultOptions: CurlyOptions = {}): CurlyFunction => {
function curly<ResultData>(
url: string,
options: CurlyOptions = {},
): Promise<CurlyResult<ResultData>> {
Function create
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
const create = (defaultOptions: CurlyOptions = {}): CurlyFunction => {
function curly<ResultData>(
url: string,
options: CurlyOptions = {},
): Promise<CurlyResult<ResultData>> {
- 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 curly
has 160 lines of code (exceeds 25 allowed). Consider refactoring. Open
function curly<ResultData>(
url: string,
options: CurlyOptions = {},
): Promise<CurlyResult<ResultData>> {
const curlHandle = new Curl()
Function onConnected
has 144 lines of code (exceeds 25 allowed). Consider refactoring. Open
const onConnected = (easyHandle) => {
try {
state.connectionOpen = true
// We are using this callback to listen for changes in the socket.
Function run
has 124 lines of code (exceeds 25 allowed). Consider refactoring. Open
const run = async () => {
const curlOptionsFilePath = path.resolve(
__dirname,
'../lib/generated/CurlOption.ts',
)
Function createAndPerformAndCloseCurlHandlesMultiTest
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
function createAndPerformAndCloseCurlHandlesMultiTest() {
let i = AMOUNT_ITERATIONS_PER_RUN
let toClose: Curl[] = []
let toPerform: Curl[] = []
let currentlyPerforming: Curl[] = []
- 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 createAndPerformAndCloseCurlHandlesMultiTest
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createAndPerformAndCloseCurlHandlesMultiTest() {
let i = AMOUNT_ITERATIONS_PER_RUN
let toClose: Curl[] = []
let toPerform: Curl[] = []
let currentlyPerforming: Curl[] = []
File curly.ts
has 308 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Copyright (c) Jonathan Cardoso Machado. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
Curl
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class Curl extends EventEmitter {
/**
* Calls [`curl_global_init()`](http://curl.haxx.se/libcurl/c/curl_global_init.html).
*
* For **flags** see the the enum {@link CurlGlobalInit | `CurlGlobalInit`}.
File 21-websockets-client.js
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Copyright (c) Jonathan Cardoso Machado. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
Function setUploadStream
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
setUploadStream(stream: Readable | null) {
if (!stream) {
if (this.readFunctionStream) {
this.cleanupReadFunctionStreamEvents()
this.readFunctionStream = null
Function defaultWriteFunctionStreamBased
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected defaultWriteFunctionStreamBased(
chunk: Buffer,
size: number,
nmemb: number,
) {
Function run
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function run() {
return new Promise<void>((resolve) => {
while (i--) {
console.log('creating handler')
Function createSetOptOverloads
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createSetOptOverloads = (filePath, setOptReturnType = 'CurlCode') => {
let easyClassSetOptOverloadsData = [
getSetOptDefinition(
'DataCallbackOptions',
optionKindValueMap.dataCallback,
Function readFrame
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
function readFrame(frame) {
const firstByte = frame.readUInt8(0)
const fin = ((firstByte & 0b10000000) === 0b10000000) | 0
const rs1 = firstByte & 0b01000000
Similar blocks of code found in 2 locations. Consider refactoring. Open
const constantsObj = [
`
/**
* @public
*/
- 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 70.
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
? [
`export const ${variableName}CamelCaseMap = {`,
...constants.map(
(option) =>
`${getDescriptionCommentForOption(option)}${
- 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 70.
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
Function connection
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
wss.on('connection', function connection(ws) {
let pingTimeout = null
lastSocket = ws
ws.on('message', function (message) {
console.log('ws.on - message:', message)