Showing 1,345 of 1,345 total issues
Function onEnd
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
onEnd() {
const isStreamResponse = !!(this.features & CurlFeature.StreamResponse)
const isDataStorageEnabled =
!isStreamResponse && !(this.features & CurlFeature.NoDataStorage)
const isDataParsingEnabled =
Function sendProtoBufMessage
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function sendProtoBufMessage(url, message) {
const curl = new Curl()
curl.setOpt('URL', url)
// enable if you want to see even more debug info
// curl.setOpt('VERBOSE', true)
Function defaultWriteFunctionStreamBased
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected defaultWriteFunctionStreamBased(
chunk: Buffer,
size: number,
nmemb: number,
) {
- 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 parseHeaders
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function parseHeaders(headersString: string): HeaderInfo[] {
const headers = headersString.split(/\r?\n|\r/g)
const len = headers.length
const result = []
- 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 readFrame
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function readFrame(frame) {
const firstByte = frame.readUInt8(0)
const fin = ((firstByte & 0b10000000) === 0b10000000) | 0
const rs1 = firstByte & 0b01000000
- 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 cb
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function cb(code) {
const { data } = this
const now = Date.now()
let shouldWrite = false
Function attachPackageToRelease
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function attachPackageToRelease(pckg, release) {
const packagePath = path.resolve(pckg)
if (!fs.existsSync(packagePath)) {
throw new Error(
Function sendData
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function sendData(handle, buffer) {
let bufferToSend = buffer
while (bufferToSend) {
const { code, bytesSent } = handle.send(bufferToSend)
- 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 receiveData
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function receiveData(handle, bufferSize = 32 * 1024) {
const buffers = []
// eslint-disable-next-line no-constant-condition
while (true) {
- 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 fileIsComing
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fileIsComing(fileInfo, remains) {
console.log(
util.format(
'Remaining entries: %d / Current: %s / Size: %d - ',
remains,
Function run
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const run = async () => {
try {
// there are many ways to use the curly.* functions
let response = null
Function removePackageFromRelease
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function removePackageFromRelease(packageToDelete, release) {
const packageToDeleteName = path.basename(packageToDelete)
let found = false
Function createAndCloseCurlHandlesTest
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createAndCloseCurlHandlesTest() {
let i = 0
const shouldClose = iteration++ % 2
const postData = [
{
Function parseHeaders
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function parseHeaders(headersString: string): HeaderInfo[] {
const headers = headersString.split(/\r?\n|\r/g)
const len = headers.length
const result = []
Function run
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const run = async () => {
// the files we are going to read and write
const uploadFilePath = './100mb.in.data.zip'
const downloadFilePath = './100mb.out.data.zip'
Function retrieveWinDeps
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const retrieveWinDeps = async () => {
const fileExists = fs.existsSync(fileWithDepsTag)
if (!fileExists && !envCurlForWindowsDepsVersionTag) {
console.error(
Function packFrame
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function packFrame(data, type) {
const length = data.length
// initial offset is 6
// 1 byte for the first part (fin, rsvn, opcode)
// 1 byte for the mask and payload length(first part)
Function debugCallback
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const debugCallback = (infoType, content) => {
let text = ''
const contentString = content.toString('utf8')
Similar blocks of code found in 2 locations. Consider refactoring. Open
handle.setOpt(Curl.option.WRITEFUNCTION, function (buf, size, nmemb) {
console.log('WRITEFUNCTION: ')
console.log(arguments)
return size * nmemb
- 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 56.
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
handle.setOpt(Curl.option.HEADERFUNCTION, function (buf, size, nmemb) {
console.log('HEADERFUNCTION: ')
console.log(arguments)
return size * nmemb
- 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 56.
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