Showing 207 of 207 total issues
Function runProvision
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
runProvision(system, options = {}) {
return async(this, function* () {
var steps = system.provision_steps;
options = _.clone(options);
Similar blocks of code found in 2 locations. Consider refactoring. Open
dhcp.getByNetworkName = function(name) {
return this.list_servers().then((list) => {
return _.find(list, (server) => server.NetworkName == name);
});
};
- 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 65.
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
hostonly.getByName = function(name) {
return this.list().then((list) => {
return _.find(list, (net) => net.Name == name);
});
};
- 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 65.
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 _clean_sync_folder
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
_clean_sync_folder(system, syncs) {
return async(this, function* () {
var local_user = config('agent:vm:user');
var uid, gid;
if (config('agent:requires_vm')) {
Function init
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
init() {
return defer((resolve, reject) => {
if (this._status === 'connecting' || this._status === 'connected') {
return resolve();
}
Function start
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
start(manifest, systems, opts) {
return async(this, function* () {
var result = yield this._scale(systems, 'start', opts);
// if flag --open
Function installVM
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
installVM(start = false) {
var vm_name = config("agent:vm:name");
return async(this, function* () {
var installed = yield VM.isInstalled(vm_name);
var running = (installed) ? yield VM.isRunnig(vm_name) : false;
Function _checkGitError
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
_checkGitError(git_repo, git_branch_tag_commit, git_destination_path) {
return function (err) {
var original_error = err.message;
var stack_trace = err.stack || '';
var error_type;
Function require
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Module.prototype.require = function(file, ...args) {
var result, require = () => {
return original.apply(this, [file, ...args]);
};
- 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 _findDockerfile
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
_findDockerfile(dockerfile_path) {
var msg;
if (this.system.hasOwnProperty('manifest') && this.system.manifest.cwd) {
var dockerfile_cwd = path.resolve(this.system.manifest.cwd, dockerfile_path);
- 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 constructor
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
constructor(extra_values, tracker, configuration = null) {
extra_values = _.merge({}, {
meta: {},
server: {},
}, extra_values);
- 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 _subscription
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
var _subscription = subscribe('#.status', (event) => {
if (!event) { return; }
var type;
if (event.type === "pull_msg") {
this.view('image_pull').render(event);
Function render
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
render(msg) {
if (msg.type !== "pull_msg") {
return msg;
}
Function _veredict
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_veredict() {
_.forEach(this.__folder_evidences_suggestion, function(folder_evidence_suggestion) {
var systemName = '';
var folderName = folder_evidence_suggestion.path;
var evidences_suggestion = folder_evidence_suggestion.suggestions;
Function _system_validate
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_system_validate(name, properties) {
var msg, opts;
// system_name must not contain anything not valid in docker container name
if (!name.match(/^[a-zA-Z0-9-]+$/)) {
msg = t("manifest.system_name_invalid", { system: name });
Function _scale
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_scale(systems, action, opts) {
var args = this.normalized_params.arguments;
var args_systems = (args.system || '').split(',');
args_systems = _.map(args_systems, (s) => (s || '').trim());
Function systemsInOrder
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
systemsInOrder(requireds = []) {
var edges = [];
_.each(this.systems, (system, name) => {
if (_.isEmpty(system.depends)) {
edges.push(["__", name]);
Function suggestion
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
get suggestion() {
let name = this.name;
let upper_name = name.toUpperCase();
let suggestion = _.extend({}, example_system, {
__type : 'postgres',
Function throwRunError
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
throwRunError(system, container, command, data = null, stop = false, options = {}) {
data = data ? promiseResolve(data) : container.inspect();
return data.then((data) => {
// Get container log
var promise = container.logs({stdout: true, stderr: true}).then((stream) => {
Function mount
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
mount(vm_name, share, point, opts = {}) {
_.defaults(opts, {
umask: "0000",
gid : "vboxsf",
uid : config("agent:vm:user"),