packages/compile-solidity/src/compilerSupplier/loadingStrategies/VersionRange.ts
File VersionRange.ts
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import debugModule from "debug";
const debug = debugModule("compile:compilerSupplier");
import requireFromString from "require-from-string";
Function getSolcFromCacheOrUrl
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getSolcFromCacheOrUrl(versionConstraint: string, index: number = 0) {
// go through all sources (compilerRoots) trying to locate a
// suitable version of the Solidity compiler
const { compilerRoots, events } = this.config;
if (!compilerRoots || compilerRoots.length === 0) {
Function list
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async list(index = 0) {
if (index >= this.config.compilerRoots!.length) {
throw new Error(
`Failed to fetch the list of Solidity compilers from the following ` +
`sources: ${this.config.compilerRoots}. Make sure you are connected ` +
Function getAndCacheSolcByUrl
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getAndCacheSolcByUrl(fileName: string, index: number) {
const { events, compilerRoots } = this.config;
const url = `${compilerRoots![index].replace(/\/+$/, "")}/${fileName}`;
events.emit("downloadCompiler:start", {
attemptNumber: index + 1
Function getSolcFromCacheOrUrl
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
async getSolcFromCacheOrUrl(versionConstraint: string, index: number = 0) {
// go through all sources (compilerRoots) trying to locate a
// suitable version of the Solidity compiler
const { compilerRoots, events } = this.config;
if (!compilerRoots || compilerRoots.length === 0) {
- 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 getSolcVersionFileName
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
getSolcVersionFileName(
version: string,
allVersions: SolidityCompilersList
): string | null {
if (allVersions.releases[version]) return allVersions.releases[version];
- 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"