Commit 09d5cb70 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Renamed serializer methods and DRY'd codeclimate reported code

parent 7760d3b2
...@@ -267,24 +267,30 @@ const RepoHelper = { ...@@ -267,24 +267,30 @@ const RepoHelper = {
}, },
/* eslint-enable no-param-reassign */ /* eslint-enable no-param-reassign */
blobToSimpleBlob(blob) { serializeBlob(blob) {
return { const simpleBlob = this.serializeRepoEntity('blob', blob);
type: 'blob', simpleBlob.lastCommitMessage = blob.last_commit.message;
name: blob.name, simpleBlob.lastCommitUpdate = blob.last_commit.committed_date;
url: blob.url,
icon: this.toFA(blob.icon), return simpleBlob;
lastCommitMessage: blob.last_commit.message, },
lastCommitUpdate: blob.last_commit.committed_date,
level: 0, serializeTree(tree) {
}; return this.serializeRepoEntity('tree', tree);
},
serializeSubmodule(submodule) {
return this.serializeRepoEntity('submodule', submodule);
}, },
treeToSimpleTree(tree) { serializeRepoEntity(type, entity) {
const { url, name, icon } = entity;
return { return {
type: 'tree', type,
name: tree.name, name,
url: tree.url, url,
icon: this.toFA(tree.icon), icon: this.toFA(icon),
level: 0, level: 0,
}; };
}, },
...@@ -294,21 +300,15 @@ const RepoHelper = { ...@@ -294,21 +300,15 @@ const RepoHelper = {
// push in blobs // push in blobs
data.blobs.forEach((blob) => { data.blobs.forEach((blob) => {
a.push(this.blobToSimpleBlob(blob)); a.push(this.serializeBlob(blob));
}); });
data.trees.forEach((tree) => { data.trees.forEach((tree) => {
a.push(this.treeToSimpleTree(tree)); a.push(this.serializeTree(tree));
}); });
data.submodules.forEach((submodule) => { data.submodules.forEach((submodule) => {
a.push({ a.push(this.serializeSubmodule(submodule));
type: 'submodule',
name: submodule.name,
url: submodule.url,
icon: this.toFA(submodule.icon),
level: 0,
});
}); });
return a; return a;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment