Showing 34 of 158 total issues
File index.js
has 374 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
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
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
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
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
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
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
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
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
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
Method onCreate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Open
private void retrieveFinalRanking() {
FbDatabase.getRoomAttribute(roomId, RANKING,
new OnSuccessValueEventListener() {
@Override
Method onDataChange
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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
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
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
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
Open
public static GameStates convertValueIntoState(int value) {
GameStates state;
switch (value) {
case 0:
state = HOME_STATE;
Method floodFill
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
void floodFill(int x, int y) {
prepare();
if (startColor[0] == 0) {
int startPixel = pixels[(width * y) + x];
Method getGameResultsFromDb
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public List<GameResult> getGameResultsFromDb(Context context) {
String query = "Select * FROM " + TABLE_NAME + " ORDER BY " + COLUMN_ID + " DESC LIMIT 10";
SQLiteDatabase db = this.getWritableDatabase();