Showing 35 of 35 total issues
Function gameService
has 247 lines of code (exceeds 25 allowed). Consider refactoring. Open
function gameService($log, $rootScope, Step, Var, Ending, Character, I18n, memoizeMixin) {
// Symbols declarion for private attributes and methods
const _meta = Symbol('meta');
const _vars = Symbol('vars');
const _history = Symbol('history');
Game
has 53 functions (exceeds 20 allowed). Consider refactoring. Open
class Game {
constructor(meta) {
// Load meta data
this[_meta] = angular.copy(meta || game);
// Build step using meta data
Function StepService
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
function StepService(Choice, Slice, Stack, I18n, Explainer, $rootScope, $log) {
// Symbols declarion for private attributes and methods
const _meta = Symbol('meta');
const _game = Symbol('game');
Function gameService
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
function gameService($log, $rootScope, Step, Var, Ending, Character, I18n, memoizeMixin) {
// Symbols declarion for private attributes and methods
const _meta = Symbol('meta');
const _vars = Symbol('vars');
const _history = Symbol('history');
- 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 StackService
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
function StackService(Slice, I18n) {
// Symbols declarion for private attributes and methods
const _meta = Symbol('meta');
const _slice = Symbol('slice');
const _parent = Symbol('parent');
Function ChartService
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ChartService($filter, I18n, memoizeMixin) {
// Symbols declarion for private attributes and methods
const _game = Symbol('game');
const _id = Symbol('id');
Function controller
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
controller($state, $scope, $timeout, hotkeys, $transitions, $localForage, $translate) {
$translate.use('en');
// Method to start a new party
this.playAgain = this.start = () => {
// Simply create a new instance of game
Function ChoiceService
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ChoiceService(Slice, Stack) {
// Symbols declarion for private attributes and methods
const _meta = Symbol('meta');
const _step = Symbol('step');
const _consequences = Symbol('consequences');
Step
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class Step extends Stack {
constructor(meta, game) {
// Create slices using the parent constructor
super(meta.texts, game);
// Set private properties
Function I18nService
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
function I18nService($translate, memoizeMixin) {
const _meta = Symbol('meta');
const _fields = Symbol('fields');
class I18n {
Function VarService
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function VarService(I18n) {
// Symbols declarion for private attributes and methods
const _meta = Symbol('meta');
const _game = Symbol('game');
File game.service.js
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
export default gameService;
import _ from 'lodash';
import game from './game.json';
/** @ngInject */
Function SliceService
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SliceService(I18n) {
// Symbols declarion for private attributes and methods
const _stack = Symbol('stack');
class Slice extends I18n {
Function modernizrRun
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function modernizrRun($window) {
// Here are all the values we will test. If you want to use just one or two, comment out the lines of test you don't need.
const tests = [
// False positive in IE, supports SVG clip-path, but not on HTML element
{name: 'svg', value: 'url(#test)'},
Similar blocks of code found in 2 locations. Consider refactoring. Open
function karmaAutoRun(done) {
const configFile = path.join(process.cwd(), 'conf', 'karma-auto.conf.js');
const karmaServer = new karma.Server({configFile}, karmaFinishHandler(done));
karmaServer.start();
}
- 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 69.
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
function karmaSingleRun(done) {
const configFile = path.join(process.cwd(), 'conf', 'karma.conf.js');
const karmaServer = new karma.Server({configFile}, karmaFinishHandler(done));
karmaServer.start();
}
- 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 69.
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 routesConfig
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.routesConfig = function routesConfig($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.html5Mode(false).hashPrefix('');
$urlRouterProvider.otherwise('/');
$stateProvider
Function controller
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
controller($state, $scope, $timeout, hotkeys, $transitions, $localForage, $translate) {
$translate.use('en');
// Method to start a new party
this.playAgain = this.start = () => {
// Simply create a new instance of game
- 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 ExplainerService
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ExplainerService(I18n) {
// Symbols declarion for private attributes and methods
const _open = Symbol('open');
const _step = Symbol('step');
const _ref = Symbol('ref');
Function EndingService
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function EndingService(I18n) {
// Symbols declarion for private attributes and methods
const _meta = Symbol('meta');
const _game = Symbol('game');