Showing 117 of 158 total issues
File index.js
has 374 lines of code (exceeds 250 allowed). Consider refactoring. Open
// The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers.
const functions = require('firebase-functions');
// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require('firebase-admin');
Method onCreate
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
profileWindow = new Dialog(this);
Method onCreate
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_voting_page);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
Method retrieveDrawingsFromDatabaseStorage
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void retrieveDrawingsFromDatabaseStorage() {
FbDatabase.getRoomAttribute(roomId, USERS,
new OnSuccessValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Method setListener
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void setListener(final View view, final double amplitude, final int frequency) {
final Context context = this;
view.setOnTouchListener(new View.OnTouchListener() {
@Override
Function functionTimer
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function functionTimer (seconds, state, roomID, isWaiting, call) {
return new Promise((resolve, reject) => {
// This represents the maximum time allowed for firebase.
if (seconds > 300) {
return;
Function joinGame
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.joinGame = functions.https.onCall((data, context) => {
const id = data.id;
const username = data.username;
const league = data.league - 1;
const gameMode = data.mode;
Method setLayout
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressLint({"NewApi", "ClickableViewAccessibility"})
void setLayout(int stars, ShopActivity context) {
Resources res = context.getResources();
String colorName = color.toString();
Typeface typeMuro = TypefaceLibrary.getTypeMuro();
Method listenerEventSelector
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void listenerEventSelector(final View view, int resourceId) {
switch (resourceId) {
case R.id.drawButton:
((ImageView) view).setImageResource(R.drawable.draw_button);
launchOnlineGame(NORMAL_MODE);
Method floodFill
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
void floodFill(int x, int y) {
prepare();
if (startColor[0] == 0) {
int startPixel = pixels[(width * y) + x];
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
@Test
public void testTextFeedbackGetsDisplayed() {
int viewsBefore = paintViewHolder.getChildCount();
Item item;
do {
- 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 95.
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
@Test
public void testTextFeedbackGetsDisplayed() {
int viewsBefore = paintViewHolder.getChildCount();
Item item;
do {
- 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 95.
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
Method onCreate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
setContentView(getLayoutId());
Method retrieveFinalRanking
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void retrieveFinalRanking() {
FbDatabase.getRoomAttribute(roomId, RANKING,
new OnSuccessValueEventListener() {
@Override
Method onDataChange
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Integer state = dataSnapshot.getValue(Integer.class);
if (state != null) {
GameStates stateEnum = GameStates.convertValueIntoState(state);
Function onInterval
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function onInterval() {
if (stop === true) {
stop = false;
throw new "Timer stopped";
Function updateUser
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function updateUser(userID) {
return admin.database().ref("users/").once('value', (snapshot) => {
if(snapshot.hasChild(userID)) {
let newTrophies;
let totalMatches;
Method onCreate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
setContentView(R.layout.activity_waiting_page);
Method handleSuccessfulSignIn
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void handleSuccessfulSignIn(IdpResponse response) {
assert response != null;
final String email = response.getEmail();
if (response.isNewUser()) {
Method convertValueIntoState
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static GameStates convertValueIntoState(int value) {
GameStates state;
switch (value) {
case 0:
state = HOME_STATE;