Showing 166 of 237 total issues
Function list
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
list() {
var tarReader = this;
var extract = tar.extract();
tarReader.fileCount = 0;
tarReader.dirCount = 0;
Function parseFromDOM
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
parseFromDOM() {
// This is required for jest tests.
if ($ === undefined) {
var $ = require('jquery');
}
Function profileFromStandardObject
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static profileFromStandardObject(obj) {
if (BagItUtil.guessProfileType(obj) != 'bagit_profiles') {
throw Context.y18n.__("Object does not look like a BagIt profile");
}
var p = new BagItProfile();
- 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 _validateManifestEntries
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
_validateManifestEntries(manifestType) {
var manifests = this.payloadManifests();
if (manifestType === Constants.TAG_MANIFEST) {
manifests = this.tagManifests();
}
- 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 uploadedAt
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
uploadedAt() {
var uploadedAt = null;
if (this.uploadOps.length > 0) {
for (let uploadOp of this.uploadOps) {
for (let result of uploadOp.results) {
- 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 _writeIntoArchive
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function _writeIntoArchive(data, done) {
if (!fs.existsSync(path.dirname(data.dest))) {
try {
mkdirp.sync(path.dirname(data.dest), { mode: 0o755 });
} catch (err) {
- 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 title
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
get title() {
// Try to get the name of the file that was created or uploaded.
var name = null;
if (!name && this.packageOp && this.packageOp.packageName) {
name = path.basename(this.packageOp.packageName);
- 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 uploadAttempted
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
uploadAttempted() {
if (this.uploadOps) {
for (let op of this.uploadOps) {
for (let result of op.results) {
if (result.attempt > 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 writeFile
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function writeFile(data, done) {
try {
var reader = fs.createReadStream(data.bagItFile.absSourcePath);
reader.on('error', function(err) {
Function _validateSerialization
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_validateSerialization() {
var validFormat = true;
if (!this.disableSerializationCheck) {
var checkSerializationFormat = true;
var bagIsDirectory = fs.statSync(this.pathToBag).isDirectory();
Function _init
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_init() {
var profiles = BagItProfile.list(null, {
limit: 0,
offset: 0,
orderBy: 'name',
Function _processResponses
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_processResponses(controller) {
let form = new SettingsResponseForm(importedSettings);
let responses = form.getResponses();
let hasEmptyAnswers = false;
let errors = '';
Function _validatePayloadOxum
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
_validatePayloadOxum() {
//Context.logger.info(`Validator: Validating Payload-Oxum in ${this.pathToBag}`);
let found = false;
let bagInfo = this.files["bag-info.txt"];
if (bagInfo && bagInfo.keyValueCollection) {
Function list
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
list() {
var fsReader = this;
var stream = readdirp(fsReader.pathToDirectory, OPTS);
fsReader.fileCount = 0;
fsReader.dirCount = 0;
Function _ensureDirectories
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
_ensureDirectories(fileHeader) {
let template =
{
relDestPath: '',
mode: 0o755,
Function read
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
read() {
var tarReader = this;
var extract = tar.extract();
tarReader.fileCount = 0;
tarReader.dirCount = 0;
Similar blocks of code found in 2 locations. Consider refactoring. Open
_resetDisplayBeforeValidation() {
$('#batchRunning').hide();
$('#batchCompleted').hide();
$('#workflowResults').hide();
}
- 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 54.
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
_resetDisplayBeforeRunning() {
$('#batchRunning').show();
$('#workflowResults').show();
$('div.batch-result').remove();
}
- 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 54.
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 _readEntry
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
_readEntry(entry) {
let validator = this;
if (entry.fileStat.isFile()) {
var bagItFile = this._addBagItFile(entry);
if (Context.slowMotionDelay > 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 renderPackageInfo
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
renderPackageInfo(data, dartProcess) {
let [detailDiv, progressBar] = this.getDivs(dartProcess, 'packageInfo');
if (data.action == 'fileAdded') {
let shortName = Util.trimToLength(data.msg, 80, 'middle');
detailDiv.text(Context.y18n.__('Added file %s', shortName));
- 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"